随笔分类 -  LeetCode

摘要:Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequent 阅读全文
posted @ 2015-03-12 14:24 Grandyang 阅读(25048) 评论(12) 推荐(1) 编辑
摘要:Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The r 阅读全文
posted @ 2015-03-11 11:02 Grandyang 阅读(15134) 评论(5) 推荐(1) 编辑
摘要:Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relati 阅读全文
posted @ 2015-03-11 10:22 Grandyang 阅读(22472) 评论(16) 推荐(0) 编辑
摘要:There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values). Before being passed to your function, nums is ro 阅读全文
posted @ 2015-03-10 13:47 Grandyang 阅读(18993) 评论(3) 推荐(0) 编辑
摘要:There is an integer array nums sorted in ascending order (with distinct values). Prior to being passed to your function, nums is possibly rotated at a 阅读全文
posted @ 2015-03-10 12:34 Grandyang 阅读(43877) 评论(7) 推荐(1) 编辑
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit 阅读全文
posted @ 2015-03-10 11:11 Grandyang 阅读(9680) 评论(4) 推荐(1) 编辑
摘要:You are given an m x n integer matrix matrix with the following two properties: Each row is sorted in non-decreasing order. The first integer of each 阅读全文
posted @ 2015-03-09 12:53 Grandyang 阅读(15391) 评论(11) 推荐(0) 编辑
摘要:Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. Example 1: Input: matri 阅读全文
posted @ 2015-03-09 06:43 Grandyang 阅读(37026) 评论(9) 推荐(2) 编辑
摘要:Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle 阅读全文
posted @ 2015-03-09 02:38 Grandyang 阅读(49988) 评论(15) 推荐(1) 编辑
摘要:Reverse bits of a given 32 bits unsigned integer. Example 1: Input: 00000010100101000001111010011100 Output: 00111001011110000010100101000000 Explanat 阅读全文
posted @ 2015-03-08 10:15 Grandyang 阅读(24119) 评论(5) 推荐(1) 编辑
摘要:Given the head of a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should p 阅读全文
posted @ 2015-03-08 08:37 Grandyang 阅读(14868) 评论(0) 推荐(2) 编辑
摘要:We can scramble a string s to get a string t using the following algorithm: If the length of the string is 1, stop. If the length of the string is > 1 阅读全文
posted @ 2015-03-06 15:53 Grandyang 阅读(16761) 评论(10) 推荐(1) 编辑
摘要:An n-bit gray code sequence is a sequence of 2n integers where: Every integer is in the inclusive range [0, 2n - 1], The first integer is 0, An intege 阅读全文
posted @ 2015-03-05 13:52 Grandyang 阅读(20072) 评论(3) 推荐(4) 编辑
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits, determ 阅读全文
posted @ 2015-03-04 15:03 Grandyang 阅读(31280) 评论(13) 推荐(0) 编辑
摘要:Given a collection of integers that might contain duplicates, S, return all possible subsets. Note: Elements in a subset must be in non-descending ord 阅读全文
posted @ 2015-03-03 14:57 Grandyang 阅读(20461) 评论(4) 推荐(0) 编辑
摘要:Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Retu 阅读全文
posted @ 2015-03-02 17:29 Grandyang 阅读(32183) 评论(8) 推荐(6) 编辑
摘要:Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4 Out 阅读全文
posted @ 2015-03-01 09:17 Grandyang 阅读(21108) 评论(11) 推荐(1) 编辑
摘要:Given a string containing only digits, restore it by returning all possible valid IP address combinations. Example: Input: "25525511135" Output: ["255 阅读全文
posted @ 2015-02-28 15:28 Grandyang 阅读(21528) 评论(5) 推荐(5) 编辑
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: Input: 3 Output: [ [1,null,3,2], 阅读全文
posted @ 2015-02-26 13:16 Grandyang 阅读(22597) 评论(9) 推荐(3) 编辑
摘要:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n = 3, the 阅读全文
posted @ 2015-02-25 14:56 Grandyang 阅读(23810) 评论(4) 推荐(4) 编辑

Fork me on GitHub