LeeCode_Array
Haskei
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[LeeCode] 4. Median of Two Sorted Arrays (Python)
4.Median of Two Sorted Arrays Hard There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assumenums1andnums2cannot be bot...原创 2020-06-13 09:26:41 · 240 阅读 · 0 评论 -
[Leetcode] 560. Subarray Sum Equals K 找出连续子串的和等于k的子串个数
560.Subarray Sum Equals K(题目链接) Medium Given an array of integers and an integerk, you need to find the total number of continuous subarrays whose sum equals tok. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Constraints: The length of the...原创 2020-08-19 12:32:20 · 401 阅读 · 0 评论 -
13. Roman to Integer (Python)
13.Roman to Integer Easy Roman numerals are represented by seven different symbols:I,V,X,L,C,DandM. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Fo...原创 2020-05-28 00:31:43 · 394 阅读 · 0 评论 -
819. Most Common Word (Python)
819.Most Common Word Easy Given a paragraphand a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique. Words in the l...原创 2020-05-27 13:10:12 · 241 阅读 · 0 评论 -
20. Valid Parentheses (Python)
20.Valid Parentheses Easy Given a string containing 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 mus...原创 2020-05-27 11:47:02 · 317 阅读 · 0 评论 -
387. First Unique Character in a String (Python)
387.First Unique Character in a String Easy 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:You may assum...原创 2020-05-27 11:18:31 · 274 阅读 · 0 评论 -
273. Integer to English Words (Python)
273.Integer to English Words Hard Convert a non-negative integer to its english words representation. Given input is guaranteed to be less than 231- 1. Example 1: Input: 123 Output: "One Hundred Twenty Three" Example 2: Input: 12345 Output: "Twe..原创 2020-05-27 10:51:54 · 281 阅读 · 0 评论 -
76. Minimum Window Substring
76.Minimum Window Substring Hard Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). Example: Input: S = "ADOBECODEBANC", T = "ABC" Output: "BANC" Note: If there is no such w.原创 2020-05-27 04:17:17 · 205 阅读 · 0 评论 -
937. Reorder Data in Log Files
937.Reorder Data in Log Files Easy 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 will consist only of lo...原创 2020-05-23 23:59:17 · 246 阅读 · 0 评论 -
[Leetcode] 16. 3Sum Closet 双指针
16.3Sum Closest Given an arraynumsofnintegers and an integertarget, find three integers innumssuch that the sum is closest totarget. Return the sum of the three integers. You may assume that...原创 2020-02-26 08:05:49 · 288 阅读 · 0 评论 -
Longest Substring Without Repeating Characters
3.Longest Substring Without Repeating Characters Medium 7654450Add to ListShare Given a string, find the length of thelongest substringwithout repeating characters. Example 1: Input: "abcabcb...原创 2020-02-08 14:58:28 · 207 阅读 · 0 评论 -
287. Find the Duplicate Number
287.Find the Duplicate Number Given an arraynumscontainingn+ 1 integers where each integer is between 1 andn(inclusive), prove that at least one duplicate number must exist. Assume that there i...原创 2020-01-31 14:53:58 · 259 阅读 · 0 评论 -
矩阵顺时针旋转90度,逆时针旋转90度
参考https://blog.csdn.net/lym940928/article/details/89674125 //顺时针旋转90度 /* * clockwise rotate * first reverse up to down, then swap the symmetry * 1 2 3 7 8 9 7 4 1 * 4 5 6 => 4 5 ...原创 2020-01-30 08:03:45 · 2495 阅读 · 0 评论 -
448. Find All Numbers Disappeared in an Array
448.Find All Numbers Disappeared in an Array Given an array of integers where 1 ≤ a[i] ≤n(n= size of array), some elements appear twice and others appear once. Find all the elements of [1,n] in...原创 2020-01-29 08:33:35 · 355 阅读 · 0 评论 -
283. Move Zeroes
283.Move Zeroes 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,...原创 2020-01-29 05:20:10 · 390 阅读 · 0 评论 -
78. Subsets
78.Subsets Given a set ofdistinctintegers,nums, return all possible subsets (the power set). Note:The solution set must not contain duplicate subsets. Example: Input: nums = [1,2,3] Output: ...原创 2020-01-27 12:08:04 · 226 阅读 · 0 评论 -
LeeCode 数组做题随笔(主要记录做题过程中的一些感悟)
1.当对一个数组要求以O(n)的时间复杂度去实现的时候,大部分情况下需要对数组进行一下预处理,或者程序中包含多个O(n)的for循环 2.对数组的处理,如果需要用到之前数组的信息,也就是说后面更新的数组信息跟之前信息有关,处理方法往往是从无到有,比如从最左边开始往右递增,或者从最右边开始往左递增。 ...原创 2020-01-27 09:15:14 · 218 阅读 · 0 评论 -
238. Product of Array Except Self
238.Product of Array Except Self Given an arraynumsofnintegers wheren> 1, return an arrayoutputsuch thatoutput[i]is equal to the product of all the elements ofnumsexceptnums[i]. Ex...原创 2020-01-27 09:05:16 · 257 阅读 · 0 评论 -
53. Maximum Subarray
53.Maximum Subarray 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...原创 2020-01-27 07:47:01 · 217 阅读 · 0 评论 -
34. Find First and Last Position of Element in Sorted Array 变向使用二分法
34.Find First and Last Position of Element in Sorted Array Given an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue. Your algorith...原创 2020-01-24 11:24:08 · 242 阅读 · 0 评论 -
33. Search in Rotated Sorted Array 二分法的变向使用
33.Search in Rotated Sorted Array Medium Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e.,[0,1,2,4,5,6,7]might become[4,5,6,7,0,1,2]). You a...原创 2020-01-23 08:39:29 · 297 阅读 · 0 评论 -
31. Next Permutation
31.Next Permutation Implementnext permutation, which rearranges numbers into the lexicographically next greater permutation of numbers. If such arrangement is not possible, it must rearrange it as...原创 2020-01-17 11:36:21 · 255 阅读 · 0 评论 -
LeeCode 3Sum
Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero. Note: The solution set must not cont...原创 2020-01-16 11:58:54 · 281 阅读 · 0 评论 -
1.Two Sum - LeeCode hashmap
Given an array of integers, returnindicesof the two numbers such that they add up to a specific target. You may assume that each input would haveexactlyone solution, and you may not use thesame...原创 2020-01-07 08:33:29 · 194 阅读 · 0 评论 -
42. Trapping Rain Water
解: 辅助图片: class Solution { public: int trap(vector<int>& height) { int value=0; int cnt = height.capacity(); int maxIndex = 0; int sum = 0; ...原创 2019-12-19 15:02:59 · 187 阅读 · 0 评论 -
LeeCode 4. Median of Two Sorted Arrays
4.Median of Two Sorted Arrays There are two sorted arraysnums1andnums2of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+...原创 2019-12-17 04:24:01 · 152 阅读 · 0 评论 -
Array 常用函数(C++)
std::remove(begin, end, value) 该函数移除一个从begin到end位置,值等于value的数据。这个函数只是通过指针的移动来完成删除操作,将不等于value的值放到链表的最前端,然后返回一个指向新的尾值的迭代器(比如,[1,2,3,4,2], 最后会指向index=3,0是第一个元素)。 std::distance(begin, end); 返回begin与end...原创 2019-12-16 09:17:00 · 828 阅读 · 0 评论
分享