中文


[leetcode] Word Break

Word Break 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”, “code”]. Return true because “leetcode” can be segmented as “leet code”. First, I […]


[leetcode] Single Number II

Single Number II Given an array of integers, every element appears three times except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? This is an extremely tricky problem. First, we consider each bit of the […]


[leetcode] Clone Graph

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, consider […]


[leetcode] Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For example, given s = “aab”, Return [ [“aa”,”b”], [“a”,”a”,”b”] ] Dynamic Programming. I used vector<vector<string>> dp[s.size()] as dynamic programming array. dp[i] stores all the possible palindrome […]


[Leetcode] Word Ladder II

Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from start to end, such that: Only one letter can be changed at a time Each intermediate word must exist in the dictionary For example, Given: start = “hit” end = “cog” dict = [“hot”,”dot”,”dog”,”lot”,”log”] Return […]


[Leetcode] Word Ladder

Given two words (beginWord and endWord), and a dictionary, 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 dictionary For example, Given: start = “hit” end = “cog” dict = […]