Hey, everyone, mynameis y queon I'm a formersoftwaredeveloper, Google.
Inthisvideo, I'm goingtowalkyouthroughtheprocess I wouldpersonallyusetogetthroughanactualquoting, intimatequestionfromGoogleHere.
I'm goingtouse a questionfromGoogleasanexample, butyoubeabletousethesameprocesstogetthroughprogramminginterviewswithanycompany, and I chose a relativelysimpleproblemheresothat I canexplainthewholeprocessquickly.
Nowhere's theproblem.
You'regivenanarrayofeditorsforexample, 13 to 4, whichrepresents a number.
Thisarrayofrepresents 1000 324 andtheproblemiswriting a functionthattakesdisarrayonasonetothisnumber.
Soyourfunction, ifyou'regiventhisarray, shouldreturn 13 to 5, whichrepresents 1325.
Now, howwould I solvethisproblem?
Letmewalkyouthroughthewholeprocess I wouldpersonallyusetosolvethisproblemstepbystep.
Ifthegivenarrayendswith a numberthat's notnine, forexample, fourThisarray 13 to 4 becauseinthatcasewecanjustaddonetothelastitemandwegetfiveandthencopyovereverythingelseifthelastintegerisnine.
Soifwehad, forexample, 13 to 9 insteadoff 13 to 4, thenwouldneedtochangethisnumber 20 andthencarryonetothenextnumberonkeeprepeatingthisprocessuntilwehavenothingtocarry.
Theonlytrickycaseforthisproblemiswhenwehavesomethinglikemy 199 or 999 intheGivenarray, becausethenthenewarraywillneedtobe 1000 Sofromourfunctionwillneedtocreate a newarraywith a differentlengthlengthfourhereandthenreturnedthisNuriforthisproblem.
Ormaybeiftheproblemismorecomplex, I'd recommendthatyoulistout a fewpotentialapproachesyoucouldusetosolvethisproblem.
Forexample, forthisparticularproblem, youmightsay, Well, I'm thinkingaboutusingeitheraniterativeapproachwith a fourlooporwith a recursiveapproach, waysrickerson, especiallyformorecomplexproblem.
It's reallyimportanttolistout a fewpotentialsolutionsyouhave a mindbecauseit's rareforyoutogettotheoptimalsolutionwithyourfirstidea.
Butifnot, listout a fewpotentialsolutionsbeforeyoustartcoatingnowontosteptwoJewsyourapproachandstartquotinghereinthisexample, youmightsaysomethinglike, Well, I thinktheeaterysolutionis a goodsolution.
Soletmestartquotingwiththat, orifyou'renot 100% sure, ifyoursolutioniscorrectoroptimal, youcouldalsosaysomethinglike, Well, I thinktheeaterysolutionisgood.
Should I startquotingwiththatjustbyaskingthatquestion?
So, forexample, withthisparticularproblem, youmightsaysomethinglike, Well, thefirstthingwe'llneedtodoiswe'llneedtocreate a newEaster's offHonore, andthen I'm goingtocreateitwiththelengthbeingthesameastheoriginalrate.
Forexample, 134 Andifwehaven't it's caselikethiswherewehave 999 or 999.
Thenwe'llneedtocreate a newrayagainattheendofthefunctionandthenreturnedthatinstead.
Sotocreate a newexcessofHonorewiththesamelengthasyours, nooneensued.
CodewemightridesomethinglikethisresultwillbethenewYuri, andthenwe'reinitializing a nuri, anintegerarray, let's say, withthelengthbeingthesameasgiving a racelength.
Anotherthing, we'llneedtotakecareofistheKerry.
So, forexample, ifwehad 199 andthenifweinitializedisarray, forexample, to 000 thenwhenwelookatthisnumber, theywillknowthatthelastvisitinthenewnumbershouldbezero, andtheywillneedtocarryonetothisnumber.
Afterthat, we'regoingtorun a fourloopfor I fromgiving a raidatlengthminusone.
Given a raidatlengthisfour, so I willstartatthree.
Atitwillgoto 2 to 1 tozero.
When I isequaltothree, we'd beexaminingtheseelements.
Onthetotalwillbegiven a rayscarRocketsthree, whichisnineplusCarrie, whichisone.
Sothetotalwillbe 10.
AndsincetotalistanCarriewillstillbeoneonthecurrentitemoffresultsorrealresults, scrubrockets I orresultspublic.
It's threeinthiscasewillbetotalmodof 10 whichiszero, andwegotothenextvalueoff I, whichistowe'regoingtorepeatthesamethingonthecurrentvalueofresultwillbezero.
Carriewillstillbeone, andthen I becomesonewheneyesequaltoonetotalthistimewillbegiven a racecarBrackets I, whichistoplusCarrie, whichisoneandsototalwouldbethreeandseehistotalisnotgoodto 10.
Andwhere N isthenumberofitemsinthegiven a rate, thespacecomplexitywillbebigoffandaswell, becausethemostwecreatethemostspacewecreateisforthenewarray, whichisbigoff.
Andandthat's theframework I wouldpersonallyuseforcracking a Gu, accordingtovieworquotinginterviewsfromanyothercompany.
Forthatmatter.
Ifyoulikethisvideo, I wouldalsorecommendmycourseonyouknow, me 11 assensor, accordingtobequestions.
Andthat's theframework I wouldpersonallyuseforcracking a Googleaccordingtovieworquotinginterviewsfromanyothercompany.
Forthatmatter.
Ifyoulikethisvideo, I wouldalsorecommendmycourseonyou.
Timmy 11 a sensor, accordingtobequestionsinwhich I cover 11 ofthemostessentialquotingintomequestionstomasterforyournextCordyinterview.
Incaseyou'reinterestedintakingthecourse, I put a discountcodebelowandthedescription.
Allright.
Thanksforwatchingthisvideoon.
I'llseeyousoon.
Hey, everyone, mynameis y queon I'm a formersoftwaredeveloper, Google.
Subtitles and vocabulary
Click the word to look it upClick the word to find further inforamtion about it