- 博客(85)
- 资源 (4)
- 收藏
- 关注
原创 Leetcode需要重复看的题目
目录没思路动态规划有优化解法没思路动态规划Best Time to Buy and Sell Stock有优化解法
2020-03-09 21:08:22 202
原创 912. Sort an Array(Leetcode每日一题-2020.03.31)
ProblemGiven an array of integers nums, sort the array in ascending order.Example1Input: nums = [5,2,3,1]Output: [1,2,3,5]Example2Input: nums = [5,1,1,2,0,0]Output: [0,0,1,1,2,5]SolutionS...
2020-03-31 20:43:38 215
原创 78. Subsets && 面试题 08.04. Power Set LCCI
ProblemProblem 78Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.面试题 08.04Write a method to return al...
2020-03-30 20:27:59 268
原创 面试题62. 圆圈中最后剩下的数字(Leetcode每日一题-2020.03.30)
Problem0,1,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个数字。例如,0、1、2、3、4这5个数字组成一个圆圈,从数字0开始每次删除第3个数字,则删除的前4个数字依次是2、0、4、1,因此最后剩下的数字是3。Example1输入: n = 5, m = 3输出: 3Example2输入: n = 10, m =...
2020-03-30 20:13:22 344
原创 1162. As Far from Land as Possible(Leetcode每日一题-2020.03.29)
ProblemGiven an N x N grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized and return th...
2020-03-30 20:05:56 318
原创 820. Short Encoding of Words(Leetcode每日一题-2020.03.28)
ProblemGiven a list of words, we may encode it by writing a reference string S and a list of indexes A.For example, if the list of words is [“time”, “me”, “bell”], we can write it as S = “time#bell#...
2020-03-30 19:57:51 275
原创 47. Permutations II && 面试题 08.08. Permutation II LCCI && 面试题38. 字符串的排列
Problem47Given a collection of numbers that might contain duplicates, return all possible unique permutations.ExampleInput: [1,1,2]Output:[[1,1,2],[1,2,1],[2,1,1]]面试题08.08Write a method ...
2020-03-29 17:21:57 246
原创 46. Permutations&&面试题 08.07. Permutation I LCCI(Leetcode每日一题-2020.04.25)
Problem46Given a collection of distinct integers, return all possible permutations.ExampleInput: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]来源:力扣(LeetCode)链接:https...
2020-03-29 17:12:33 291
原创 914. X of a Kind in a Deck of Cards(Leetcode每日一题-2020.03.27)
ProblemIn a deck of cards, each card has an integer written on it.Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards...
2020-03-27 20:57:16 227
原创 155. Min Stack&&面试题 03.02. Min Stack LCCI(Leetcode每日一题-2020.05.12)
ProblemHow would you design a stack which, in addition to push and pop, has a function min which returns the minimum element? Push, pop and min should all operate in 0(1) time.ExampleMinStack minS...
2020-03-26 22:43:30 233
原创 面试题 03.01. Three in One LCCI
ProblemDescribe how you could use a single array to implement three stacks.Yout should implement push(stackNum, value)、pop(stackNum)、isEmpty(stackNum)、peek(stackNum) methods. stackNum is the index o...
2020-03-26 22:30:26 252
原创 999. Available Captures for Rook(Leetcode每日一题-2020.03.26)
ProblemOn an 8 x 8 chessboard, there is one white rook. There also may be empty squares, white bishops, and black pawns. These are given as characters ‘R’, ‘.’, ‘B’, and ‘p’ respectively. Uppercase...
2020-03-26 20:06:11 272
原创 面试题 02.06. Palindrome Linked List LCCI
ProblemImplement a function to check if a linked list is a palindrome.Example1Input: 1->2Output: falseExample2Input: 1->2->2->1Output: trueSolution/** * Definition for si...
2020-03-25 22:16:46 215
原创 面试题 02.01. Remove Duplicate Node LCCI
ProblemWrite code to remove duplicates from an unsorted linked list.Example1Input: [1, 2, 3, 3, 2, 1]Output: [1, 2, 3]Example2Input: [1, 2, 3, 3, 2, 1]Output: [1, 2, 3]Solution用一个set辅助记录出...
2020-03-25 22:00:48 208
原创 892. Surface Area of 3D Shapes(Leetcode每日一题-2020.03.25)
ProblemOn a N * N grid, we place some 1 * 1 * 1 cubes.Each value v = grid[i][j] represents a tower of v cubes placed on top of grid cell (i, j).Return the total surface area of the resulting shapes...
2020-03-25 20:20:24 316
原创 面试题 01.09. String Rotation LCCI
ProblemGiven two strings, s1 and s2, write code to check if s2 is a rotation of s1 (e.g.,“waterbottle” is a rotation of"erbottlewat"). Can you use only one call to the method that checks if one word ...
2020-03-24 23:48:20 227
原创 面试题 01.04. Palindrome Permutation LCCI
ProblemGiven a string, write a function to check if it is a permutation of a palin drome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement o...
2020-03-24 23:34:12 223
原创 面试题 01.03. String to URL LCCI
ProblemWrite a method to replace all spaces in a string with ‘%20’. You may assume that the string has sufficient space at the end to hold the additional characters,and that you are given the “true” ...
2020-03-24 23:27:32 162
原创 面试题 17.16. The Masseuse LCCI(Leetcode每日一题-2020.03.24)
ProblemA popular masseuse receives a sequence of back-to-back appointment requests and is debating which ones to accept. She needs a break between appointments and therefore she cannot accept any adj...
2020-03-24 23:17:19 721
原创 面试题 01.02. Check Permutation LCCI
ProblemGiven two strings,write a method to decide if one is a permutation of the other.Note:0 <= len(s1) <= 1000 <= len(s2) <= 100Example1Input: s1 = “abc”, s2 = “bca”Output: true...
2020-03-23 23:26:24 175
原创 面试题 01.01. Is Unique LCCI
ProblemImplement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?Example1Input: s = “leetcode”Output: falseExample2Input: s ...
2020-03-23 23:22:05 259
原创 面试题 03.04. Implement Queue using Stacks LCCI
ProblemImplement a MyQueue class which implements a queue using two stacks.Notes:You must use only standard operations of a stack – which means only push to top, peek/pop from top, size, and is em...
2020-03-23 23:15:53 200
原创 面试题 02.03. Delete Middle Node LCCI
ProblemImplement an algorithm to delete a node in the middle (i.e., any node but the first and last node, not necessarily the exact middle) of a singly linked list, given only access to that node.Ex...
2020-03-23 23:00:17 214
原创 面试题 02.02. Kth Node From End of List LCCI&面试题22. 链表中倒数第k个节点
ProblemImplement an algorithm to find the kth to last element of a singly linked list. Return the value of the element.Note:k is always valid.This problem is slightly different from the original ...
2020-03-23 22:47:35 183
原创 998. Maximum Binary Tree II
ProblemWe are given the root node of a maximum tree: a tree where every node has a value greater than any other value in its subtree.Just as in the previous problem, the given tree was constructed f...
2020-03-23 20:29:42 125
原创 951. Flip Equivalent Binary Trees
ProblemFor a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees.A binary tree X is flip equivalent to a binary tree Y if and only i...
2020-03-23 19:50:52 146
原创 876. Middle of the Linked List(Leetcode每日一题-2020.03.23)
ProblemGiven a non-empty, singly linked list with head node head, return a middle node of linked list.If there are two middle nodes, return the second middle node.Note:The number of nodes in the g...
2020-03-23 19:48:37 191
原创 889. Construct Binary Tree from Preorder and Postorder Traversal
ProblemReturn any binary tree that matches the given preorder and postorder traversals.Values in the traversals pre and post are distinct positive integers.Note:1 <= pre.length == post.length ...
2020-03-22 21:28:11 198
原创 1325. Delete Leaves With a Given Value
ProblemGiven a binary tree root and an integer target, delete all the leaf nodes with value target.Note that once you delete a leaf node with value target, if it’s parent node becomes a leaf node an...
2020-03-22 20:39:38 176
原创 945. Minimum Increment to Make Array Unique(Leetcode每日一题-2020.03.22)
ProblemGiven an array of integers A, a move consists of choosing any A[i], and incrementing it by 1.Return the least number of moves to make every value in A unique.Note:0 <= A.length <= 400...
2020-03-22 17:20:40 212
原创 1261. Find Elements in a Contaminated Binary Tree
ProblemGiven a binary tree with the following rules:root.val == 0If treeNode.val == x and treeNode.left != null, then treeNode.left.val == 2 * x + 1If treeNode.val == x and treeNode.right != null,...
2020-03-21 23:21:05 203
原创 894. All Possible Full Binary Trees
ProblemA full binary tree is a binary tree where each node has exactly 0 or 2 children.Return a list of all possible full binary trees with N nodes. Each element of the answer is the root node of o...
2020-03-21 22:59:41 260
原创 1379. Find a Corresponding Node of a Binary Tree in a Clone of That Tree
ProblemGiven two binary trees original and cloned and given a reference to a node target in the original tree.The cloned tree is a copy of the original tree.Return a reference to the same node in t...
2020-03-21 22:20:17 532
原创 365. Water and Jug Problem(Leetcode每日一题-2020.03.21)
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two j...
2020-03-21 15:24:29 314
原创 面试题40. 最小的k个数(Leetcode每日一题-2020.03.20)
Problem输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。限制:0 <= k <= arr.length <= 100000 <= arr[i] <= 10000Example1输入:arr = [3,2,1], k = 2输出:[1,2] 或者 [2,1]...
2020-03-20 19:27:57 201
原创 409. Longest Palindrome(Leetcode每日一题-2020.03.19)
ProblemGiven 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 no...
2020-03-19 20:04:14 166
原创 814. Binary Tree Pruning
ProblemWe are given the head node root of a binary tree, where additionally every node’s value is either a 0 or a 1.Return the same tree where every subtree (of the given tree) not containing a 1 ha...
2020-03-18 20:05:42 190
原创 836. Rectangle Overlap(Leetcode每日一题-2020.03.18)
ProblemA 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 of its top-right corner.Two rectangles ov...
2020-03-18 19:47:45 181
原创 1160. Find Words That Can Be Formed by Characters(Leetcode每日一题-2020.03.17)
ProblemYou are given an array of strings words and a string chars.A string is good if it can be formed by characters from chars (each character can only be used once).Return the sum of lengths of a...
2020-03-17 19:55:19 221
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人