Given a linked list, determine if it has a cycle in it. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ...
分类:
其他好文 时间:
2015-04-17 17:59:53
阅读次数:
112
Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
解题思路:
思路比较简单,将原来的数求逆数。若逆数与原数相等,返回true,否则,返回false。弄清楚,负数能否回文?若溢出咋办?这里总结一下,若遇到整数的逆转,或者字符转化为整数,就需要考虑是否溢...
分类:
其他好文 时间:
2015-04-17 15:42:22
阅读次数:
115
题目:Given a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must close in the corre...
分类:
其他好文 时间:
2015-04-17 13:33:47
阅读次数:
82
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-04-17 08:21:12
阅读次数:
101
Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space?摘自剑指offer:当用一个指针遍历链表不能解决问题的时候,可以尝试用两个指针来遍...
分类:
其他好文 时间:
2015-04-17 00:56:38
阅读次数:
166
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2015-04-16 19:33:20
阅读次数:
110
A message containing letters from A-Z is being encoded to numbers using the
following mapping:
'A' -> 1
'B' -> 2
...
'Z' -> 26
Given an encoded message containing digits, determine the total nu...
分类:
其他好文 时间:
2015-04-15 23:22:45
阅读次数:
212
题目:Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes?...
分类:
其他好文 时间:
2015-04-15 23:20:59
阅读次数:
159
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2015-04-15 22:59:23
阅读次数:
146
题目链接:Validate Binary Search Tree
Given a binary tree, determine if it is a valid binary search tree (BST).
Assume a BST is defined as follows:
The left subtree of a node contains only nodes with ...
分类:
其他好文 时间:
2015-04-14 21:41:20
阅读次数:
118