Determine whether an integer is a palindrome. Do this without extra space.
思路:若使用【Leetcode】Reverse
Integer 的方法,判断反转后的整数是否与原整数相同,则可能出现溢出情况;又因为题目要求不适用额外空间,可以之间对比整数第一个与最后一个数的值,再依次类推。
class Solution {...
分类:
其他好文 时间:
2014-06-22 20:43:56
阅读次数:
187
检查一个图是否是二分图的算法
使用的是宽度搜索:
1 初始化一个颜色记录数组
2 利用queue宽度遍历图
3 从任意源点出发,染色0, 或1
4 遍历这点的邻接点,如果没有染色就染色与这个源点相反的颜色,如果已经染色并且和源点的值相反,那么就是合法点,如果是相同的颜色,那么就不能是二分图
参考:http://www.geeksforgeeks.org/bipartite-gra...
分类:
其他好文 时间:
2014-06-22 18:35:43
阅读次数:
223
题目:Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmet...
分类:
其他好文 时间:
2014-06-20 18:44:41
阅读次数:
279
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2014-06-18 13:29:31
阅读次数:
214
题目
Determine whether an integer is a palindrome. Do this without extra space.
Some hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to ...
分类:
其他好文 时间:
2014-06-17 16:12:39
阅读次数:
226
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree is symmetric:
1
/ 2 2
/ \ / 3 4 4 3
But the f...
分类:
其他好文 时间:
2014-06-15 19:49:35
阅读次数:
176
Symmetric TreeGiven a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric...
分类:
其他好文 时间:
2014-06-15 18:55:36
阅读次数:
188
数组的恒等 === 在文档中是这么说的:
Check whether two arrays or subarrays share the same storage and elements by comparing them with the identity operators (=== and !==).
数组的恒等 === 判断即判断两个数组所指向的元素存储区是否相同。
但 XCode 6 测试下来,结果大为迥异:var a = [1, 2, 3]; a === a 其结果却为 false,...
分类:
其他好文 时间:
2014-06-14 11:39:39
阅读次数:
280
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i...
分类:
其他好文 时间:
2014-06-14 08:52:31
阅读次数:
265
Environment variable: "PATH" - This test checks
whether the length of the environment variable "PATH" does not exceed the
recommended length.预期值:1023实...
分类:
数据库 时间:
2014-06-12 17:25:20
阅读次数:
633