代码改变世界

[LeetCode] 611. Valid Triangle Number_Medium tag: Two pointers

2019-05-31 11:01 by Johnson_强生仔仔, 254 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we tak 阅读全文

[LeetCode] 167. Two Sum II - Input array is sorted_Easy tag: Hash/Two pointers

2019-05-31 10:22 by Johnson_强生仔仔, 195 阅读, 0 推荐, 收藏, 编辑
摘要:Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function 阅读全文

[LeetCode] 126. Word Ladder II_Hard tag: BFS&DFS

2019-05-26 05:33 by Johnson_强生仔仔, 376 阅读, 0 推荐, 收藏, 编辑
摘要:Given two words (beginWord and endWord), and a dictionary's word list, find all shortest transformation sequence(s) from beginWord to endWord, such th 阅读全文

[LeetCode] 39. Combination Sum_Medium tag: backtracking

2019-05-25 23:14 by Johnson_强生仔仔, 244 阅读, 0 推荐, 收藏, 编辑
摘要:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the 阅读全文

[LeetCode] 40. Combination Sum II_Medium tag: backtracking

2019-05-25 22:55 by Johnson_强生仔仔, 261 阅读, 0 推荐, 收藏, 编辑
摘要:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numb 阅读全文

[LeetCode] 131. Palindrome Partitioning_Medium tag: DFS, backtracking, Palindrome

2019-05-25 10:14 by Johnson_强生仔仔, 301 阅读, 0 推荐, 收藏, 编辑
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. Example: 这 阅读全文

[Palindrome] Check any substring in a s is a palindrome or not.

2019-05-25 09:57 by Johnson_强生仔仔, 328 阅读, 0 推荐, 收藏, 编辑
摘要:Give a s, need to check every substring whether it is a palindrome or not. Brute Force T: O(n ^3) 我们利用如果s[start] == s[end], 则只需要判断s[start + 1][end - 1 阅读全文

[LeetCode] 52. N-QueensII_Hard tag: DFS, backtracking

2019-05-24 10:40 by Johnson_强生仔仔, 260 阅读, 0 推荐, 收藏, 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文

[LeetCode] 51. N-Queens_Hard tag: DFS, backtracking

2019-05-24 10:22 by Johnson_强生仔仔, 237 阅读, 0 推荐, 收藏, 编辑
摘要:The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all 阅读全文

[LeetCode] 47. Permutations II_Medium tag: DFS, backtracking

2019-05-24 09:35 by Johnson_强生仔仔, 248 阅读, 0 推荐, 收藏, 编辑
摘要:Given a collection of numbers that might contain duplicates, return all possible unique permutations. Example: Input: [1,1,2] Output: [ [1,1,2], [1,2, 阅读全文
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 39 下一页