qingcheng奕  

2014年7月6日

摘要: 判断是否为n回文,比如 a b a 是1 回文, abcdab是2回文。输入: abcabc|3 这种格式,输出true or false#include #include #include using namespace std; bool judge_n_pal(string str,int ... 阅读全文
posted @ 2014-07-06 21:58 qingcheng奕 阅读(138) 评论(0) 推荐(0) 编辑
 
摘要: move 2turn rightmove 3turn rightmove 6初始位置为(0,0),方向为north,求最后的位置。string2char: const char* t = second.c_str();string2int: #includestringsecond; cin>>s... 阅读全文
posted @ 2014-07-06 21:32 qingcheng奕 阅读(164) 评论(0) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/jump-game-ii/给一个数列,每次可以跳相应位置上的步数,问跳到最后位置至少用几步。动态规划:j[pos]表示从0到pos至少要跳的步数,初始化为nj[pos] = min { j[i] + 1 ,j[pos]} if(A[i... 阅读全文
posted @ 2014-07-06 15:21 qingcheng奕 阅读(169) 评论(1) 推荐(0) 编辑
 
摘要: https://oj.leetcode.com/problems/jump-game/从0开始,根据每一位上存的数值往前跳。这道题给想复杂了。。。记录当前位置 pos,记录可以调到的最远达位置为far,并随时更新它如果 far >= n - 1 则相当于调到末尾了,在此过程中 pos = n - 1... 阅读全文
posted @ 2014-07-06 13:57 qingcheng奕 阅读(178) 评论(0) 推荐(0) 编辑