- 博客(25)
- 收藏
- 关注
原创 1663. Smallest String With A Given Numeric Value
题目:Thenumeric valueof alowercase characteris defined as its position(1-indexed)in the alphabet, so the numeric value ofais1, the numeric value ofbis2, the numeric value ofcis3, and so on.Thenumeric valueof astringconsisting of lowerc...
2021-01-29 23:12:00 58
原创 374. Guess Number Higher or Lower
题目: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 will tell you whether the number I picked is higher or lower than your guess.You call a pre-...
2021-01-27 04:45:19 118
原创 1437. Check If All 1‘s Are at Least Length K Places Away
题目:Given an arraynumsof 0s and 1s and an integerk, returnTrueif all 1's are at leastkplaces away from each other, otherwise returnFalse.Example 1:Input: nums = [1,0,0,0,1,0,0,1], k = 2Output: trueExplanation: Each of the 1s are at lea...
2021-01-26 01:45:17 94
原创 1736. Latest Time by Replacing Hidden Digits
题目:You are given a stringtimein the form ofhh:mm, where some of the digits in the string are hidden (represented by?).The valid times are those inclusively between00:00and23:59.Returnthe latest valid time you can get fromtimeby replacing th...
2021-01-25 11:26:05 197
原创 23. Merge k Sorted Lists
题目:You are given an array ofklinked-listslists, each linked-list is sorted in ascending order.Merge all the linked-lists into one sorted linked-list and return it.Example 1:Input: lists = [[1,4,5],[1,3,4],[2,6]]Output: [1,1,2,3,4,4,5,6]Exp...
2021-01-24 23:42:59 161
原创 1657. Determine if Two Strings Are Close
题目:Two strings are consideredcloseif you can attain one from the other using the following operations:Operation 1: Swap any twoexistingcharacters. For example,abcde-> aecdb Operation 2: Transformeveryoccurrence of oneexistingcharacter...
2021-01-23 12:45:49 167
原创 1673. Find the Most Competitive Subsequence
题目:Given an integer arraynumsand a positive integerk, returnthe mostcompetitivesubsequence ofnumsof sizek.An array's subsequence is a resulting sequence obtained by erasing some (possibly zero) elements from the array.We define that a subseq...
2021-01-21 23:54:25 98
原创 20. Valid Parentheses
题目:Given a stringscontaining just the characters'(',')','{','}','['and']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of brackets. Open brackets must be closed in the cor...
2021-01-21 02:41:28 150
原创 5. Longest Palindromic Substring
题目:Given a strings, returnthe longest palindromic substringins.Example 1:Input: s = "babad"Output: "bab"Note: "aba" is also a valid answer.Example 2:Input: s = "cbbd"Output: "bb"Example 3:Input: s = "a"Output: "a"Example 4:...
2021-01-21 01:34:42 63
原创 1726. Tuple with Same Product
题目:Given an arraynumsofdistinctpositive integers, returnthe number of tuples(a, b, c, d)such thata * b = c * dwherea,b,c, anddare elements ofnums, anda != b != c != d.Example 1:Input: nums = [2,3,4,6]Output: 8Explanation: There ...
2021-01-19 10:23:09 201
原创 1679. Max Number of K-Sum Pairs
题目:You are given an integer arraynumsand an integerk.In one operation, you can pick two numbers from the array whose sum equalskand remove them from the array.Returnthe maximum number of operations you can perform on the array.Example 1:...
2021-01-18 20:50:19 133
原创 215. Kth Largest Element in an Array
题目:Find thekth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.Example 1:Input: [3,2,1,5,6,4] and k = 2Output: 5Example 2:Input: [3,2,3,1,2,4,5,5,6] and k = 4Ou.
2021-01-17 08:30:27 67
原创 1646. Get Maximum in Generated Array
题目:You are given an integern. An arraynumsof lengthn + 1is generated in the following way:nums[0] = 0 nums[1] = 1 nums[2 * i] = nums[i]when2 <= 2 * i <= n nums[2 * i + 1] = nums[i] + nums[i + 1]when2 <= 2 * i + 1 <= nReturnthe...
2021-01-17 08:14:33 109
原创 881. Boats to Save People
题目:Thei-th person has weightpeople[i], and each boat can carry a maximum weight oflimit.Each boat carries at most 2 people at the same time, provided the sum of theweight of those people is at mostlimit.Return the minimum number of boats to carr...
2021-01-14 07:18:44 37
原创 2. Add Two Numbers
题目:You are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse order, and each of their nodes contains a single digit. Add the two numbers and return the sumas a linked list.You may assume the two ...
2021-01-13 01:48:50 69
原创 88. Merge Sorted Array
题目:Given two sorted integer arraysnums1andnums2, mergenums2intonums1as one sorted array.The number of elements initialized innums1andnums2aremandnrespectively. You may assume thatnums1has enough space (size that isequal tom + n) to h...
2021-01-12 03:05:35 84
原创 1721. Swapping Nodes in a Linked List
题目:You are given theheadof a linked list, and an integerk.Returnthe head of the linked list afterswappingthe values of thekthnode from the beginning and thekthnode from the end (the list is1-indexed).Example 1:Input: head = [1,2,3,...
2021-01-11 02:20:50 343
原创 3. Longest Substring Without Repeating Characters
题目:Given a strings, find the length of thelongest substringwithout repeating characters.Example 1:Input: s = "abcabcbb"Output: 3Explanation: The answer is "abc", with the length of 3.Example 2:Input: s = "bbbbb"Output: 1Explanation: ...
2021-01-08 07:25:21 64
原创 1539. Kth Missing Positive Number
题目:Given an arrayarrof positive integerssorted in astrictly increasing order, and an integerk.Find thekthpositive integer that is missing from this array.Example 1:Input: arr = [2,3,4,7,11], k = 5Output: 9Explanation: The missing posit...
2021-01-07 01:22:08 156
原创 83. Remove Duplicates from Sorted List
题目:Given theheadof a sorted linked list,delete all duplicates such that each element appears only once. Returnthe linked listsortedas well.Example 1:Input: head = [1,1,2]Output: [1,2]Example 2:Input: head = [1,1,2,3,3]Output: [1...
2021-01-06 11:46:36 186 1
原创 82. Remove Duplicates from Sorted List II
题目:Given theheadof a sorted linked list,delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Returnthe linked listsortedas well.Example 1:Input: head = [1,2,3,3,4,4,5]Output: [1,2,5]Examp...
2021-01-06 11:31:08 68
原创 21. Merge Two Sorted Lists
题目:Merge two sorted linked lists and return it as asortedlist. The list should be made by splicing together the nodes of the first two lists.Example 1:Input: l1 = [1,2,4], l2 = [1,3,4]Output: [1,1,2,3,4,4]Example 2:Input: l1 = [], l2 =...
2021-01-04 23:52:16 58
原创 1713. Minimum Operations to Make a Subsequence
题目:You are given an arraytargetthat consists ofdistinctintegers and another integer arrayarrthatcanhave duplicates.In one operation, you can insert any integer at any position inarr. For example, ifarr = [1,4,1,2], you can add3in the middle...
2021-01-04 09:40:57 125
原创 1711. Count Good Meals
题目:Agood mealis a meal that containsexactly two different food itemswith a sum of deliciousness equal to a power of two.You can pickanytwo different foods to make a good meal.Given an array of integersdeliciousnesswheredeliciousness[i]is th...
2021-01-04 05:57:30 208
原创 526. Beautiful Arrangement
题目:Suppose you havenintegers from1ton. We define a beautiful arrangement as an array that is constructed by thesennumbers successfully if one of the following is true for theithposition (1 <= i <= n) in this array:The number at theithp...
2021-01-03 23:50:32 164
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人