随笔分类 -  weird problems

556. Next Greater Element III
摘要:Given a positive 32-bit integer n, you need to find the smallest 32-bit integer which has exactly the same digits existing in the integer n and is greater in value than n. If no such positive 32-bit ... 阅读全文

posted @ 2018-11-09 10:33 猪猪🐷

147. Insertion Sort List
摘要:Sort a linked list using insertion sort. A graphical example of insertion sort. The partial sorted list (black) initially contains only the first elem 阅读全文

posted @ 2018-11-09 07:30 猪猪🐷

204. Count Primes
摘要:还记得里扣而令四,一点点变化,要打印出来。 Count the number of prime numbers less than a non-negative number, n. Example: Input: 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. ... 阅读全文

posted @ 2018-11-09 07:02 猪猪🐷

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 individuall 阅读全文

posted @ 2018-11-09 06:52 猪猪🐷

166. Fraction to Recurring Decimal
摘要:Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating 阅读全文

posted @ 2018-11-08 17:05 猪猪🐷

41. First Missing Positive
摘要:Given an unsorted integer array, find the smallest missing positive integer. Example 1: Input: [1,2,0] Output: 3 Example 2: Input: [3,4,-1,1] Output: 阅读全文

posted @ 2018-11-08 16:56 猪猪🐷

68. Text Justification
摘要:it teaches you in the real world. Programmers are always been ask to deal with dirty works. Besides detail-oriented mindset, I think this question als 阅读全文

posted @ 2018-11-08 16:54 猪猪🐷

134. Gas Station
摘要:There are N gas stations along a circular route, where the amount of gas at station i is gas[i]. You have a car with an unlimited gas tank and it cost 阅读全文

posted @ 2018-11-08 16:53 猪猪🐷

370 Range Addition
摘要:Assume you have an array of length n initialized with all 0's and are given k update operations. Each operation is represented as a triplet: [startIndex, endIndex, inc] which increments each element ... 阅读全文

posted @ 2018-11-08 16:41 猪猪🐷

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 i and j equals the distance between i and k (the order of the t... 阅读全文

posted @ 2018-11-08 16:37 猪猪🐷

659. Split Array into Consecutive Subsequences
摘要:659. Split Array into Consecutive Subsequences 阅读全文

posted @ 2018-11-08 16:32 猪猪🐷

475. Heaters
摘要:java.util.Arrays.binarySearch() method public static int binarySearch(int[] a, int key) Parameters * a − This is the array to be searched. * key − This is the value to be searched for. This method... 阅读全文

posted @ 2018-11-08 16:26 猪猪🐷

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 猪猪🐷

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 猪猪🐷

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 猪猪🐷

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

posted @ 2018-11-08 16:07 猪猪🐷

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 猪猪🐷

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 猪猪🐷

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 猪猪🐷

683. K Empty Slots
摘要:There is a garden with N slots. In each slot, there is a flower. The N flowers will bloom one by one in N days. In each day, there will be exactly one flower blooming and it will be in the status of ... 阅读全文

posted @ 2018-11-08 02:08 猪猪🐷

导航