What if the given tree could be any binary tree? Would your previous solution still work?Note:You may only use constant extra space.For example,Given ...
分类:
其他好文 时间:
2014-07-22 08:37:34
阅读次数:
289
Apparently BFS is the most obvious one.. but it is not that simple - only constant extra space is provided.Then the only strategy to take is recursion...
分类:
其他好文 时间:
2014-07-22 00:39:35
阅读次数:
258
Classic recursion\pruning problem. We can use O(n) space: A[i] = j means [i,j] is occupied.class Solution {public: int ret; bool isValid(int *A,...
分类:
其他好文 时间:
2014-07-21 11:08:20
阅读次数:
240
What's xxxAn SVM model is a representation of the examples as points in space, mapped so that the examples of the separate categories are divided by a...
分类:
其他好文 时间:
2014-07-21 09:32:31
阅读次数:
284
摘要:本Blog主要为了阐述java.lang.OutOfMemoryError:PermGenspace可能产生的原因及解决方案。其中PermGen
space是Permanent Generationspace的简写,表示内存的永久保存区域,这块内存主要是被JVM存放Class和Meta信息的,Class在被Loader时就会被放到PermGenspace中,它和存放类实例(Instanc...
分类:
其他好文 时间:
2014-07-20 22:45:43
阅读次数:
453
Determine whether an integer is a palindrome. Do this without extra space.
判断一个int值是否为回文数。
本题有几点需要注意:
(1)不能用额外存储空间,也就是说只能用常数空间解决;诸如将int转换为string再去比较字符是不可行的;
(2)判断回文数的方法有两个:从中间开始向两头判断、从两头向中间判断;后者更简...
分类:
其他好文 时间:
2014-07-19 23:22:39
阅读次数:
345
Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe...
分类:
其他好文 时间:
2014-07-19 22:36:30
阅读次数:
149
Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space for a...
分类:
其他好文 时间:
2014-07-19 22:19:36
阅读次数:
202
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?算法思路1:快慢指针,当两个指针相遇,则表示有环,...
分类:
其他好文 时间:
2014-07-19 18:38:30
阅读次数:
198
问题:以下是我编译工程后出现的错误: *** ERROR L107: ADDRESS SPACE OVERFLOW SPACE: DATA SEGMENT: _DATA_GROUP_ LENGTH: 0020H Program Si...
分类:
其他好文 时间:
2014-07-19 16:30:07
阅读次数:
272