Problem Description
Write a program to read in a list of integers and determine whether or not each number is prime. A number, n, is prime if its only divisors are 1 and n. For this problem, the numbers 1 and 2 are not considered primes.
Input
Each inp...
分类:
其他好文 时间:
2015-03-13 14:24:56
阅读次数:
130
Given a linked list, determine if it has a cycle in it.简单题,只要知道快慢指针这个技巧就很容易解了。 1 class Solution { 2 public: 3 bool hasCycle(ListNode *head) { 4 ...
分类:
其他好文 时间:
2015-03-13 01:38:17
阅读次数:
110
Given a binary tree, determine if it is height-balanced.
For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never differ ...
分类:
其他好文 时间:
2015-03-12 20:51:39
阅读次数:
108
Linked List CycleGiven a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space?SOLUTION 1: 依次将链表节点添加入已....
分类:
其他好文 时间:
2015-03-11 23:04:31
阅读次数:
223
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if yo...
分类:
其他好文 时间:
2015-03-11 21:40:22
阅读次数:
126
题目描述:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in ...
分类:
其他好文 时间:
2015-03-11 17:02:55
阅读次数:
98
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
98 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 o...
分类:
其他好文 时间:
2015-03-11 14:58:29
阅读次数:
122
Palindrome Number问题:Determine whether an integer is a palindrome. Do this without extra space.思路:常用的进制遍历方法while(num != 0){ remian = num % 进制; ...
分类:
其他好文 时间:
2015-03-11 12:07:14
阅读次数:
148
Path Sum问题: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 g...
分类:
其他好文 时间:
2015-03-11 09:17:40
阅读次数:
123
Problem Description
In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryption, etc. In this problem you are given a number, you have to determine the number of digit...
分类:
其他好文 时间:
2015-03-10 19:30:04
阅读次数:
150