摘要: class Solution {public: int uniquePathsWithObstacles(vector > &obstacleGrid) { vector >& dp = obstacleGrid; if (dp.empty() || dp[0].e... 阅读全文
posted @ 2014-03-14 19:56 卖程序的小歪 阅读(157) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: int uniquePaths(int m, int n) { int (*dp)[101] = new int[101][101]; for (int i=0;i<101;i++) dp[0][i] = 0; ... 阅读全文
posted @ 2014-03-14 16:58 卖程序的小歪 阅读(154) 评论(0) 推荐(0) 编辑
摘要: A message containing letters from A-Z is being encoded to numbers using the following mapping: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Given an encoded messag... 阅读全文
posted @ 2014-03-13 22:22 卖程序的小歪 阅读(191) 评论(0) 推荐(0) 编辑
摘要: class Solution {private: int row[9]; int col[9]; int blk[9]; public: void solveSudoku(vector > &board) { if (board.empty() || board[0].empty()) return; initBits(board); dfs(board, 0, 0); } bool dfs(vector >& board, int ridx, int cidx) { ... 阅读全文
posted @ 2014-03-13 16:24 卖程序的小歪 阅读(218) 评论(0) 推荐(0) 编辑
摘要: class Solution {private: // only used by _isValidSudoku int row[9]; int col[9]; int blk[9];public: bool _isValidSudoku(vector >& board) { if (board.empty()) return true; memset(row, 0, sizeof(row)); memset(col, 0, sizeof(col)); memset(blk, 0, sizeof(blk)); ... 阅读全文
posted @ 2014-03-12 21:34 卖程序的小歪 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 void solve(vector > &board) { 4 if (board.size() == 0) return; 5 int my = board.size() - 1; 6 int mx = board[0].size() -1; 7 // top border 8 for (int i=0; i >& board, int mx, int my, int _x, int _y, char oc, char nc) {40 ... 阅读全文
posted @ 2014-03-11 21:37 卖程序的小歪 阅读(197) 评论(0) 推荐(0) 编辑
摘要: int sqrt(int x) { int lo = 0; int hi = x; int m = 0; double mul = 0; for (;;) { m = (lo + hi) / 2; if (lo > hi) break; mul = 1.0 * m * m; if (mul > x) { hi = m - 1; } else if (mul == x) { ... 阅读全文
posted @ 2014-03-11 16:17 卖程序的小歪 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 1 double pow(double x, int n) { 2 if (n == 0) return 1; 3 unsigned int k = 0; 4 if (n >=1;14 }15 return ret;16 }MS 2012 math.h 1 template inline 2 _Ty _Pow_int(_Ty _X, int _Y) 3 {unsigned int _N; 4 if (_Y >= 0) 5 ... 阅读全文
posted @ 2014-03-11 14:39 卖程序的小歪 阅读(147) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: void nextPermutation(vector &num) { if (num.size() =0 && (num[i] >= num[i+1])) i--; if (i >= 0) { ... 阅读全文
posted @ 2014-03-10 22:18 卖程序的小歪 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 以前好几次在学语言的使用都有实现这个ack函数的经历,今天读本算法书,偶尔又提到了这个,查了下wiki来头好大Values ofA(m,n)m\n01234n012345123456235791135132961125413=65533=265536−3=== 阅读全文
posted @ 2014-03-06 15:13 卖程序的小歪 阅读(753) 评论(0) 推荐(0) 编辑