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

2018年11月9日

14. Longest Common Prefix

摘要: Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Input: ["flower","flow","flight"] Output:... 阅读全文

posted @ 2018-11-09 10:38 猪猪🐷 阅读(100) 评论(0) 推荐(0)

750. Number Of Corner Rectangles

摘要: Given a grid where each entry is only 0 or 1, find the number of corner rectangles. A corner rectangle is 4 distinct 1s on the grid that form an axis-aligned rectangle. Note that only the corners nee... 阅读全文

posted @ 2018-11-09 10:37 猪猪🐷 阅读(100) 评论(0) 推荐(0)

739. Daily Temperatures

摘要: Given a list of daily temperatures T, return a list such 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 whic... 阅读全文

posted @ 2018-11-09 10:36 猪猪🐷 阅读(89) 评论(0) 推荐(0)

105. Construct Binary Tree from Preorder and Inorder Traversal

摘要: Given preorder and inorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. For example, given preorder = [3,9,20,15,7] inorder = [9,3... 阅读全文

posted @ 2018-11-09 10:35 猪猪🐷 阅读(122) 评论(0) 推荐(0)

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 猪猪🐷 阅读(112) 评论(0) 推荐(0)

436. Find Right Interval

摘要: Given a set of intervals, for each of the interval i, check if there exists an interval j whose start point is bigger than or equal to the end point of the interval i, which can be called that j is o... 阅读全文

posted @ 2018-11-09 10:30 猪猪🐷 阅读(107) 评论(0) 推荐(1)

4. Median of Two Sorted Arrays

摘要: 这个题的解法就是在较短的 那个 array 上 做 binary search 如果 较短的 这半需要增长点, 那么使 left = mid , 如果 这段 需要短一点, 那么 right = mid 判断需要增长还是 变短 是根据 阅读全文

posted @ 2018-11-09 10:26 猪猪🐷 阅读(149) 评论(0) 推荐(0)

59. Spiral Matrix II

摘要: Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: Input: 3 Output: [ [ 1, 2, 3 ], [ 8, 9, 4 ], [ 7, 6, 5 ] ] 59. Spiral Matrix II ... 阅读全文

posted @ 2018-11-09 10:22 猪猪🐷 阅读(113) 评论(0) 推荐(0)

119. Pascal's Triangle II

摘要: Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note that the row index starts from 0.  In Pascal's tri 阅读全文

posted @ 2018-11-09 10:21 猪猪🐷 阅读(87) 评论(0) 推荐(0)

456. 132 Pattern

摘要: Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i third的second值,其中的任何一个值都是大于当前的third值,如果有更大的值进来,那就等于形成了一个更优的second > third的这样一个组合,并且这时弹出的third值比以前... 阅读全文

posted @ 2018-11-09 10:20 猪猪🐷 阅读(109) 评论(0) 推荐(0)

611. Valid Triangle Number

摘要: Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. Example 1: ... 阅读全文

posted @ 2018-11-09 10:19 猪猪🐷 阅读(99) 评论(0) 推荐(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 leng... 阅读全文

posted @ 2018-11-09 10:18 猪猪🐷 阅读(143) 评论(0) 推荐(0)

6. ZigZag Conversion

摘要: https://www.youtube.com/watch?v=8zXTAn7i5rU The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for... 阅读全文

posted @ 2018-11-09 10:17 猪猪🐷 阅读(117) 评论(0) 推荐(0)

624. Maximum Distance in Arrays

摘要: Given m arrays, and each array is sorted in ascending order. Now you can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance betwe... 阅读全文

posted @ 2018-11-09 07:39 猪猪🐷 阅读(93) 评论(0) 推荐(0)

289. Game of Life

摘要: According to the Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." Given a board with m by n... 阅读全文

posted @ 2018-11-09 07:36 猪猪🐷 阅读(110) 评论(0) 推荐(0)

685. Redundant Connection II

摘要: In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent, exce... 阅读全文

posted @ 2018-11-09 07:34 猪猪🐷 阅读(117) 评论(0) 推荐(0)

156. Binary Tree Upside Down

摘要: Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same parent node) or empty, flip it up 阅读全文

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

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 猪猪🐷 阅读(87) 评论(0) 推荐(0)

541. Reverse String II

摘要: Given a string and an integer k, you need to reverse the first k characters for every 2k characters counting from the start of the string. If there are less than k characters left, reverse all of t... 阅读全文

posted @ 2018-11-09 07:26 猪猪🐷 阅读(77) 评论(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-09 07:26 猪猪🐷 阅读(84) 评论(0) 推荐(0)

161. One Edit Distance

摘要: Given two strings s and t, determine if they are both one edit distance apart. Note: There are 3 possiblities to satisify one edit distance apart: Insert a character into s to get t Delete a char... 阅读全文

posted @ 2018-11-09 07:22 猪猪🐷 阅读(115) 评论(0) 推荐(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 appear once. So 'e' m... 阅读全文

posted @ 2018-11-09 07:20 猪猪🐷 阅读(86) 评论(0) 推荐(0)

336. Palindrome Pairs

摘要: Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that the concatenation of the two words, i.e. words[i] + words[j] is a palindrome. Example 1: Input: ["ab... 阅读全文

posted @ 2018-11-09 07:20 猪猪🐷 阅读(215) 评论(0) 推荐(0)

24. Swap Nodes in Pairs

摘要: Given a linked list, swap every two adjacent nodes and return its head. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. Note: * Your algorithm should use only constant extra spac... 阅读全文

posted @ 2018-11-09 07:19 猪猪🐷 阅读(65) 评论(0) 推荐(0)

234. Palindrome Linked List

摘要: Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in O(n) time and O(1) space? ... 阅读全文

posted @ 2018-11-09 07:18 猪猪🐷 阅读(103) 评论(0) 推荐(0)

616. Add Bold Tag in String

摘要: Given a string s and a list of strings dict, you need to add a closed pair of bold tag and to wrap the substrings in s that exist in dict. If two such substrings overlap, you need to wrap them to... 阅读全文

posted @ 2018-11-09 07:17 猪猪🐷 阅读(163) 评论(0) 推荐(0)

299. Bulls and Cows

摘要: You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint th... 阅读全文

posted @ 2018-11-09 07:10 猪猪🐷 阅读(130) 评论(0) 推荐(0)

142. Linked List Cycle II

摘要: 数学题的感觉, 想不出来 https://www.qiujiawei.com/leetcode-problem-142/ 阅读全文

posted @ 2018-11-09 07:10 猪猪🐷 阅读(71) 评论(0) 推荐(0)

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 猪猪🐷 阅读(103) 评论(0) 推荐(0)

150. Evaluate Reverse Polish Notation

摘要: 变成符号在两个数前面,stack做 wyt211 发表于 2018-10-10 04:35 请问最后一题,可以把input reverse一下以后,按照lc的原题做法做嘛? 题有点不一样, 他是一个运算符后面可以跟多个数,数之间空格隔开, 运算符只有+, - 比如 * (+ 2 4 1) 3 =( 2 + 4 + 1 ) * 3. 1point3acres 我是用两个stack,一个存数字... 阅读全文

posted @ 2018-11-09 06:57 猪猪🐷 阅读(116) 评论(0) 推荐(0)

834. Sum of Distances in Tree

摘要: An undirected, connected tree with N nodes labelled 0...N-1 and N-1 edges are given. The ith edge connects nodes edges[i][0] and edges[i][1] together. 阅读全文

posted @ 2018-11-09 06:55 猪猪🐷 阅读(89) 评论(0) 推荐(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 individuall 阅读全文

posted @ 2018-11-09 06:52 猪猪🐷 阅读(85) 评论(0) 推荐(0)

70. Climbing Stairs

摘要: 口起灵,比那个稍微难点,一次不是跳两级,是跳k级,给一个k,一个n,n是总台阶数,k是每次最多跳的个数,可以比它少。我一上来说dp,给了个时间复杂度 O(kn),空间O(n)的。他说能不能简化一下空间。我说那我给了个时间kn, 空间k的。最后讨论了一阵子我简化成了时间n,空间min(n,k)的。就是不用每次都把那k个加一遍,保持一个sum就好了,每次删除一个旧的再加一个新的。 You a... 阅读全文

posted @ 2018-11-09 06:50 猪猪🐷 阅读(101) 评论(0) 推荐(0)

489. Robot Room Cleaner

摘要: Given a robot cleaner in a room modeled as a grid. Each cell in the grid can be empty or blocked. The robot cleaner with 4 given APIs can move forward, turn left or turn right. Each turn it made is... 阅读全文

posted @ 2018-11-09 06:48 猪猪🐷 阅读(157) 评论(0) 推荐(0)

755. Pour Water

摘要: We are given an elevation map, heights[i] representing the height of the terrain at that index. The width at each index is 1. After V units of water fall at index K, how much water is at each index? ... 阅读全文

posted @ 2018-11-09 06:45 猪猪🐷 阅读(162) 评论(0) 推荐(0)

759. Employee Free Time

摘要: We are given a list schedule of employees, which represents the working time for each employee. Each employee has a list of non-overlapping Intervals, and these intervals are in sorted order. Retur... 阅读全文

posted @ 2018-11-09 06:44 猪猪🐷 阅读(105) 评论(0) 推荐(0)

337. House Robber III

摘要: In step I, we defined our problem as rob(root), which will yield the maximum amount of money that can be robbed of the binary tree rooted at root. Thi 阅读全文

posted @ 2018-11-09 06:42 猪猪🐷 阅读(113) 评论(0) 推荐(0)

774. Minimize Max Distance to Gas Station

摘要: On a horizontal number line, we have gas stations at positions stations[0], stations[1], ..., stations[N-1], where N = stations.length. Now, we add K more gas stations so that D, the maximum distance... 阅读全文

posted @ 2018-11-09 06:40 猪猪🐷 阅读(107) 评论(0) 推荐(0)

267. Palindrome Permutation II

摘要: Given a string s, return all the palindromic permutations (without duplicates) of it. Return an empty list if no palindromic permutation could be form. Example 1: Input: "aabb" Output: ["abba", "ba... 阅读全文

posted @ 2018-11-09 06:39 猪猪🐷 阅读(104) 评论(0) 推荐(0)

351. Android Unlock Patterns

摘要: 带返回值的recursion, dfs 阅读全文

posted @ 2018-11-09 06:39 猪猪🐷 阅读(96) 评论(0) 推荐(0)

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

导航