leetcode
文章平均质量分 66
yanqinghe123
这个作者很懒,什么都没留下…
展开
-
LeetCode 164. Maximum Gap
LeetCode 164. Maximum Gap 问题来源LeetCode 164. Maximum Gap问题描述 Given an unsorted array, find the maximum difference between the successive elements in its sorted form. Try to solve it in linear原创 2017-12-07 18:45:37 · 419 阅读 · 0 评论 -
LeetCode207 Course Schedule
LeetCode207 Course Schedule问题描述 here are a total of n courses you have to take, labeled from 0 to n - 1. Some courses may have prerequisites, for example to take course 0 you have to first take co原创 2017-12-11 20:40:05 · 288 阅读 · 0 评论 -
LeetCode 190 Reverse Bits
LeetCode 190 Reverse Bits 问题来源LeetCode190 Reverse Bits问题描述 Reverse bits of a given 32 bits unsigned integer. For example, given input 43261596 (represented in binary as 0000001010010100000111原创 2017-12-03 10:04:37 · 182 阅读 · 0 评论 -
LeetCode191 Number of 1 Bits
LeetCode191 Number of 1 Bits 问题来源LeetCode191 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 3原创 2017-12-03 09:59:33 · 183 阅读 · 0 评论 -
LeetCode201. Bitwise AND of Numbers Range
LeetCode201. Bitwise AND of Numbers Range 问题来源LeetCode201. Bitwise AND of Numbers Range问题描述 Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this rang原创 2017-12-11 15:35:58 · 337 阅读 · 0 评论 -
LeetCode94 Binary Tree Inorder Traversal
LeetCode94 Binary Tree Inorder Traversal问题来源LeetCode94问题描述 Given a binary tree, return the inorder traversal of its nodes’ values. For example: Given binary tree [1,null,2,3], 1 \原创 2017-11-22 21:08:10 · 171 阅读 · 0 评论 -
LeeCode Contest 62 Find Smallest Letter Greater Than Target
Weekly Contest 62 Find Smallest Letter Greater Than Target问题描述 Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element原创 2017-12-10 23:32:12 · 271 阅读 · 0 评论 -
LeetCode92 Reverse Linked List II
LeetCode92 Reverse Linked List II 问题来源LeetCode92问题描述 Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4,原创 2017-10-16 22:24:51 · 176 阅读 · 0 评论 -
LeetCode91 Decode Ways
LeetCode91 Decode Ways 问题来源LeetCode91问题描述 A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26 Given an encoded message原创 2017-10-16 22:16:52 · 239 阅读 · 0 评论 -
LeetCode93 Restore IP Addresses
LeetCode93 Restore IP Addresses 问题来源leetcode93问题描述Given a string containing only digits, restore it by returning all possible valid IP address combinations.For example: Given “25525511135”,return [原创 2017-10-24 23:07:58 · 201 阅读 · 0 评论 -
LeetCode70 Climbing Stairs
LeetCode70 Climbing Stairs问题描述 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the to原创 2017-10-15 22:56:22 · 182 阅读 · 0 评论 -
LeetCode90 Subsets II
LeetCode90 Subsets II 问题来源LeetCode90问题描述 Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: The solution set must not contain duplicate sub原创 2017-10-15 22:50:15 · 187 阅读 · 0 评论 -
LeetCode89 Gray Code
LeetCode89 Gray Code 问题来源LeetCode89问题描述 Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0.原创 2017-10-15 22:44:06 · 218 阅读 · 0 评论 -
LeetCode88 Merge Sorted Array
LeetCode88 Merge Sorted Array 问题来源LeetCode88问题描述 Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: You may assume that nums1 has enough spa原创 2017-10-15 22:38:21 · 165 阅读 · 0 评论 -
LeetCode87 Scramble String
LeetCode87 Scramble String问题来源LeetCode87问题描述 Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representat原创 2017-10-15 22:33:07 · 320 阅读 · 0 评论 -
LeetCode82 Remove Duplicates from Sorted List II
LeetCode82 Remove Duplicates from Sorted List II问题来源LeetCode82问题描述Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For exam原创 2017-10-15 21:54:53 · 347 阅读 · 0 评论 -
LeetCode86 Partition List
LeetCode86 Partition List问题来源LeetCode86问题描述 Given 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 preserve the原创 2017-10-15 21:48:00 · 201 阅读 · 0 评论 -
LeetCode208 Implement Trie (Prefix Tree)
LeetCode208 Implement Trie (Prefix Tree)问题描述 Implement a trie with insert, search, and startsWith methods. 问题分析问题描述很简单,就是写一个Trie树。至于Trie树是干什么的。前段时间刚好在做文本分词的时候研究过。大家可以去网上看一下。Wiki6天通吃树结构—— 第五天 Trie树原创 2017-12-11 21:28:13 · 306 阅读 · 0 评论 -
LeetCode 189 Rotate Array
LeetCode189 Rotate Array 问题来源LeetCode189 Rotate Array问题描述 Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,原创 2017-12-03 21:11:39 · 185 阅读 · 0 评论 -
LeetCode Best Time to Buy and Sell Stock I & II & III & IV
LeetCode Best Time to Buy and Sell Stock 问题来源 LeetCode 121. Best Time to Buy and Sell Stock LeetCode 122. Best Time to Buy and Sell Stock II LeetCode 123. Best Time to Buy and Sell Stock II原创 2017-12-03 23:40:24 · 345 阅读 · 0 评论 -
LeetCode 165. Compare Version Numbers
LeetCode 165. Compare Version Numbers 问题来源LeetCode 165. Compare Version Numbers问题描述 Compare two version numbers version1 and version2. If version1 > version2 return 1, if version1 < version2 re原创 2017-12-07 18:32:56 · 268 阅读 · 0 评论 -
LeetCode 166. Fraction to Recurring Decimal
LeetCode 166. Fraction to Recurring Decimal 问题来源LeetCode 166. Fraction to Recurring Decimal问题描述 Given two integers representing the numerator and denominator of a fraction, return the fraction in原创 2017-12-06 21:48:28 · 233 阅读 · 0 评论 -
LeetCode 167. Two Sum II - Input array is sorted
LeetCode 167. Two Sum II - Input array is sorted 问题来源LeetCode 167. Two Sum II - Input array is sorted问题描述 Given an array of integers that is already sorted in ascending order, find two numbers suc原创 2017-12-06 21:37:18 · 242 阅读 · 0 评论 -
LeetCode 168. Excel Sheet Column Title
LeetCode 168. Excel Sheet Column Title 问题来源LeetCode 168. Excel Sheet Column Title问题分析 Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example:原创 2017-12-06 21:28:16 · 235 阅读 · 0 评论 -
LeetCode 169. Majority Element
LeetCode 169. Majority Element 问题来源LeetCode 169. Majority Element问题描述 Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.原创 2017-12-06 21:20:40 · 248 阅读 · 0 评论 -
LeetCode 171. Excel Sheet Column Number
LeetCode 171. Excel Sheet Column Number 问题来源LeetCode 171. Excel Sheet Column Number问题描述 Related to question Excel Sheet Column Title Given a column title as appear in an Excel sheet, return i原创 2017-12-06 21:11:35 · 306 阅读 · 0 评论 -
LeetCode 172. Factorial Trailing Zeroes
LeetCode 172. Factorial Trailing Zeroes 问题来源LeetCode 172. Factorial Trailing Zeroes问题描述 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in logari原创 2017-12-06 21:08:30 · 252 阅读 · 0 评论 -
LeetCode 173. Binary Search Tree Iterator
LeetCode 173. Binary Search Tree Iterator 问题来源LeetCode 173. Binary Search Tree Iterator问题描述 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root n原创 2017-12-06 20:56:52 · 300 阅读 · 0 评论 -
LeetCode174. Dungeon Game
LeetCode174. Dungeon Game 问题来源LeetCode174 Dungeon Game问题描述 The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms原创 2017-12-06 20:30:36 · 291 阅读 · 0 评论 -
LeetCode 187. Repeated DNA Sequences
LeetCode 187. Repeated DNA Sequences 问题来源LeetCode187 Repeated DNA Sequences问题描述 All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: “ACGAATTCCG”. When studyi原创 2017-12-06 20:20:27 · 377 阅读 · 0 评论 -
LeetCode198 House Robber
LeetCode198 House Robber 问题来源LeetCode198问题描述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you原创 2017-11-26 22:53:21 · 214 阅读 · 0 评论 -
LeetCode199 Binary Tree Right Side View
LeetCode199 Binary Tree Right Side View 问题来源LeetCode199问题描述 Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to b原创 2017-11-26 22:26:48 · 228 阅读 · 0 评论 -
LeetCode200 Number of Islands
LeetCode200 Number of Islands 问题来源 LeetCode200问题描述 Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting ad原创 2017-11-26 22:01:15 · 155 阅读 · 0 评论 -
LeetCode212. Word Search II
>Given a 2D board and a list of words from the dictionary, find all words in the board.>Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally原创 2017-12-12 19:08:07 · 430 阅读 · 0 评论 -
LeetCode211. Add and Search Word - Data structure design
>Design a data structure that supports the following two operations:>```void addWord(word)bool search(word)>```>search(word) can search a literal word or a regular expression string containing only letters原创 2017-12-12 16:49:49 · 393 阅读 · 0 评论 -
LeetCode 210 Course Schedule II
There are a total of n courses you have to take, labeled from 0 to n - 1.>Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: `[0,1原创 2017-12-12 16:43:39 · 323 阅读 · 0 评论 -
LeetCode85 Maximal Rectangle
LeetCode85 Maximal Rectangle问题来源 LeetCode85问题描述 Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s and return its area. For example, given the follo原创 2017-10-15 21:40:19 · 227 阅读 · 0 评论 -
LeetCode84 Largest Rectangle in Histogram
LeetCode84 Largest Rectangle in Histogram问题链接 LeetCode84问题描述 Given n non-negative integers representing the histogram’s bar height where the width of each bar is 1, find the area of largest rectangle原创 2017-10-15 21:29:50 · 254 阅读 · 0 评论 -
LeetCode57 Insert Interval
Insert Interval问题描述 Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according原创 2017-10-08 20:14:01 · 345 阅读 · 0 评论 -
LeetCode50_Pow(x,n)
Pow(x, n)问题描述 Implement pow(x, n).简单分析这道题的问题描述十分简单,就是自己实现一下pow(x,n)这个函数。对于幂函数,循环乘法是最简单的做法,但是效率太低了,那么有什么简单的做法吗?根据一个基本定理 n看成是以2为基的位构成的,因此每一位是对应x的一个幂数,然后迭代直到n到最高位。比如说第一位对应x,第二位对应x*x,第三位对应x^4,…,第k位对应x^原创 2017-09-25 19:04:50 · 167 阅读 · 0 评论