#Etc

leetcode 349. Intersection of Two Arrays

Giventwoarrays,writeafunctiontocomputetheirintersection.Example:Given nums1 = [1,2,2,1], nums2 = [2,2],return [2].Note:Eachel...

leetcode 659. Split Array into Consecutive Subsequences

Youaregivenanintegerarraysortedinascendingorder(maycontainduplicates),youneedtosplitthemintoseveralsubsequences,whereeachsubsequencesconsistofatleast3consecutiv...

leetcode 658. Find K Closest Elements

Givenasortedarray,twointegers k and x,findthe k closestelementsto x inthearray.Theresultshouldalsobesortedinascendingorder.If...

leetcode 657. Judge Route Circle

  Initially,thereisaRobotatposition(0,0).Givenasequenceofitsmoves,judgeifthisrobotmakesacircle,whichmeansitmovesbackto theoriginalplace.Themovese...

leetcode 179. Largest Number

Givenalistofnonnegativeintegers,arrangethemsuchthattheyformthelargestnumber.Forexample,given [3,30,34,5,9],thelargestformednumberis 9534330.Note:There...
代码星球 代码星球·2021-01-23

leetcode 660. Remove 9

Startfrominteger1,removeanyintegerthatcontains9suchas9,19,29...Sonow,youwillhaveanewintegersequence:1,2,3,4,5,6,7,8,10,11,...Givenapositiveinteger n,younee...
代码星球 代码星球·2021-01-23

leetcode 442. Find All Duplicates in an Array

Givenanarrayofintegers,1≤a[i]≤ n (n =sizeofarray),someelementsappear twice andothersappear once.Findalltheelementsthatappear ...

leetcode 405. Convert a Number to Hexadecimal

Givenaninteger,writeanalgorithmtoconvertittohexadecimal.Fornegativeinteger, two’scomplement methodisused.Note:Alllettersinhexadecimal(a-f)mustbeinlowe...

leetcode 506. Relative Ranks

Givenscoresof N athletes,findtheirrelativeranksandthepeoplewiththetopthreehighestscores,whowillbeawardedmedals:"GoldMedal","SilverMedal"and"BronzeMeda...
代码星球 代码星球·2021-01-23

leetcode 316. Remove Duplicate Letters

Givenastringwhichcontainsonlylowercaseletters,removeduplicateletterssothateveryletterappearonceandonlyonce.Youmustmakesureyourresultisthesmallestinlexicographic...

leetcode 654. Maximum Binary Tree

Givenanintegerarraywithnoduplicates.Amaximumtreebuildingonthisarrayisdefinedasfollow:Therootisthemaximumnumberinthearray.Theleftsubtreeisthemaximumtreeconstruct...

leetcode 653. Two Sum IV

GivenaBinarySearchTreeandatargetnumber,returntrueifthereexisttwoelementsintheBSTsuchthattheirsumisequaltothegiventarget.Example1:Input:5/36/247Target=9Output:Tr...
代码星球 代码星球·2021-01-23

leetcode 656. Coin Path

Givenanarray A (indexstartsat 1)consistingofNintegers:A1,A2,...,AN andaninteger B.Theinteger B denotesthatfromanyplace(suppos...
代码星球 代码星球·2021-01-23

leetcode 258. Add Digits

Givenanon-negativeinteger num,repeatedlyaddallitsdigitsuntiltheresulthasonlyonedigit.Forexample:Given num=38,theprocessislike: 3+8=11, 1+1=2...
代码星球 代码星球·2021-01-23

leetcode 231. Power of Two

Givenaninteger,writeafunctiontodetermineifitisapoweroftwo.classSolution{public:boolisPowerOfTwo(intn){intnum=0;while(n>0){if(n&1)num++;n/=2;}if(num==1)re...
首页上一页...2122232425...下一页尾页