上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 28 下一页
摘要: The idea is try to replace every "++" in the current string s to "--" and see if the opponent has the chance to win or not, if the opponent is guarant 阅读全文
posted @ 2017-08-19 10:43 apanda009 阅读(144) 评论(0) 推荐(0) 编辑
摘要: You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The g... 阅读全文
posted @ 2017-08-19 09:09 apanda009 阅读(126) 评论(0) 推荐(0) 编辑
摘要: Leetcode 12, 13(需要考虑输入不合法的情况,比如“VV”或者“IIII”都是不合法的输入,要输出错误信息): if (s.indexOf(II) .. throw new A.... 如今我们最常见的罗马数字就是钟表的表盘符号:Ⅰ,Ⅱ,Ⅲ,Ⅳ(IIII),Ⅴ,Ⅵ,Ⅶ,Ⅷ,Ⅸ,Ⅹ,Ⅺ,Ⅻ 阅读全文
posted @ 2017-08-18 22:10 apanda009 阅读(162) 评论(0) 推荐(0) 编辑
摘要: The key of this problem is to think of using Stack, 阅读全文
posted @ 2017-08-16 22:10 apanda009 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 矩阵(一般是二维数组)操作的题目在面试中考察基础coding的时候比较常见,一般来说不带有太多算法思想,纯粹就是二维数组下标的操作。虽然比较简单,不过还是比较能体现基本的实现能力。LeetCode中关于矩阵操作的题目有以下几个:Spiral MatrixSpiral Matrix IIRotate 阅读全文
posted @ 2017-08-16 10:47 apanda009 阅读(446) 评论(0) 推荐(0) 编辑
摘要: 这是一个矩阵操作的题目,目标很明确,就是如果矩阵如果有元素为0,就把对应的行和列上面的元素都置为0。这里最大的问题就是我们遇到0的时候不能直接把矩阵的行列在当前矩阵直接置0,否则后面还没访问到的会被当成原来是0,最后会把很多不该置0的行列都置0了。一个直接的想法是备份一个矩阵,然后在备份矩阵上判断, 阅读全文
posted @ 2017-08-16 10:44 apanda009 阅读(121) 评论(0) 推荐(0) 编辑
摘要: Implement a Comparator<Interval> Syntax: don't forget the public sign when defining a function 阅读全文
posted @ 2017-08-13 18:13 apanda009 阅读(108) 评论(0) 推荐(0) 编辑
摘要: Analysis: Try one more example, n = 3: 000 - 0 001 - 1 011 - 3 010 - 2 110 - 6 111 - 7 101 - 5 100 - 4 Comparing n = 2: [0,1,3,2] and n=3: [0,1,3,2,6, 阅读全文
posted @ 2017-08-12 13:05 apanda009 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 这道题是要求恢复一颗有两个元素调换错了的二叉查找树。一开始拿到可能会觉得比较复杂,其实观察出规律了就比较简单。主要还是利用二叉查找树的主要性质,就是中序遍历是有序的性质。那么如果其中有元素被调换了,意味着中序遍历中必然出现违背有序的情况。那么会出现几次呢?有两种情况,如果是中序遍历相邻的两个元素被调 阅读全文
posted @ 2017-08-12 12:26 apanda009 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 这道题是求解所有可行的二叉查找树,从Unique Binary Search Trees中我们已经知道,可行的二叉查找树的数量是相应的卡特兰数,不是一个多项式时间的数量级,所以我们要求解所有的树,自然是不能多项式时间内完成的了。算法上还是用求解NP问题的方法来求解,也就是N-Queens中介绍的在循 阅读全文
posted @ 2017-08-12 10:15 apanda009 阅读(157) 评论(0) 推荐(0) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 28 下一页