Given a linked list, determine if it has a cycle in it.Can you solve it without using extra space?每个节点再开辟一个属性存放是否访问过,这样遍历一遍即可知道是否有环。但为了不增加额外的空间,可以设置两个...
分类:
其他好文 时间:
2015-04-08 01:01:24
阅读次数:
120
题目:
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, given
s = “leetcode”,
dict = [“leet...
分类:
其他好文 时间:
2015-04-06 21:53:21
阅读次数:
163
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-05 17:20:10
阅读次数:
97
题目:
Given a linked list, determine if it has a cycle in it. 思路分析:
利用快慢指针slow,fast。 slow指针每次走一步,fast指针每次走两步,倘若存在环,则slow和fast必定在某一时刻相遇。C++参考代码:/**
* Definition for singly-linked list.
* struct ListNo...
分类:
其他好文 时间:
2015-04-05 11:59:17
阅读次数:
99
??
问题描述:
Determine whether an integer is a palindrome. Do thiswithout extra space.
click to showspoilers.
Some hints:
Could negative integers be palindromes? (ie, -1)
If yo...
分类:
其他好文 时间:
2015-04-04 09:18:33
阅读次数:
137
题目:Word Break通过率:22.6%难度:中等Given a stringsand a dictionary of wordsdict, determine ifscan be segmented into a space-separated sequence of one or more ...
分类:
其他好文 时间:
2015-04-03 23:44:22
阅读次数:
171
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
The brackets must close in the correct order, "()" and "()[]{}" are
all vali...
分类:
其他好文 时间:
2015-04-02 21:00:04
阅读次数:
105
【题目】
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Write a function to determine if a given target...
分类:
其他好文 时间:
2015-04-02 15:04:37
阅读次数:
114
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-02 14:48:37
阅读次数:
163
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 ...
分类:
其他好文 时间:
2015-04-02 10:26:41
阅读次数:
127