`
frank-liu
  • 浏览: 1682117 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
问题描述: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you solve it without using extra space? 原问题链接:https://leetcode.com/problems/linked-list-cycle-ii/   问题分析   和前一个问题比起来,这个问题相对于前面一个问题更进一步。在这里不 ...
问题描述: Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? 原问题链接:https://leetcode.com/problems/linked-list-cycle/   问题分析   这是一个比较老的问题了。要判断一个链表是否存在有环,一种办法就是采用快慢指针的方式。一个向前移动一步,一个向前移动两步。这样只要存在有环这个快指针就一定可以遇到慢指针。这样也就证明了链表存在环。   在实际实现的时候还需要考虑 ...
问题描述: Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word. Return all such possible sentences. For example, givens = "catsanddog",dict = ["cat", "cats", "and" ...
问题描述: 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, givens = "leetcode",dict = ["leet", "code"]. Return true because "leetcode" can be segmented ...
问题描述: Given an array of integers, every element appears twice except for one. Find that single one. Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? 原问题链接:https://leetcode.com/problems/single-number/   问题分析   这个问题的解决思路相对来说就比较简单了。只是 ...

leetcode: Candy

问题描述: There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following requirements: Each child must have at least one candy. Children with a higher rating get more candies than their neighbors. What is the mi ...
问题描述: There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its next station (i+1). You begin the journey with an empty tank at one of the ...
问题描述: Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.   OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each node, and , as a separator for node label and each neighbor of the node.   As an example, ...
问题描述: Given a string s, partition s such that every substring of the partition is a palindrome. Return the minimum cuts needed for a palindrome partitioning of s. For example, given s = "aab",Return 1 since the palindrome partitioning ["aa","b"] could be produced us ...
问题描述: Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, X X X X X O O X X X O X X O X X   After running your function, the board should be:   X X X X X X X X X X X ...
问题描述: Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / \ 2 3   The root-to-le ...
问题描述: Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity. 原问题 ...
问题描述: Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, such that: Only one letter can be changed at a time Each intermediate word must exist in the word list For example, Given:beginWord = &q ...
问题描述: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: Panama" is a palindrome."race a car" is not a palindrome. Note:Have you consider that the string might be empt ...
问题描述: Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The path does not need to go through the root. For example:Given the below binary tree, ...
Global site tag (gtag.js) - Google Analytics