LeetCode
文章平均质量分 59
繁城落叶
这个作者很懒,什么都没留下…
展开
-
167. Two Sum II - Input array is sorted。
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers suc原创 2018-01-06 20:45:58 · 474 阅读 · 0 评论 -
661. Image Smoother。
Given a 2D integer matrix M representing the gray scale of an image, you need to design a smoother to make the gray scale of each cell becomes the average gray scale (rounding down) of all the 8 surrou原创 2018-01-27 23:43:02 · 500 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock。
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), desi原创 2018-02-09 23:12:44 · 358 阅读 · 0 评论 -
714. Best Time to Buy and Sell Stock with Transaction Fee。
Your are given an array of integers prices, for which the i-th element is the price of a given stock on day i; and a non-negative integer fee representing a transaction fee.You may complete as many tra原创 2018-02-12 22:50:26 · 771 阅读 · 0 评论 -
769. Max Chunks To Make Sorted。
Given an array arr that is a permutation of [0, 1, …, arr.length - 1], we split the array into some number of “chunks” (partitions), and individually sort each chunk. After concatenating them, the re...原创 2018-02-14 12:06:43 · 584 阅读 · 0 评论 -
216. Combination Sum III。
Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used and each combination should be a unique set of numbers.Example 1: Input: k ...原创 2018-02-20 14:34:55 · 380 阅读 · 0 评论 -
771. Jewels and Stones。
You’re given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the ston原创 2018-02-20 17:08:15 · 598 阅读 · 0 评论 -
500. Keyboard Row。
Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American keyboard like the image below.Example 1: Input: [“Hello”, “Alaska”, “Dad”, “Peace”]原创 2018-02-20 22:05:45 · 487 阅读 · 0 评论 -
575. Distribute Candies。
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these原创 2018-02-21 10:14:20 · 434 阅读 · 0 评论 -
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 s原创 2018-02-21 13:02:51 · 340 阅读 · 0 评论 -
122. Best Time to Buy and Sell Stock II。
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and原创 2018-01-26 23:20:32 · 466 阅读 · 0 评论 -
565. Array Nesting。
A zero-indexed array A of length N contains all integers from 0 to N-1. Find and return the longest length of set S, where S[i] = {A[i], A[A[i]], A[A[A[i]]], … } subjected to the rule below.Suppose the原创 2018-01-10 15:35:53 · 411 阅读 · 0 评论 -
LeetCode目录。
本目录只会在一个Tag完成之后更新,实时更新目录:https://github.com/jiajia0/LeetCode。按照LeetCode的Tags来区分的话,目前共有34个Tag,只列出已经解决的题,各分类中按照题目编号排序:Linked List。Solved:21/28 # Title Difficulty 2 Add Two Numbe原创 2017-11-21 18:41:33 · 595 阅读 · 0 评论 -
217. Contains Duplicate。
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every element is原创 2018-01-07 20:35:17 · 351 阅读 · 0 评论 -
747. Largest Number At Least Twice of Others。
In a given integer array nums, there is always exactly one largest element.Find whether the largest element in the array is at least twice as much as every other number in the array.If it is, return th原创 2018-01-07 21:12:12 · 1264 阅读 · 0 评论 -
766. Toeplitz Matrix。
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.Example 1: Input: matrix = [[1,2原创 2018-01-25 00:06:21 · 1101 阅读 · 0 评论 -
628. Maximum Product of Three Numbers。
Given an integer array, find three numbers whose product is maximum and output the maximum product.Example 1: Input: [1,2,3] Output: 6Example 2: Input: [1,2,3,4] Output: 24给定一个数组,找出三个数产生的乘积原创 2018-01-08 20:11:59 · 434 阅读 · 0 评论 -
268. Missing Number。
Given an array containing n distinct numbers taken from 0, 1, 2, …, n, find the one that is missing from the array.Example 1 Input: [3,0,1] Output: 2Example 2 Input: [9,6,4,2,3,5,7,0,1] Outp原创 2018-01-08 21:16:20 · 442 阅读 · 0 评论 -
674. Longest Continuous Increasing Subsequence。
Given an unsorted array of integers, find the length of longest continuous increasing subsequence (subarray).Example 1: Input: [1,3,5,4,7] Output: 3 Explanation: The longest continuous increasi原创 2018-01-09 20:30:17 · 501 阅读 · 0 评论 -
717. 1-bit and 2-bit Characters。
We have two special characters. The first character can be represented by one bit 0. The second character can be represented by two bits (10 or 11).Now given a string represented by several bits. Re原创 2017-12-09 16:50:08 · 917 阅读 · 0 评论 -
287. Find the Duplicate Number。
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, fin原创 2018-01-26 00:07:04 · 506 阅读 · 0 评论 -
136. Single Number。
Given an array of integers, every element appears twice except for one. Find that single one.原文:https://leetcode.com/problems/single-number/description/在一写数字中,有一个数字只出现了一次,其余的都出现了两次,找出出现一次的数字。首先可以利用额外的辅原创 2018-02-21 20:33:48 · 375 阅读 · 0 评论 -
739. Daily Temperatures。
Given a list of daily temperatures, produce a list that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this i原创 2018-02-22 23:16:08 · 926 阅读 · 0 评论 -
888. Fair Candy Swap。
Alice and Bob have candy bars of different sizes: A[i] is the size of the i-th bar of candy that Alice has, and B[j] is the size of the j-th bar of candy that Bob has.Since they are friends, they wo...原创 2019-01-04 22:33:48 · 367 阅读 · 0 评论 -
830. Positions of Large Groups。
In a string S of lowercase letters, these letters form consecutive groups of the same character.For example, a string like S = “abbxxxxzyy” has the groups “a”, “bb”, “xxxx”, “z” and “yy”.Call a gro...原创 2019-01-05 16:31:41 · 353 阅读 · 0 评论 -
66. Plus One。
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element...原创 2019-01-10 21:00:43 · 332 阅读 · 0 评论 -
832. Flipping an Image。
Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.To flip an image horizontally means that each row of the image is reversed. For examp...原创 2019-01-01 17:57:38 · 304 阅读 · 0 评论 -
846. Hand of Straights。
Alice has a hand of cards, given as an array of integers.Now she wants to rearrange the cards into groups so that each group is size W, and consists of W consecutive cards.Return true if and only i...原创 2019-01-06 23:59:30 · 357 阅读 · 0 评论 -
922. Sort Array By Parity II。
Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even.Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is...原创 2019-01-02 20:32:25 · 357 阅读 · 0 评论 -
1051. Height Checker。
Students are asked to stand in non-decreasing order of heights for an annual photo.Return the minimum number of students not standing in the right positions. (This is the number of students that mus...原创 2019-06-12 14:21:46 · 514 阅读 · 0 评论 -
977. Squares of a Sorted Array。
Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order.Example 1:Input: [-4,-1,0,3,10]Output: [0,1,9,16,1...原创 2019-06-07 11:35:47 · 261 阅读 · 0 评论 -
709. To Lower Case。
Implement function ToLowerCase() that has a string parameter str, and returns the same string in lowercase.原文链接:https://leetcode.com/problems/to-lower-case/水。。。class Solution {public: string ...原创 2019-06-12 11:17:39 · 395 阅读 · 0 评论 -
905. Sort Array By Parity。
Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A.You may return any answer array that satisfies this conditio...原创 2018-12-30 21:42:43 · 335 阅读 · 0 评论 -
896. Monotonic Array。
An array is monotonic if it is either monotone increasing or monotone decreasing.An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for al...原创 2019-01-03 21:21:17 · 329 阅读 · 0 评论 -
748. Shortest Completing Word。
Find the minimum length word from a given dictionary words, which has all the letters from the string licensePlate. Such a word is said to complete the given string licensePlateHere, for letters we ign原创 2018-02-23 00:02:41 · 687 阅读 · 0 评论 -
347. Top K Frequent Elements。
Given a non-empty array of integers, return the k most frequent elements.For example, Given [1,1,1,2,2,3] and k = 2, return [1,2].原文:https://leetcode.com/problems/top-k-frequent-elements/description/题原创 2018-03-11 23:09:13 · 335 阅读 · 0 评论 -
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 appea原创 2018-02-25 19:18:56 · 371 阅读 · 0 评论 -
389. Find the Difference。
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in原创 2018-02-25 19:45:27 · 344 阅读 · 0 评论 -
804. Unique Morse Code Words。
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: “a” maps to “.-“, “b” maps to “-…”, “c” maps to “-.-.”, and so on.For con...原创 2018-04-30 14:45:35 · 571 阅读 · 0 评论 -
728. Self Dividing Numbers。
A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.Also, a self-dividin...原创 2018-06-30 17:23:19 · 410 阅读 · 0 评论