随笔分类 - LeetCode
摘要:O(n) look for the median(or any target rank) in an array 1 class Solution { 2 public static void main(String[] args) { 3 Solution solution = new Solut
阅读全文
摘要:630. Course Schedule III There are n different online courses numbered from 1 to n. Each course has some duration(course length) t and closed on dthda
阅读全文
摘要:621. Task Scheduler Given a char array representing tasks CPU need to do. It contains capital letters A to Z where different letters represent differe
阅读全文
摘要:72. Edit Distance Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as
阅读全文
摘要:56. Merge Intervals Given a collection of intervals, merge all overlapping intervals. For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10]
阅读全文
摘要:32. Longest Valid Parentheses Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parenthese
阅读全文
摘要:384. Shuffle an Array Shuffle a set of numbers without duplicates. Example: // Init an array with set 1, 2, and 3. int[] nums = {1,2,3}; Solution solu
阅读全文
摘要:232. Implement Queue using Stacks Implement the following operations of a queue using stacks. push(x) -- Push element x to the back of queue. pop() --
阅读全文
摘要:151. Reverse Words in a String Given an input string, reverse the string word by word. For example,Given s = "the sky is blue",return "blue is sky the
阅读全文
摘要:96. Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, the
阅读全文
摘要:201. Bitwise AND of Numbers Range Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive
阅读全文
摘要:221. Maximal Square Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. For example, gi
阅读全文
摘要:376. Wiggle Subsequence A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between pos
阅读全文
摘要:331. Verify Preorder Serialization of a Binary Tree One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null nod
阅读全文
摘要:127. Word Ladder Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from begin
阅读全文
摘要:365. Water and Jug Problem You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to d
阅读全文
摘要:355. Design Twitter Design a simplified version of Twitter where users can post tweets, follow/unfollow another user and is able to see the 10 most re
阅读全文
摘要:93. Restore IP Addresses Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given
阅读全文
摘要:73. Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. Hide Tags Array Hide Similar Probl
阅读全文
摘要:222. Count Complete Tree Nodes Given a complete binary tree, count the number of nodes. Definition of a complete binary tree from Wikipedia:In a compl
阅读全文

浙公网安备 33010602011771号