-
Programming for Everyone !
摘要:Hello Internet ! This blog is to store my algorithm practices. Since Evernote code blocks do not show indent properly, here I am, back to cnblog. Befo
阅读全文
-
73. Set Matrix Zeroes
摘要:https://leetcode.com/problems/set-matrix-zeroes/tabs/description Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it i
阅读全文
-
89. Gray Code
摘要:https://leetcode.com/problems/gray-code/#/description The gray code is a binary numeral system where two successive values differ in only one bit. Giv
阅读全文
-
186. Reverse Words in a String II
摘要:https://leetcode.com/problems/reverse-words-in-a-string-ii/#/description Given an input string, reverse the string word by word. A word is defined as
阅读全文
-
449. Serialize and Deserialize BST
摘要:https://leetcode.com/problems/serialize-and-deserialize-bst/#/description Serialization is the process of converting a data structure or object into a
阅读全文
-
3. Longest Substring Without Repeating Characters
摘要:https://leetcode.com/problems/longest-substring-without-repeating-characters/#/description Given a string, find the length of the longest substring wi
阅读全文
-
2. Add Two Numbers
摘要:https://leetcode.com/problems/add-two-numbers/#/description You are given two non-empty linked lists representing two non-negative integers. The digit
阅读全文
-
240. Search a 2D Matrix II
摘要:https://leetcode.com/problems/search-a-2d-matrix-ii/#/description Write an efficient algorithm that searches for a value in an m x n matrix. This matr
阅读全文
-
5. Longest Palindromic Substring - Unsolved
摘要:https://leetcode.com/problems/longest-palindromic-substring/#/description Given a string s, find the longest palindromic substring in s. You may assum
阅读全文
-
48. Rotate Image
摘要:https://leetcode.com/problems/rotate-image/#/description You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clock
阅读全文
-
138. Copy List with Random Pointer
摘要:https://leetcode.com/problems/copy-list-with-random-pointer/#/description A linked list is given such that each node contains an additional random poi
阅读全文
-
210. Course Schedule II
摘要:https://leetcode.com/problems/course-schedule-ii/#/description There are a total of n courses you have to take, labeled from 0 to n - 1. Some courses
阅读全文
-
274. H-Index
摘要:https://leetcode.com/problems/h-index/#/description Given an array of citations (each citation is a non-negative integer) of a researcher, write a fun
阅读全文
-
286. Walls and Gates
摘要:https://leetcode.com/problems/walls-and-gates/#/description You are given a m x n 2D grid initialized with these three possible values. -1 - A wall or
阅读全文
-
221. Maximal Square
摘要:https://leetcode.com/problems/maximal-square/#/description Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1
阅读全文
-
117. Populating Next Right Pointers in Each Node II
摘要:https://leetcode.com/problems/populating-next-right-pointers-in-each-node-ii/#/description Follow up for problem "Populating Next Right Pointers in Ea
阅读全文
-
50. Pow(x, n)
摘要:https://leetcode.com/problems/powx-n/#/description Implement pow(x, n). Sol: Recursion. Sol 2 : iteration.
阅读全文
-
494. Target Sum - Unsolved
摘要:https://leetcode.com/problems/target-sum/#/description You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2
阅读全文
-
Word Ladder
摘要:https://github.com/Premiumlab/Python-for-Algorithms--Data-Structures--and-Interviews/blob/master/Graphs/Word%20Ladder%20Example%20Problem.ipynb BFS. W
阅读全文
-
127. Word Ladder
摘要:https://leetcode.com/problems/word-ladder/#/description Given two words (beginWord and endWord), and a dictionary's word list, find the length of shor
阅读全文
-
398. Random Pick Index
摘要:Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number m
阅读全文
-
334. Increasing Triplet Subsequence
摘要:https://leetcode.com/problems/increasing-triplet-subsequence/#/description Given an unsorted array return whether an increasing subsequence of length
阅读全文
-
377. Combination Sum IV
摘要:https://leetcode.com/problems/combination-sum-iv/#/description Given an integer array with all positive numbers and no duplicates, find the number of
阅读全文
-
102. Binary Tree Level Order Traversal
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree [3
阅读全文
-
380. Insert Delete GetRandom O(1)
摘要:https://leetcode.com/problems/insert-delete-getrandom-o1/#/description Design a data structure that supports all following operations in average O(1)
阅读全文
-
90. Subsets II
摘要:https://leetcode.com/problems/subsets-ii/#/description Given a collection of integers that might contain duplicates, nums, return all possible subsets
阅读全文
-
208. Implement Trie (Prefix Tree)
摘要:https://leetcode.com/problems/implement-trie-prefix-tree/#/description Implement a trie with insert, search, and startsWith methods. Note:You may assu
阅读全文
-
33. Search in Rotated Sorted Array
摘要:https://leetcode.com/problems/search-in-rotated-sorted-array/#/description Suppose an array sorted in ascending order is rotated at some pivot unknown
阅读全文
-
71. Simplify Path
摘要:https://leetcode.com/problems/simplify-path/#/description Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", =>
阅读全文
-
209. Minimum Size Subarray Sum
摘要:https://leetcode.com/problems/minimum-size-subarray-sum/#/description Given an array of n positive integers and a positive integer s, find the minimal
阅读全文
-
215. Kth Largest Element in an Array
摘要:https://leetcode.com/problems/kth-largest-element-in-an-array/#/description Find the kth largest element in an unsorted array. Note that it is the kth
阅读全文
-
238. Product of Array Except Self
摘要:https://leetcode.com/problems/product-of-array-except-self/#/description Given an array of n integers where n > 1, nums, return an array output such t
阅读全文
-
79. Word Search
摘要:https://leetcode.com/problems/word-search/#/description Given a 2D board and a word, find if the word exists in the grid. The word can be constructed
阅读全文
-
49. Group Anagrams
摘要:https://leetcode.com/problems/group-anagrams/#/description Given an array of strings, group anagrams together. For example, given: ["eat", "tea", "tan
阅读全文
-
236. Lowest Common Ancestor of a Binary Tree
摘要:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/#/description Given a binary tree, find the lowest common ancestor (LCA) of two
阅读全文
-
133. 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
阅读全文
-
43. Multiply Strings
摘要:https://leetcode.com/problems/multiply-strings/#/description Given two non-negative integers num1 and num2 represented as strings, return the product
阅读全文
-
98. Validate Binary Search Tree
摘要:https://leetcode.com/problems/validate-binary-search-tree/#/description Given a binary tree, determine if it is a valid binary search tree (BST). Assu
阅读全文
-
78. Subsets
摘要:https://leetcode.com/problems/subsets/#/description Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must n
阅读全文
-
75. Sort Colors
摘要:https://leetcode.com/problems/sort-colors/#/description Given an array with n objects colored red, white or blue, sort them so that objects of the sam
阅读全文
-
173. Binary Search Tree Iterator
摘要:https://leetcode.com/problems/binary-search-tree-iterator/#/description Implement an iterator over a binary search tree (BST). Your iterator will be i
阅读全文
-
341. Flatten Nested List Iterator
摘要:https://leetcode.com/problems/flatten-nested-list-iterator/#/description Given a nested list of integers, implement an iterator to flatten it. Each el
阅读全文
-
56. Merge Intervals
摘要:https://leetcode.com/problems/merge-intervals/#/solutions Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2
阅读全文
-
139. Word Break
摘要:https://leetcode.com/problems/word-break/#/description Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, dete
阅读全文
-
211. Add and Search Word - Data structure design
摘要:https://leetcode.com/problems/add-and-search-word-data-structure-design/#/description Design a data structure that supports the following two operatio
阅读全文
-
285. Inorder Successor in BST
摘要:https://leetcode.com/problems/inorder-successor-in-bst/#/description Given a binary search tree and a node in it, find the in-order successor of that
阅读全文
-
161. One Edit Distance
摘要:https://leetcode.com/problems/one-edit-distance/#/description Given two strings S and T, determine if they are both one edit distance apart. Sol: In c
阅读全文
-
200. Number of Islands
摘要:https://leetcode.com/problems/number-of-islands/#/description Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An isl
阅读全文
-
277. Find the Celebrity
摘要:https://leetcode.com/problems/find-the-celebrity/#/description Suppose you are at a party with n people (labeled from 0 to n - 1) and among them, ther
阅读全文
-
15. 3Sum
摘要:https://leetcode.com/problems/3sum/#/description Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all uni
阅读全文
|