Easy
weixin_39145266
这个作者很懒,什么都没留下…
展开
-
1099 Two Sum Less Than K
1 题目Given an arrayAof integers andintegerK, return the maximumSsuch that there existsi < jwithA[i] + A[j] = SandS < K. If noi, jexist satisfying this equation, return -1.Example...原创 2019-12-05 08:15:50 · 120 阅读 · 0 评论 -
572 Subtree of Another Tree
1 题目Given two non-empty binary treessandt, check whether treethas exactly the same structure and node values with a subtree ofs. A subtree ofsis a tree consists of a node insand all of thi...原创 2019-11-24 10:17:54 · 84 阅读 · 0 评论 -
937 Reorder Data in Log Files
1 题目You have an array oflogs. Each log is a space delimited string of words.For each log, the first word in each log is an alphanumericidentifier. Then, either:Each word after the identifier...原创 2019-11-21 10:43:46 · 230 阅读 · 0 评论 -
409 Longest Palindrome
1 题目Given 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 not...原创 2019-11-21 03:27:44 · 73 阅读 · 0 评论 -
70 Climbing Stairs
1 题目You are climbing a stair case. It takesnsteps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note:Givennwill be a po...原创 2019-08-02 17:46:37 · 66 阅读 · 0 评论 -
303 Range Sum Query - Immutable
1 题目Given an integer arraynums, find the sum of the elements between indicesiandj(i≤j), inclusive.Example:Given nums = [-2, 0, 3, -5, 2, -1]sumRange(0, 2) -> 1sumRange(2, 5) -> ...原创 2019-06-26 15:08:13 · 55 阅读 · 0 评论 -
485 Max Consecutive Ones
1 题目Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecu...原创 2019-06-25 16:26:58 · 76 阅读 · 0 评论 -
387 First Unique Character in a String
1 题目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:Yo...原创 2019-05-07 16:08:04 · 67 阅读 · 0 评论 -
383 Ransom Note
1 题目Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note can be constructed from the magazine...原创 2019-05-07 16:34:40 · 427 阅读 · 0 评论 -
155 Min Stack
1 题目Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top()...原创 2019-05-07 15:25:23 · 175 阅读 · 0 评论 -
746 Min Cost Climbing Stairs
1 题目On a staircase, thei-th step has some non-negative costcost[i]assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the t...原创 2019-08-03 11:24:11 · 59 阅读 · 0 评论 -
1025 Divisor Game
1 题目Alice and Bob take turns playing a game, with Alice starting first.Initially, there is a numberNon the chalkboard. On each player's turn, that player makes amoveconsisting of:Choosinga...原创 2019-08-03 12:00:38 · 130 阅读 · 0 评论 -
718 Maximum Length of Repeated Subarray
1 题目Given two integer arraysAandB, return the maximum length of an subarray that appears in both arrays.Example 1:Input:A: [1,2,3,2,1]B: [3,2,1,4,7]Output: 3Explanation: The repeated su...原创 2019-08-03 12:25:23 · 65 阅读 · 0 评论 -
1029 Two City Scheduling
1 题目There are2Npeople a company is planning to interview. The cost of flying thei-th person to cityAiscosts[i][0], and the cost of flying thei-th person to cityBiscosts[i][1].Return the ...原创 2019-08-10 14:06:16 · 167 阅读 · 0 评论 -
1005 Maximize Sum Of Array After K Negations
1 题目Given an arrayAof integers, wemustmodify the array in the following way: we choose aniand replaceA[i]with-A[i], and we repeat this processKtimes in total. (We may choose the same ind...原创 2019-08-10 18:38:43 · 89 阅读 · 0 评论 -
1046 Last Stone Weight
1 题目We have a collection of rocks, each rock has a positive integer weight.Each turn, we choose the twoheaviestrocksand smash them together. Suppose the stones have weightsxandywithx <...原创 2019-08-10 18:56:59 · 62 阅读 · 0 评论 -
1200 Minimum Absolute Difference
1 题目Given anarrayofdistinctintegersarr, find all pairs of elements with the minimum absolute difference of any two elements.Return a list of pairs in ascending order(with respect to pairs), ...原创 2019-09-24 10:05:49 · 162 阅读 · 0 评论 -
994 Rotting Oranges
1 题目In a given grid, each cell can have one of threevalues:the value0representing an empty cell; the value1representing a fresh orange; the value2representing a rotten orange.Every minut...原创 2019-09-27 07:23:52 · 138 阅读 · 0 评论 -
234 Palindrome Linked List
1 题目Given a singly linked list, determine if it is a palindrome.Example 1:Input: 1->2Output: falseExample 2:Input: 1->2->2->1Output: trueFollow up:Could you do it in O(n) ...原创 2019-05-07 14:57:01 · 77 阅读 · 0 评论 -
189 Rotate Array
1 题目Given an array, rotate the array to the right byksteps, wherekis non-negative.Example 1:Input: [1,2,3,4,5,6,7] and k = 3Output: [5,6,7,1,2,3,4]Explanation:rotate 1 steps to the right...原创 2019-05-07 12:09:01 · 96 阅读 · 0 评论 -
232 Implement Queue using Stacks
1 题目Implement the following operations of a queue using stacks.push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front elemen...原创 2019-05-06 17:46:21 · 71 阅读 · 0 评论 -
257 Binary Tree Paths
1 题目Given a binary tree, return all root-to-leaf paths.Note:A leaf is a node with no children.Example:Input: 1 / \2 3 \ 5Output: ["1->2->5", "1->3"]Explanation: A...原创 2019-04-26 10:10:32 · 62 阅读 · 0 评论 -
235 Lowest Common Ancestor of a Binary Search Tree
1 题目Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: “The lowest common ancestor is defined be...原创 2019-04-26 10:39:49 · 67 阅读 · 0 评论 -
160 Intersection of Two Linked Lists
1 题目Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:begin to intersect at node c1.Example 1:Inpu...原创 2019-04-26 11:42:17 · 94 阅读 · 0 评论 -
107 Binary Tree Level Order Traversal II
1 题目Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree[3,9,20,null,nul...原创 2019-04-26 12:10:12 · 245 阅读 · 0 评论 -
206 Reverse Linked List
1 题目Reverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or re...原创 2019-04-26 15:54:21 · 65 阅读 · 0 评论 -
204 Count Primes
1 题目Count the number of prime numbers less than a non-negative number,n.Example:Input: 10Output: 4Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7.2 尝试解2.1 分析从2...原创 2019-04-26 17:46:15 · 87 阅读 · 0 评论 -
88 Merge Sorted Array
1 题目Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.Note:The number of elements initialized innums1andnums2aremandnrespectively. You may assume...原创 2019-04-26 18:15:11 · 206 阅读 · 0 评论 -
292 Nim Game
1 题目You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will ...原创 2019-04-24 17:49:36 · 127 阅读 · 0 评论 -
400 Nth Digit
1题目Find thenthdigit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...Note:nis positive and will fit within the range of a 32-bit signed integer (n< 231).Example 1:...原创 2019-05-08 15:14:00 · 87 阅读 · 0 评论 -
374 Guess Number Higher or Lower
1 题目We are playing the Guess Game. The game is as follows:I pick a number from1ton. You have to guess which number I picked.Every time you guess wrong, I'll tell you whether the number is hig...原创 2019-05-08 16:11:45 · 86 阅读 · 0 评论 -
121 Best Time to Buy and Sell Stock
1 题目Say you have an array for which theithelement is the price of a given stock on dayi.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the s...原创 2019-05-06 14:19:33 · 65 阅读 · 0 评论 -
122 Best Time to Buy and Sell Stock II
1 题目Say you have an array for which theithelement is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (i.e., ...原创 2019-05-06 14:34:02 · 76 阅读 · 0 评论 -
125 Valid Palindrome
1 题目Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.Note:For the purpose of this problem, we define empty string as valid palindrome....原创 2019-05-06 15:02:05 · 70 阅读 · 0 评论 -
283 Move Zeroes
1 题目Given an arraynums, write a function to move all0's to the end of it while maintaining the relative order of the non-zero elements.Example:Input: [0,1,0,3,12]Output: [1,3,12,0,0]Note:...原创 2019-05-06 15:20:24 · 63 阅读 · 0 评论 -
225 Implement Stack using Queues
1 题目Implement the following operations of a stack using queues.push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. empty() -- R...原创 2019-05-06 15:42:51 · 91 阅读 · 0 评论 -
14 Longest Common Prefix
1 题目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"]O...原创 2019-05-06 16:02:02 · 67 阅读 · 0 评论 -
108 Convert Sorted Array to Binary Search Tree
1 题目Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth ...原创 2019-05-06 16:26:02 · 54 阅读 · 0 评论 -
53 Maximum Subarray
1 题目Given an integer arraynums, find the contiguous subarray(containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output: 6Exp...原创 2019-04-26 10:01:06 · 71 阅读 · 0 评论