LeetCode
文章平均质量分 61
想当厨子的程序媛
前期追深度,否则会华而不实,后期追广度,否则会坐井观天;
展开
-
LeetCode——118. Pascal's Triangle
题目原址https://leetcode.com/problems/pascals-triangle/description/题目描述Given numRows, generate the first numRows of Pascal’s triangle. For example, given numRows = 5, Return 解题思路帕斯卡三角(杨辉三...原创 2018-02-08 20:44:55 · 231 阅读 · 0 评论 -
Leetcode——643. Maximum Average Subarray I
题目原址https://leetcode.com/problems/maximum-average-subarray-i/description/题目描述Given an array consisting of n integers, find the contiguous subarray of given length k that has the maximum averag...原创 2018-02-08 21:17:21 · 204 阅读 · 0 评论 -
Leetcode——532. K-diff Pairs in an Array
题目原址https://leetcode.com/problems/k-diff-pairs-in-an-array/description/题目描述Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a ...原创 2018-02-09 10:56:59 · 237 阅读 · 0 评论 -
Leetcode——350. Intersection of Two Arrays II
题目原址https://leetcode.com/problems/intersection-of-two-arrays-ii/description/题目描述Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], num...原创 2018-02-09 20:41:52 · 159 阅读 · 0 评论 -
Leetcode——349. Intersection of Two Arrays
题目原址https://leetcode.com/problems/intersection-of-two-arrays/description/题目描述Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = ...原创 2018-02-09 21:09:17 · 152 阅读 · 0 评论 -
Leetcode——58. Length of Last Word
题目难度easy题目描述解题思路给定一个字符串s由大/小写字母和空格字符组成,返回字符串中最后一个单词的长度。如果最后一个词不存在,返回0。 注意:一个词是指由非空格字符组成的字符序列。该题的难度为easy,我觉得题目考察的主要是一些临界情况的判断。LeetCode的很多题都是在考察边界情况的判断。在这里有3个临界情况需要考虑 ” ” 字符串中都是空格原创 2018-02-06 19:48:00 · 195 阅读 · 0 评论 -
Leetcode——147. Insertion Sort List
题目描述 Sort a linked list using insertion sort. (升序)解题思路: 对于未排序的数据,在已经排序的数据中从前向后扫描,找到相应的位置并插入对应的元素。 用一个当前活动指针向后遍历第一个节点有可能被修改,因此要使用dummy。其下一个节点指向头结点,返回时返回dummy.next。当p的值不大于下一个节点的值时,就向下遍历:p原创 2018-01-30 21:35:45 · 165 阅读 · 0 评论 -
Leetcode——303.Range Sum Query - Immutable
题目难度easy题目描述解题思路给一个整形数组,返回下标从i到j的元素的和。 该题主要考察时间复杂度,题目本身的难度很低,要求使用尽可能少的时间来处理这个问题。解题思路 (1) 更改元素存储的值的信息:后一个元素存储前面所有元素的和(包含自己)。(2) 如果想要得到第i到第j个元素的和,只需要返回nums[j] - nums[i-1]即可。(3) 在第(2)步时原创 2018-02-06 20:23:31 · 215 阅读 · 0 评论 -
Leetcode——665. Non-decreasing Array
题目原址https://leetcode.com/problems/non-decreasing-array/description/题目难度easy题目TagArray题目描述Given an array with n integers, your task is to check if it could become non-decreasing by mo原创 2018-02-06 21:04:55 · 244 阅读 · 0 评论 -
Leetcode——448. Find All Numbers Disappeared in an Array
题目原址https://leetcode.com/problems/find-all-numbers-disappeared-in-an-array/description/题目描述Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and other原创 2018-02-06 21:55:37 · 238 阅读 · 0 评论 -
Leetcode——198. House Robber
题目原址https://leetcode.com/problems/house-robber/description/题目描述 You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the onl原创 2018-02-07 11:46:08 · 266 阅读 · 0 评论 -
Leetcode——697. Degree of an Array
题目原址https://leetcode.com/problems/degree-of-an-array/description/题目描述Example1: Input: [1, 2, 2, 3, 1] Output: 2 Explanation: The input array has a degree of 2 because both elements原创 2018-02-07 13:11:47 · 271 阅读 · 0 评论 -
Leetcode—— 283 141 628. Maximum Product of Three Numbers
题目原址https://leetcode.com/problems/maximum-product-of-three-numbers/description/题目描述Given an integer array, find three numbers whose product is maximum and output the maximum product.Example原创 2018-02-07 13:44:56 · 150 阅读 · 0 评论 -
Leetcode——268. Missing Number
题目原址https://leetcode.com/problems/missing-number/description/题目描述Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.Example1原创 2018-02-07 14:24:01 · 211 阅读 · 0 评论 -
Leetcode——121. Best Time to Buy and Sell Stock
题目原址https://leetcode.com/problems/best-time-to-buy-and-sell-stock/description/题目描述Say you have an array for which the ith element is the price of a given stock on day i. If you were only perm原创 2018-02-07 15:17:28 · 227 阅读 · 0 评论 -
Leetcode——724. Find Pivot Index
题目原址https://leetcode.com/problems/find-pivot-index/description/题目描述Given an array of integers nums, write a method that returns the “pivot” index of this array. We define the pivot index as th原创 2018-02-07 15:49:10 · 282 阅读 · 0 评论 -
Leetcode—— 28. Implement strStr()
年后第一题,身体是革命的本钱,过年没把身体照顾好,导致好多天不能学习。>_<题目原址https://leetcode.com/problems/implement-strstr/description/题目描述Implement strStr(). Return the index of the first occurrence of needle in...原创 2018-02-25 14:13:31 · 187 阅读 · 0 评论 -
Leetcode——557. Reverse Words in a String III
题目原址https://leetcode.com/problems/reverse-words-in-a-string-iii/description/题目描述Given a string, you need to reverse the order of characters in each word within a sentence while still preserving ...原创 2018-02-25 15:42:09 · 253 阅读 · 0 评论 -
Leetcode——521. Longest Uncommon Subsequence I
题目原址https://leetcode.com/problems/longest-uncommon-subsequence-i/description/题目描述Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The...原创 2018-03-23 10:29:35 · 173 阅读 · 0 评论 -
Leetcode——788. Rotated Digits
题目原址https://leetcode.com/problems/rotated-digits/description/题目描述X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Eac...原创 2018-03-23 11:26:49 · 793 阅读 · 0 评论 -
Leetcode——696. Count Binary Substrings
题目原址https://leetcode.com/problems/count-binary-substrings/description/题目描述Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all...原创 2018-03-23 12:02:21 · 339 阅读 · 0 评论 -
LeetCode—— 13. Roman to Integer
题目原址https://leetcode.com/problems/roman-to-integer/description/题目描述Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.解题思路罗马数字一共有7个字母...原创 2018-03-23 13:12:47 · 173 阅读 · 0 评论 -
Leetcode——383. Ransom Note
题目原址https://leetcode.com/problems/ransom-note/description/题目描述Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will retur...原创 2018-03-23 13:40:34 · 222 阅读 · 0 评论 -
Leetcode——387. First Unique Character in a String
题目原址https://leetcode.com/problems/first-unique-character-in-a-string/description/题目描述Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, retu...原创 2018-03-23 14:22:54 · 177 阅读 · 0 评论 -
Leetcode——520. Detect Capital
题目原址https://leetcode.com/problems/detect-capital/description/题目描述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 wor...原创 2018-03-23 10:40:39 · 174 阅读 · 0 评论 -
Leetcode——459. Repeated Substring Pattern
题目原址https://leetcode.com/problems/repeated-substring-pattern/description/题目描述Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of ...原创 2018-03-24 17:50:50 · 141 阅读 · 0 评论 -
Leetcode——434. Number of Segments in a String
题目原址https://leetcode.com/problems/number-of-segments-in-a-string/description/题目描述Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space cha...原创 2018-03-24 18:54:32 · 179 阅读 · 0 评论 -
Leetcode——38. Count and Say
题目原址https://leetcode.com/problems/count-and-say/description/题目描述The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221...原创 2018-03-24 19:35:14 · 193 阅读 · 0 评论 -
Leetcode——565. Array Nesting
题目原址https://leetcode.com/problems/array-nesting/description/题目描述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] ...原创 2018-05-09 10:12:24 · 233 阅读 · 0 评论 -
Leetcode——443. String Compression
题目原址https://leetcode.com/problems/string-compression/description/题目描述Given an array of characters, compress it in-place.The length after compression must always be smaller than or equal to t...原创 2018-04-24 16:58:21 · 851 阅读 · 0 评论 -
Leetcode——67. Add Binary
题目原址https://leetcode.com/problems/add-binary/description/题目描述Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters...原创 2018-04-24 19:35:22 · 146 阅读 · 0 评论 -
Leetcode——686. Repeated String Match
题目原址https://leetcode.com/problems/repeated-string-match/description/题目描述Given two strings A and B, find the minimum number of times A has to be repeated such that B is a substring of it. If no...原创 2018-04-24 20:37:44 · 206 阅读 · 0 评论 -
Leetcode——680. Valid Palindrome II
题目原址https://leetcode.com/problems/valid-palindrome-ii/description/题目描述Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.Example1: ...原创 2018-04-24 21:24:52 · 279 阅读 · 0 评论 -
Leetcode——551. Student Attendance Record I
题目原址https://leetcode.com/problems/student-attendance-record-i/description/题目描述You are given a string representing an attendance record for a student. The record only contains the following three...原创 2018-04-24 21:45:00 · 147 阅读 · 0 评论 -
Leetcode——769. Max Chunks To Make Sorted
题目原址https://leetcode.com/problems/max-chunks-to-make-sorted/description/题目描述Given an array arr that is a permutation of [0, 1, ..., arr.length - 1], we split the array into some number of “chu...原创 2018-05-09 13:44:17 · 163 阅读 · 0 评论 -
Leetcode——728. Self Dividing Numbers
题目原址https://leetcode.com/problems/self-dividing-numbers/description/题目描述A self-dividing number is a number that is divisible by every digit it contains.For example, 128 is a self-dividing nu...原创 2018-04-25 16:57:39 · 129 阅读 · 0 评论 -
Leetcode——258. Add Digits
题目原址https://leetcode.com/problems/add-digits/description/题目描述Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38,...原创 2018-04-25 18:39:11 · 131 阅读 · 0 评论 -
Leetcode——171. Excel Sheet Column Number
题目原址https://leetcode.com/problems/excel-sheet-column-number/description/题目描述Given a column title as appear in an Excel sheet, return its corresponding column number.For example: A -> 1 ...原创 2018-04-25 19:03:42 · 181 阅读 · 0 评论 -
Leetcode——598. Range Addition II
题目原址https://leetcode.com/problems/range-addition-ii/description/题目描述Given an m * n matrix M initialized with all 0’s and several update operations.Operations are represented by a 2D array, a...原创 2018-04-25 19:43:04 · 170 阅读 · 0 评论 -
Leetcode——415. Add Strings
题目原址https://leetcode.com/problems/add-strings/description/题目描述Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.Note:The length of both ...原创 2018-04-25 20:19:22 · 180 阅读 · 0 评论