0% found this document useful (0 votes)
26 views24 pages

Array - Notes

Uploaded by

adivaibhavi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
26 views24 pages

Array - Notes

Uploaded by

adivaibhavi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 24
¥ Prray 1s Cueaded im pythen b Frnpo oS 7 medele me py then eee es viease Fee wo) oan cwwiay iso collection of ftems Stored ot contiguous Merrony Saati: ney, fe The idea 7s to store Ma je tema ef the Same type cogethew. This make it casteu to calewate The peettton each element by tery addaling on . offset yo a base valve. Ta emory Wocatien = y ef ETE 0 “fonction 1s usecl on cuviey with dota type ond vale List spe cifred in FES cusgumenty, . 2. append () : -This foncHh@n Fs used to ado -the vale ys Taenttoned fn its auqument ot she erd . 6 the | CuUey. ome his is inction is used “to geld the valve (x) ot we Specified Int Fts ange 2020 @codens— notes 3 ThIS fundfon serrove the element ____ ot He postiien mentioned fn Fts —____asgumert One Hetums fe This tinction fs useel to 4 ce the girst Occurrence of the valve i tadntioned in Pts augoment ray 18 clectasied as Shown below s- @ Prom cuigy tmport Hea oussieey ty pecole, [Tnitfalices]) Q _Austay Name i “STypecode cule the cadet thet cue used to define the Type Of value the aliniey Will hole, = aa i [Representa signed inkeget f Size 1 bylelid > b B___FRepreserity unstgined Tutegen of size. 4 bye ic S ae CY Represent dacten size f byte “ __[ Represent Sel ge | Gee 2 byte \ ‘Represent unsigned thie —PYrebncsan flosing pio of She tye d Representi_flontiog point 6f Stee 8 bytes Syntax for pink an away usig pyihon import aunay BH tore fe fq Oueuptcncd Ra Piet Li) eras JAN : HE SAT © Tmport away nag z sway? = asm Ce. [10,20,30,407) _ A in pg, Will pink element at Frolexo ° ‘P emerdt of ® i ie ee (1) —? ‘Princ element of fedex 4 Q= Aula, poovscy Idode dy pe, a #uhen yoo a te import using eter ¢ y 2 Q= away (d ater type, ale IRE) then yon lapot ey “Hom Quuay ae a Ouwlayt = = auuay (17, Clo, 20, 30, 40f ) 9 a o a 2020 __ esis Sa oat ait 9 JAN : LREAB BH MON Hecate f| the “midi. Sf quueyy usi piton Fo boi on _Faom_a uu Tinpot hemovet me — «© @_ Burayt = quay (77, (10,20, 30,40) ) AG Odsuuqy 1. Hemdvel Yo) 8 For T Ta asuiayi: re ; = a “Print (i) 8 Oe Los “gal, = Can lorm__ Sequich an Aisa element ‘hated on fts value ov es Tndex- Hewe we seach a ae ae th rth en : Tn-batt Tndexl) method, ai ee () from quay import a ios a ausiayt = osmay('7) [10,20 ,30 40,50] ) aS 8) Print (owioy 1. index (40)) Pes a a5] weou roars Heute, we simply seas ign_ci new valve 10 the destred Tndex we want +o update O- from as Tinport a ta ® win t = auhoy ('71, £100, 30, 40,500) — ~@—_cunay t fas BO E — fo¥™X In Anat: a i ms Lod, Ptntias : : 4 U z- 10 gE a ae 20 H# STip t- Whenevew you aue E 80 ‘solving a coding question preter Go” thot the Inteuviewest has asked SO «You that question. Talk to Sorrel cand slowly ff asill jour Habit. Goa Hie a a do_teveusean_cuwauy: Treuative way: 1) Initialize Staxt ard end 7 Pndexer ot Staut= 0, erden-t 4 Ino Loop, swap cw [Stout] with awalend) and chonge! stout! ond end au fellaats ~ @codeus notes a | @coders_ notes] _ eR fewveres Jraas | jag atain |) ire ty te ig wa ecvesos | 35 30 31 —ia Hint ( 1 3 a coo = i Outport: (523, 45,07 a s [4s /4,3,2,2] Ry 1 Qoa2 “Fed 7 —anninammia a —— 2 a on amiay fone ccc Tato dl: Simple Unease = cUnitiélize values fF min and | dd Max aL min imem ad 2020 ae » wretig- Gr cilows Us to cheek for mustipu ._ lexppresefomay Ee za|_ [eoremaa | eT wTFes] | aeserad JAN Jena bea y THU Eagan TMaximum ¢ rst two element segpective, Stenting Faom aha fae je each element wit ek : and | Bad Orel change. Max ard min oo (ives) if “the clemélt is _Smatlen wegutred in Woven negate umbeus fo, begining and positive’ to end with cing tnt — _extra_gpace a Ka auuiay Contain beth fee ‘Negative mum betes “in grandam nodes. Ke cogs a joy clement, 80 thot” - oll eq etive Ny tem _appeas | Bpore au postive _ MpMbek. 2020 & @codeus— noes ‘ores (EH 2 In pet : “12,44, ,-13, “5, -6)-9, S, 1356 x a Outputs 19. y71d, = S)-3) 3, a a — . Nete + Orden of element & set impetont heue 4 Make ure -that all “the negative ‘element _ 7s TI Come before cull the cee elementr _ Code s- i cet Move(ary): Ta * arr. sort a aw: [-12,11,-13,-s, _____Movelarr)- aa eo {foul i ino: Prinr LF) end = 0 | a a “aide? seas (OT, in): pee ae too | co high: - hie (how < igh) ee __i¢ ( (arr [tow] < 0] <0); & Lowte1 . " elif, (ow Chigh] x0): a def. Siegen a for Tin Hange(n): nt (onli), end 2" ") a 1A Hirota f a t _Oyrrs Pryor eying 28828824 6 hss stern Toor} 5 “ue Arran ge (O%, = a i ry n) -g 8-4 -F- 6-73 2222 aw2ty = 32,3 Shop sh s 9 — Uorpets Onien: $123, AS 6,74 ____ Tnteusectfen : fais ted apm cy h follow + » To ef ‘plate m oe psveed are = 5 Use two Index Vasifable T and {, Tottfal vale i20, j-0 2) 4 Sf avyiliy fs Smellet then cuw2[77 then ani lil is qreatey ‘paint aril iy anal Pacuement 7. wn orr2 £7] cen | ee paint onreef] ‘and IncHemort ao ee T+ beth owe Some then pat coy foo Bf hem onl — Pootement beth 7 andl 7. sa “Saint 3 dtemetning elementt Gf the 2020 the _fovge ye See ear ek eas SAT Jip ao at a2 a3 a4 2s @aoders_ notes ] ie a = at ie < arre £7 -———— — Bernall, baeee — bpeeeees ova ope Bite eowegT ees Pa s aes oo While fem: J J a aD Patt (ovr Ci, end = au 2u My = Pcie Ties while 7 avapfys Pont Cave GJ end | v207T_ then inc. ? Gf them & iJ is greater than eros FT. de ed) W 2020 ape Borders notes} eee) Lz ogrom da teal Giabe tte a . je “ —__ Paint ("Given aay ja") Shite ° fx ? fn ange (0, : “ 6 wn i213 1415 Ye 17 18 19 20 21 22 23 24 25 26 27 28 23] N= den (arr) =S wen (UI) Point (arty C1 end='') 34 Ctate ( ary,n) Pont ("\nFotated oway is") for Tih Hange (Oe Print Carr 1], enol 2! 1) Daten: Given awiay fs: "a e23y Rotated array ie : SLIS Gt Win © Thine Cempleiiiy Ol) As we need! 70 Tents thuoyh __def _s0t vArrray (Orray J ae au the element Prilicuay Space = O12) Ore ox (19 taking Aast element — se array [2-1] tokiig element from stoxt fo last second clemet At ony C2] changing «Oy from stostting to. cod avy CJ = array (-1:] + array C1] array > CL 2,3,4,5] L a ape ee 2020 Reine (ta ) 3 Outpurs 54054 [@orders-motes | 4 MMP ____ juan] TaqnguNciarae es ion Liisi 7 1320 a1 a2 25 24 25 12 2 a 38 5031 aovilhim:- Tr Ts an Penative dynamic parr algoPihm, Dt colculedes Saath Si the_maximom_stim Subway © evel a ot th tthe previo position 7 ae Define two-vauiable currsum which stores / Maximum gum endin heue and maxsum _ a Which stores raaxtmurn éum $0 fost. a Now, Frevate over dhe away and ada the valve a aL corrent element to ~CurvSum andl check wk YH currSomn iS vqreaten thon 1 ment Som =o maxsumi 1 eg to GureSum,_ —— a a = CorrSum 7g tess Thon z 200, "equal (70% Zeuo, “rate eon — ee “dep | fname slag sum low) : __ nz den( ____ maxsum for ? In _guange (0,n)s ae See d currSum = Haier atin + onmbis 4 If (coredum > mox Sum) 2 i MaxSum = Curr8um i ee if (currsem <0): a. iy __ corrSem im Letom max Sem 4 6 1 2 Tf name 2s "main": ay prine(maximemSebasutay Sum (L1,3,8,-2, ee), _ Tine complexity + 2 |OLN),, whee cM ithe she of spe Conpety £015 ja = or. teclgmn SThis 3g Fmplemensroaien hi ) hondler the Coxe when OU _ Numbers 1 uy CULL negate. if a ee i Cede s- def moxSub Array Sem (2, atzehtig he ues ~maxSum = aLloy ~_ Currsum = zalol or Pin Mange (1,Stee)e | = aie. _QurvSomz ‘max (9Ci, currGin alt) a Max$um = mnax (max, CurrSum) - sedum maxsum = codexs_notes 2020 i 1 contPavows Su sum fs" "mai Sob Pr ray * eum(a,,Rent®) -wheue n fg the size of ae E oie “gi ‘lintratze the Maxime ase wipes = dee a __sthe e heights Given height OL m toweu and a valve k. kle Need 40 erthée Fnweole ai dewieate the height foe | tower by Kk (only ence) wheue KPO, The todk rs to. mini mans Ai ffewene b]io the ee of the the Lengett anol ghortert tower 9 re 1 Fk oe att he aay, the owen ~_ _ndoximum., ble clo this by cleoueaiPag the hefght a aul the towers towduds the st by ond Thedleastng al the hef tthe “Rusece towauds the L (by k)_ Ct [8 alto” possfble thot the nica que trying anoles incwcore the f fy does ve: ie maxim om height, Theuetore_ =a — he it ort _ky_cempasing Hh with the la land ou ovtpst this chip peuen ce. we only need to cheok Wahethess ft hos the L meters cm SS oe le ll mle . @codeus_motes ee : FEB 10 posuere = ft — Seni an-the aight f sidle_which fs alnI- Ke Bince , is “sorted If + the tower's Pot pean than Cri-K]" Fe itis toler + toweu —_avatlatie. Similay seasening con alta = 40 findlng + he_shorteg+ fowe —_______ We need net considen whewe alt] ck because the height @f towew con't be megative so ait gett ght ee ales + def _getitindigs lento, 21s ant arr. soit) 2 ans = grrln-4] - atrLol = = tempmin = orrlo] : ——_—temparan= ecr (NEE eeaces oes _et in Mange (10) af 3 aeaeeae empmin_ = mint larrloJ+k, avrLlrI z= “ene = ax (om =, arr la-t]-k) =k) ans = min(ans, témpmax- tempmfn) oe nzg avr: [4,4,8,8,2,9] ans = eetaindigelon, nk) ; 2020 Print Cans) Ootpars- < Uh ] “FEB : Mayon numbeu of end. Ex: hp avy [I= | eee eae a 5, 8,92, 6, 9, 6,8, apg GS asaaay He Temp 4 @ a8 thwe ffs L B ate thee opHen epee [f 8 ord is 1___ehosen then! tne end Neck 9 can be seachedl aoe Sa = Sees ve WM © meh 5p Nosve oe preach | Te 40 Stour frm st ebomedit and - eee for ale He elements Meacheb le ie — theme: The iota nombeu 8 7 4 tl ch end _ fre! Prot an be 4 ines 7 usit mint n umber Mee. toU each = Dm aes Tent 7 fd Heachedgle from» irate f zoz0 a @codeus_ notes a a uw tom 15t element to 94 element ao se Ss SS im a ee : @codens_ notes, "ee case v FEB WED pmingomps lorry 4 Cele: yMiwterha. a ee eae minz float (‘iaP) ‘ gor? Fn han ange (Le! bri) Bata toon hed iby mre hee He Od Sa Th) aps floot (Lng) and Somp L«min): Some mpast dies Deven en to kat ohere fenetion aa Or £1,8,¢,3,2,3,¢,8,9, 51 “Tenlérr) 7 elke rt (! Pafnimum no. ef. jum to seagh end, nae Oy) s 2020 TMintmum no. 6 Jomps to teach end fs 4

You might also like