- 博客(13)
- 问答 (1)
- 收藏
- 关注
原创 287. Find the Duplicate Number
287.Find the Duplicate NumberGiven 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 155
原创 矩阵顺时针旋转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 2173
原创 448. Find All Numbers Disappeared in an Array
448.Find All Numbers Disappeared in an ArrayGiven 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 243
原创 283. Move Zeroes
283.Move ZeroesGiven 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 294
原创 78. Subsets
78.SubsetsGiven 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 136
原创 LeeCode 数组做题随笔(主要记录做题过程中的一些感悟)
1.当对一个数组要求以O(n)的时间复杂度去实现的时候,大部分情况下需要对数组进行一下预处理,或者程序中包含多个O(n)的for循环2.对数组的处理,如果需要用到之前数组的信息,也就是说后面更新的数组信息跟之前信息有关,处理方法往往是从无到有,比如从最左边开始往右递增,或者从最右边开始往左递增。...
2020-01-27 09:15:14 129
原创 238. Product of Array Except Self
238.Product of Array Except SelfGiven 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 179
原创 53. Maximum Subarray
53.Maximum SubarrayGiven 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 132
原创 34. Find First and Last Position of Element in Sorted Array 变向使用二分法
34.Find First and Last Position of Element in Sorted ArrayGiven an array of integersnumssorted in ascending order, find the starting and ending position of a giventargetvalue.Your algorith...
2020-01-24 11:24:08 153
原创 33. Search in Rotated Sorted Array 二分法的变向使用
33.Search in Rotated Sorted ArrayMediumSuppose 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 209
原创 31. Next Permutation
31.Next PermutationImplementnext 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 157
原创 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 204
原创 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 114
空空如也
C++ 运算符重载问题,求大神们帮忙,一直找不到解决办法
2016-09-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人