
LeetCode
a921122
这个作者很懒,什么都没留下…
展开
-
[LeetCode] 419. Battleships in a Board 解题报告
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with'.'s. You may assume the following rules:You receive a valid b原创 2017-02-16 11:49:07 · 585 阅读 · 0 评论 -
[LeetCode]414. Third Maximum Number 解题报告
Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).Example 1:Input: [3, 2,原创 2017-02-13 06:37:03 · 497 阅读 · 0 评论 -
[LeetCode] 415. Add Strings 解题报告
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both num1 and num2 is Both num1 and num2 contains only digits 0-9.原创 2017-02-13 08:08:42 · 346 阅读 · 0 评论 -
[LeetCode] 417. Pacific Atlantic Water Flow 解题报告
Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top edges of the matrix and the "Atlantic ocean" tou原创 2017-02-15 02:11:29 · 1232 阅读 · 0 评论 -
[LeetCode] 416. Partition Equal Subset Sum 解题报告
Given a non-empty array containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.Note:Each of the array原创 2017-02-14 09:19:25 · 2039 阅读 · 0 评论 -
[LeetCode] 435. Non-overlapping Intervals 解题报告
Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.Note:You may assume the interval's end point is alw原创 2017-02-24 07:17:13 · 831 阅读 · 0 评论 -
[LeetCoee] 436. Find Right Interval 解题报告
Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is on原创 2017-02-25 04:20:58 · 537 阅读 · 0 评论 -
[LeetCode] 442. Find All Duplicates in an Array 解题报告
Given an array of integers, 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements that appear twice in this array.Could you do it without ex原创 2017-02-26 03:10:18 · 416 阅读 · 0 评论 -
[LeetCode] 269. Alien Dictionary 解题报告
There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receive a list ofnon-empty words from the dictionary, where words are sorted lex原创 2017-03-05 02:30:56 · 2602 阅读 · 0 评论 -
[LeetCode] 451. Sort Characters By Frequency 解题报告
Given a string, sort it in decreasing order based on the frequency of characters.Example 1:Input:"tree"Output:"eert"Explanation:'e' appears twice while 'r' and 't' both appear once.So 'e原创 2017-03-07 07:02:14 · 486 阅读 · 0 评论 -
[LeetCode] 452. Minimum Number of Arrows to Burst Balloons 解题报告
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordin原创 2017-03-11 10:58:38 · 815 阅读 · 0 评论 -
[LeetCode] 467. Unique Substrings in Wraparound String 解题报告
Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".Now we ha原创 2017-04-03 05:17:24 · 795 阅读 · 0 评论 -
[LeetCode] 463. Island Perimeter 解题报告
You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely原创 2017-02-21 02:45:27 · 490 阅读 · 0 评论 -
[LeetCode]413. Arithmetic Slices 解题报告
A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.For example, these are arithmetic sequenc原创 2017-02-12 00:27:22 · 513 阅读 · 0 评论 -
[LeetCode] 423. Reconstruct Original Digits from English 解题报告
Given a non-empty string containing an out-of-order English representation of digits 0-9, output the digits in ascending order.Note:Input contains only lowercase English letters.Input is g原创 2017-02-17 05:09:24 · 384 阅读 · 0 评论 -
[LeetCode] 424. Longest Repeating Character Replacement 解题报告
Given a string that consists of only uppercase English letters, you can replace any letter in the string with another letter at most k times. Find the length of a longest substring containing all re原创 2017-02-17 10:15:19 · 1781 阅读 · 0 评论 -
[LeetCode] 482. License Key Formatting 解题报告
Now you are given a string S, which represents a software license key which we would like to format. The string S is composed of alphanumerical characters and dashes. The dashes split the alphanumeric原创 2017-02-17 12:31:43 · 2248 阅读 · 0 评论 -
[LeetCode] 394. Decode String 解题报告
Given an encoded string, return it's decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note thatk is原创 2017-02-18 06:56:04 · 610 阅读 · 0 评论 -
[LeetCode]406. Queue Reconstruction by Height 解题报告
Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is the number of people in front of t原创 2017-02-11 00:22:03 · 426 阅读 · 0 评论 -
[LeetCode] 279. Perfect Squares 解题报告
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n.For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n =原创 2017-02-19 03:04:32 · 898 阅读 · 0 评论 -
[LeetCode] 274. H-Index 解题报告
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index.According to the definition of h-index on Wikipedia: "A原创 2017-02-20 00:47:26 · 1060 阅读 · 0 评论 -
[LeetCode] 447. Number of Boomerangs 解题报告
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between iand j equals the distance between i and k (the order of t原创 2017-03-01 05:04:21 · 576 阅读 · 0 评论 -
[LeetCode]409. Longest Palindrome 解题报告
Given a string which consists of lowercase or uppercase letters, find the length of the longest palindromes that can be built with those letters.This is case sensitive, for example "Aa" is not con原创 2017-02-11 07:56:40 · 449 阅读 · 0 评论 -
[LeetCode] 412. Fizz Buzz 解题报告
Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”.原创 2017-02-11 12:50:55 · 493 阅读 · 0 评论 -
[LeetCode] 501. Find Mode in Binary Search Tree 解题报告
Given a binary search tree (BST) with duplicates, find all the mode(s) (the most frequently occurred element) in the given BST.Assume a BST is defined as follows:The left subtree of a node c原创 2017-04-28 05:41:56 · 3451 阅读 · 2 评论