上一页 1 2 3 4 5 6 7 8 ··· 15 下一页

2018年11月8日

528. Random Pick with Weight

摘要: Given an array w of positive integers, where w[i] describes the weight of index i, write a function pickIndex which randomly picks an index in proportion to its weight. Note: 1. 1 psum = new ArrayLi... 阅读全文

posted @ 2018-11-08 16:16 猪猪🐷 阅读(135) 评论(0) 推荐(0)

872. Leaf-Similar Trees

摘要: Consider all the leaves of a binary tree. From left to right order, the values of those leaves form a leaf value sequence. For example, in the given t 阅读全文

posted @ 2018-11-08 16:16 猪猪🐷 阅读(105) 评论(0) 推荐(0)

723. Candy Crush

摘要: This question is about implementing a basic elimination algorithm for Candy Crush. Given a 2D integer array board representing the grid of candy, diff 阅读全文

posted @ 2018-11-08 16:15 猪猪🐷 阅读(161) 评论(0) 推荐(0)

853. Car Fleet

摘要: https://leetcode.com/problems/car-fleet/solution/ https://leetcode.com/problems/car-fleet/discuss/139999/Easy-understanding-JAVA-TreeMap-Solution-with-explanation-and-comment N cars are going ... 阅读全文

posted @ 2018-11-08 16:13 猪猪🐷 阅读(200) 评论(0) 推荐(0)

724. Find Pivot Index

摘要: Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the index where the sum of 阅读全文

posted @ 2018-11-08 16:12 猪猪🐷 阅读(105) 评论(0) 推荐(0)

845. Longest Mountain in Array

摘要: 2,1,4,7,3,2,5 0 0 1 20 0 1 1 0 0 21 00 阅读全文

posted @ 2018-11-08 16:11 猪猪🐷 阅读(185) 评论(0) 推荐(0)

821. Shortest Distance to a Character

摘要: https://leetcode.com/problems/shortest-distance-to-a-character/solution/ // three pass, accepted class Solution { public int[] shortestToChar(String S, char C) { // left scan , upda... 阅读全文

posted @ 2018-11-08 16:10 猪猪🐷 阅读(106) 评论(0) 推荐(0)

836. Rectangle Overlap

摘要: A rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) are the coordinates of its bottom-left corner, and (x2, y2) are the coordinates 阅读全文

posted @ 2018-11-08 16:10 猪猪🐷 阅读(131) 评论(0) 推荐(0)

849. Maximize Distance to Closest Person

摘要: https://leetcode.com/problems/maximize-distance-to-closest-person/solution/ In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty. There is at lea... 阅读全文

posted @ 2018-11-08 16:09 猪猪🐷 阅读(112) 评论(0) 推荐(0)

767. Reorganize String

摘要: https://leetcode.com/problems/reorganize-string/solution/ http://www.cnblogs.com/grandyang/p/8799483.html Given a string S, check if the letters can b 阅读全文

posted @ 2018-11-08 16:07 猪猪🐷 阅读(91) 评论(0) 推荐(0)

769. Max Chunks To Make Sorted

摘要: 769. Max Chunks To Make Sorted 阅读全文

posted @ 2018-11-08 16:07 猪猪🐷 阅读(83) 评论(0) 推荐(0)

830. Positions of Large Groups

摘要: 830. Positions of Large Groups https://leetcode.com/problems/positions-of-large-groups/solution/ 阅读全文

posted @ 2018-11-08 16:06 猪猪🐷 阅读(76) 评论(0) 推荐(0)

900. RLE Iterator

摘要: 900. RLE Iterator https://leetcode.com/problems/rle-iterator/solution/ 阅读全文

posted @ 2018-11-08 16:04 猪猪🐷 阅读(111) 评论(0) 推荐(0)

272. Closest Binary Search Tree Value II

摘要: Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the target. Note: Given target value is a floati 阅读全文

posted @ 2018-11-08 16:03 猪猪🐷 阅读(160) 评论(0) 推荐(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 Wconsecutive cards. Return true if and only if... 阅读全文

posted @ 2018-11-08 16:02 猪猪🐷 阅读(123) 评论(0) 推荐(0)

165. Compare Version Numbers

摘要: Compare two version numbers version1 and version2.
If version1 > version2 return 1; if version1 version2.charAt(i) - '0'){ return 1; }else if(version1.charAt(i) - '0' ve... 阅读全文

posted @ 2018-11-08 16:00 猪猪🐷 阅读(111) 评论(0) 推荐(0)

344. Reverse String

摘要: Write a function that takes a string as input and returns the string reversed. Example 1: Input: "hello" Output: "olleh" Example 2: Input: "A man, a plan, a canal: Panama" Output: "amanaP :lanac a ,n... 阅读全文

posted @ 2018-11-08 15:59 猪猪🐷 阅读(88) 评论(0) 推荐(0)

151. Reverse Words in a String

摘要: Given an input string, reverse the string word by word. Example: Input: "the sky is blue", Output: "blue is sky the". Note: * A word is defined as a sequence of non-space characters. * Input string... 阅读全文

posted @ 2018-11-08 15:46 猪猪🐷 阅读(94) 评论(0) 推荐(0)

345. Reverse Vowels of a String

摘要: Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Input: "hello" Output: "holle" Example 2: Input: "leetcode" Output: "leotcede" // correct May use ... 阅读全文

posted @ 2018-11-08 15:46 猪猪🐷 阅读(122) 评论(0) 推荐(0)

557. Reverse Words in a String III

摘要: Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: "Let's take LeetCode contest" O... 阅读全文

posted @ 2018-11-08 15:45 猪猪🐷 阅读(98) 评论(0) 推荐(0)

186. Reverse Words in a String II

摘要: Given an input string , reverse the string word by word. Example: Input: ["t","h","e"," ","s","k","y"," ","i","s"," ","b","l","u","e"] Output: [" 阅读全文

posted @ 2018-11-08 15:45 猪猪🐷 阅读(67) 评论(0) 推荐(0)

28. Implement strStr()

摘要: Implement strStr(). Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1: Input: haystack = "hello", needle = "ll" Output: 2 Example 2: I... 阅读全文

posted @ 2018-11-08 15:44 猪猪🐷 阅读(120) 评论(0) 推荐(0)

752. Open the Lock

摘要: each time, can only change one of the four positions. And for each position, can only change either + 1 , or - 1 use "+ 10 mod 10" to guarentee a posi 阅读全文

posted @ 2018-11-08 15:44 猪猪🐷 阅读(110) 评论(0) 推荐(0)

205. Isomorphic Strings

摘要: Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another c... 阅读全文

posted @ 2018-11-08 15:43 猪猪🐷 阅读(97) 评论(0) 推荐(0)

422. Valid Word Square

摘要: Given a sequence of words, check whether it forms a valid word square. A sequence of words forms a valid word square if the kth row and column read the exact same string, where 0 ≤ k words) { ... 阅读全文

posted @ 2018-11-08 15:43 猪猪🐷 阅读(121) 评论(0) 推荐(0)

290. Word Pattern

摘要: Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str. Example... 阅读全文

posted @ 2018-11-08 15:40 猪猪🐷 阅读(124) 评论(0) 推荐(0)

443. String Compression

摘要: Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int)... 阅读全文

posted @ 2018-11-08 15:39 猪猪🐷 阅读(121) 评论(0) 推荐(0)

271. Encode and Decode Strings

摘要: Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings. Machine 1 (sender) has the function:... 阅读全文

posted @ 2018-11-08 15:37 猪猪🐷 阅读(156) 评论(0) 推荐(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 licensePlate Here, for letters we ... 阅读全文

posted @ 2018-11-08 02:34 猪猪🐷 阅读(171) 评论(0) 推荐(0)

791. Custom Sort String

摘要: Use char[] array S and T are strings composed of lowercase letters. In S, no letter occurs more than once. S was sorted in some custom order previously. We want to permute the characters of T so t... 阅读全文

posted @ 2018-11-08 02:34 猪猪🐷 阅读(142) 评论(0) 推荐(0)

527. Word Abbreviation

摘要: Given an array of n distinct non-empty strings, you need to generate minimal possible abbreviations for every word following rules below. 1. Begin with the first character and then the number of char... 阅读全文

posted @ 2018-11-08 02:32 猪猪🐷 阅读(187) 评论(0) 推荐(0)

32. Longest Valid Parentheses

摘要: Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: "(()" Output: 2 Explanation: The longest valid p... 阅读全文

posted @ 2018-11-08 02:31 猪猪🐷 阅读(126) 评论(0) 推荐(0)

143. Reorder List

摘要: Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes itself may be changed. Example 1: Given 1->2->3->4,... 阅读全文

posted @ 2018-11-08 02:28 猪猪🐷 阅读(131) 评论(0) 推荐(0)

148. Sort List

摘要: Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 https://www.youtub... 阅读全文

posted @ 2018-11-08 02:28 猪猪🐷 阅读(58) 评论(0) 推荐(0)

548. Split Array with Equal Sum

摘要: Given an array with n integers, you need to find if there are triplets (i, j, k) which satisfies following conditions: 1. 0 set = new HashSet(); // cut left , i for(int i = ... 阅读全文

posted @ 2018-11-08 02:26 猪猪🐷 阅读(112) 评论(0) 推荐(0)

304. Range Sum Query 2D - Immutable

摘要: Given a 2D matrix matrix, find the sum of the elements inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2 阅读全文

posted @ 2018-11-08 02:25 猪猪🐷 阅读(91) 评论(0) 推荐(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 as... 阅读全文

posted @ 2018-11-08 02:24 猪猪🐷 阅读(84) 评论(0) 推荐(0)

266. Palindrome Permutation

摘要: Given a string, determine if a permutation of the string could form a palindrome. Example 1: Input: "code" Output: false Example 2: Input: "aab" Output: true Example 3: Input: "carerac" Output: true ... 阅读全文

posted @ 2018-11-08 02:24 猪猪🐷 阅读(79) 评论(0) 推荐(0)

202. Happy Number

摘要: Write an algorithm to determine if a number is "happy". A happy number is a number defined by the following process: Starting with any positive integer, replace the number by the sum of the squares o... 阅读全文

posted @ 2018-11-08 02:23 猪猪🐷 阅读(124) 评论(0) 推荐(0)

249. Group Shifted Strings

摘要: https://www.geeksforgeeks.org/group-shifted-string/ Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the s... 阅读全文

posted @ 2018-11-08 02:22 猪猪🐷 阅读(101) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 7 8 ··· 15 下一页

导航