摘要:
我觉得这两道题没有技巧可言,唯有把逻辑弄清楚,再用代码把自己的逻辑写下来。下面是这两道题的AC代码: 1 /** 2 * Populate each next pointer to point to its next right node. If there is no next right... 阅读全文
摘要:
这道题,采用动态规划算法。from top to down,把到每个节点的最小路径和都求出来。下面是AC代码: 1 /** 2 * Given a triangle, find the minimum path sum from top to bottom. 3 * Each ... 阅读全文
摘要:
采用2项公式解这问题挺简单,唯一需要注意的是当两个比较大的数相乘时,容易越界,我采用分子、分母同时除以他们的最大公约数。下面是AC代码: 1 /** 2 * Given an index k, return the kth row of the Pascal's triangle. 3 ... 阅读全文
摘要:
这道题挺简单的,但是需要细心。最好的方法是先对string做预处理,然后再判断是否是回文。下面是AC代码: 1 /** 2 * Given a string, determine if it is a palindrome, considering only alphanumeric ch... 阅读全文