-
STL风格版本 https://gitcafe.com/liancheng/leetcode/blob/master/solutions/next-permutation/solution.hpp
利用
reverse_iterator
简化边界判断,可处理重复元素。参见:生成全排列、下一个排列、第k
个排列的。 -
一维DP版本 https://gitcafe.com/liancheng/leetcode/blob/master/solutions/unique-binary-search-trees/dp.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Loads default settings when startup {{{ | |
source $VIMRUNTIME/vimrc_example.vim | |
if filereadable($HOME . "/.vimpath") | |
source $HOME/.vimpath | |
endif | |
call pathogen#infect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# License: Public Domain. | |
# Author: Joseph Wecker, 2012 | |
# | |
# -- DEPRICATED -- | |
# This gist is slow and is missing .bashrc_once | |
# Use the one in the repo instead! https://github.com/josephwecker/bashrc_dispatch | |
# (Thanks gioele) | |
# | |
# Are you tired of trying to remember what .bashrc does vs .bash_profile vs .profile? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'cgi' | |
require 'digest/md5' | |
require 'net/https' | |
require 'uri' | |
module Jekyll | |
class GistTag < Liquid::Tag | |
def initialize(tag_name, text, token) | |
super | |
@text = text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <limits> | |
namespace std { | |
template<> | |
struct numeric_limits<mpz_class> { | |
public: | |
static const bool is_specialized = true; | |
static mpz_class min() throw() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(import (sample)) | |
(hello-world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Decode Ways | |
https://github.com/liancheng/leetcode/blob/master/solutions/decode-ways/dp.hpp | |
Partition List | |
https://github.com/liancheng/leetcode/blob/master/solutions/partition-list/solution.hpp | |
Flatten Binary Tree to Linked List | |
https://github.com/liancheng/leetcode/blob/master/solutions/flatten-binary-tree-to-linked-list/solution.hpp | |
Binary Tree Inorder Traversal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string reverseSentence (string const& s) | |
{ | |
string t (s.rbegin (), s.rend ()); | |
for (auto p = begin (t), q = begin (t); p != end (t); ) { | |
p = find_if (p, end (t), [] (char c) { return c != ' '; }); | |
q = find (p, end (t), ' '); | |
reverse (p, q); | |
p = q; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.actors._ | |
import Actor._ | |
def sleepSort(xs : List[Int]) : List[Int] = { | |
def sorter(aggregator : Actor, n : Int) = actor { | |
reactWithin(n * 1000) { | |
case TIMEOUT => { | |
aggregator ! n | |
exit | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
mkdir -p data | |
for i in `seq $1`; do | |
file=data/$i | |
for j in `seq $2`; do | |
echo ${RANDOM} >> $file | |
done |
OlderNewer