In the "100 game," two players take turns adding, to a running total, any integer from 1..10. The player who first causes the running total to reach or exceed 100 wins. What if we change the game so that players cannot re-use integers? For examp
学习这件事在任何时间都不能停下.准备坚持刷leecode来提高自己,也会把自己的解答过程记录下来,希望能进步. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution. Example: Given n
以前觉得后续遍历最难写,今天看了篇博客http://blog.csdn.net/sgbfblog/article/details/7773103,其实却是我们仔细比较后续遍历和先序遍历,其实后续遍历就是按照 根右左 的方式先序访问然后逆序就是答案了,会先序就会逆序了 leecode 的AC代码: public class Solution { public List<Integer> postorderTraversal(TreeNode root) { ArrayList<Integ
写完才知道自己学习都是似是而非啊,大家可以也在leecode上提交代码,纯手写,离开eclipse第一种方式:数据结构书上的,使用栈大概思路.1.不断将根节点的左孩子的左孩子直到为空,在这个过程入栈.2.因为栈顶的节点的左孩子为空,所以栈顶的的节点的左子树肯定访问完毕,所以出栈后直接指向右孩子.其实这里面有个思想迭代和递归的本质相同之处是什么?以后会写一篇我的思考. public class Solution { public List<Integer> preorderTraversal(T
刚开始做这道题时,我纠结了许久什么是最优走法,想了好半天也不晓得,后来被大神点醒,最有走法,最后就是每个格子都走了一遍,得,这下简单多了,算一下总共的格数是奇数还是偶数,奇数则先手赢,偶数则后手赢. 代码如下: #include<iostream> #include<cstdio> #include<cstdlib> using namespace std; int i_number; int main() { cin>>i_nu
称号: Card Game Cheater Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 103 Accepted Submission(s): 74 Problem Description Adam and Eve play a card game using a regular deck of 52 cards. The rules