![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
基础
文章平均质量分 78
LQCUN
这个作者很懒,什么都没留下…
展开
-
392. Is Subsequence
Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, a...原创 2018-03-28 11:00:59 · 94 阅读 · 0 评论 -
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 su...原创 2018-02-17 19:45:31 · 75 阅读 · 0 评论 -
455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a coo...原创 2018-02-17 19:36:36 · 156 阅读 · 0 评论 -
387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1.Examples:s = "leetcode"return 0.s = "loveleetcode",return 2.Note: You may assume...原创 2018-02-17 19:25:38 · 86 阅读 · 0 评论 -
242. Valid Anagram
Given two strings s and t, write a function to determine if t is an anagram of s. For example,s = "anagram", t = "nagaram", return true.s = "rat", t = "car", return false.Note:You may assume the strin...原创 2018-02-17 19:11:43 · 106 阅读 · 0 评论 -
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 solution = new Solution(nums);// Shuffle the array [1,2,3] and return its re...原创 2018-02-17 17:09:05 · 151 阅读 · 0 评论 -
404. Sum of Left Leaves
Find the sum of all left leaves in a given binary tree.Example: 3 / \ 9 20 / \ 15 7There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24.代码1:...原创 2018-02-17 16:20:52 · 89 阅读 · 0 评论 -
383. Ransom Note
Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazines ; ot...原创 2018-02-16 22:04:17 · 225 阅读 · 0 评论 -
454. 4Sum II
Given four lists A, B, C, D of integer values, compute how many tuples (i, j, k, l) there are such that A[i] + B[j] + C[k] + D[l] is zero.To make problem a bit easier, all A, B, C, D have same length ...原创 2018-02-16 21:56:00 · 240 阅读 · 0 评论 -
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.You may assume that the array is non-empty and the majority element always...原创 2018-02-16 17:09:05 · 76 阅读 · 0 评论 -
733. Flood Fill
An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pixel (row and column...原创 2018-02-16 15:51:22 · 148 阅读 · 0 评论 -
237. Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with ...原创 2018-02-18 23:44:35 · 73 阅读 · 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-02-19 10:30:56 · 73 阅读 · 0 评论 -
697. Degree of an Array
Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.Your task is to find the smallest possible length of a (c...原创 2018-02-19 10:42:37 · 194 阅读 · 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: 24Note:The length of the given...原创 2018-03-28 10:47:24 · 154 阅读 · 0 评论 -
398. Random Pick Index
Given an array of integers with possible duplicates, randomly output the index of a given target number. You can assume that the given target number must exist in the array.Note:The array size can be ...原创 2018-02-22 15:38:22 · 99 阅读 · 0 评论 -
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 guaranteed to...原创 2018-02-22 15:17:43 · 103 阅读 · 0 评论 -
392. Is Subsequence
Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, a...原创 2018-02-22 15:00:45 · 121 阅读 · 0 评论 -
744. 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 in the list that is larger than the given target.Letters also w...原创 2018-02-22 14:44:26 · 119 阅读 · 0 评论 -
378. Kth Smallest Element in a Sorted Matrix
Given a n x n matrix where each of the rows and columns are sorted in ascending order, find the kth smallest element in the matrix.Note that it is the kth smallest element in the sorted order, not the...原创 2018-02-22 13:59:41 · 104 阅读 · 0 评论 -
481. Magical String
A magical string S consists of only '1' and '2' and obeys the following rules:The string S is magical because concatenating the number of contiguous occurrences of characters '1' and '2' generates the...原创 2018-02-22 13:23:53 · 105 阅读 · 0 评论 -
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 conside...原创 2018-02-22 13:07:54 · 85 阅读 · 0 评论 -
539. Minimum Time Difference
Given a list of 24-hour clock time points in "Hour:Minutes" format, find the minimum minutes difference between any two time points in the list. Example 1:Input: ["23:59","00:00"]Output: 1Note:The n...原创 2018-02-21 23:56:47 · 166 阅读 · 0 评论 -
554. Brick Wall
There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but different width. You want to draw a vertical line from the top to the...原创 2018-02-20 12:40:41 · 116 阅读 · 0 评论 -
349. Intersection of Two Arrays
Given two arrays, write a function to compute their intersection.Example:Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2].Note:Each element in the result must be unique.The result can be in any ...原创 2018-02-16 15:23:51 · 77 阅读 · 0 评论 -
492. Construct the Rectangle
For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L...原创 2018-02-16 13:30:36 · 90 阅读 · 0 评论 -
690. Employee Importance
You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id. For example, employee 1 is the leader of employee...原创 2018-02-11 11:34:19 · 94 阅读 · 0 评论 -
520. Detect Capital
Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word...原创 2018-02-10 19:50:32 · 84 阅读 · 0 评论 -
677. Map Sum Pairs
Implement a MapSum class with insert, and sum methods.For the method insert, you'll be given a pair of (string, integer). The string represents the key and the integer represents the value. If the key...原创 2018-02-10 19:35:34 · 106 阅读 · 0 评论 -
682. Baseball Game
You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:Integer (one round's score): Directly represents the number of points you get i原创 2018-02-05 14:23:14 · 96 阅读 · 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原创 2018-02-05 13:08:21 · 78 阅读 · 0 评论 -
344. Reverse String
Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh".思路:交换代码1:class Solution {public: string reverseString(string s) {原创 2018-02-05 11:57:01 · 95 阅读 · 0 评论 -
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原创 2018-02-04 17:21:02 · 94 阅读 · 0 评论 -
485. Max Consecutive Ones
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. ...原创 2018-02-09 10:50:35 · 91 阅读 · 0 评论 -
561. Array Partition I
Given an array of 2n integers, your task is to group these integers inton pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as pos原创 2018-02-04 11:50:49 · 66 阅读 · 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-divid原创 2018-02-04 11:17:27 · 89 阅读 · 0 评论 -
695. Max Area of Island
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surro...原创 2018-02-11 12:15:17 · 114 阅读 · 0 评论 -
283. Move Zeroes
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your fun...原创 2018-02-11 15:03:36 · 79 阅读 · 0 评论 -
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”.原创 2018-02-06 11:10:47 · 27767 阅读 · 0 评论 -
171. Excel Sheet Column Number
Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 B -> 2 C -> 3 ... Z...原创 2018-02-16 13:18:26 · 118 阅读 · 0 评论