0% found this document useful (0 votes)
86 views

Smart Interviews Notes

SI notes

Uploaded by

aalu.balu12
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)
86 views

Smart Interviews Notes

SI notes

Uploaded by

aalu.balu12
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/ 75
Sut Gee es are deed in ram /main: inemoy ——-~—data pus - y Mwai “a 7 F raqicher * cd “le u Ky the date a [Systane] | a’ pe 1k — 1p? peed 4 4 AM —s 1p¢ | 10% ¢ ax 10 ces | 4h—99 tn | Cl py clock Ci cl, 1 Me! Lado] { \ clock fy el 9 = : mt is 2 cok | abita re) inch uction 3 10 Kf, ~ 0” tnctruction / See ; sree ~ 1014 ingtruction/ “DDR © Uebrlogy is, in s buaphic Processing Unit) Hard lick Ueeconcary memo O€ —Linus, wWindno,Mac fu Cache peehony bbl, Prehitector | ry) Swatie | 3 32 bit Juad WE totes — Abnea — pt UbrB* —> ux eB ae (9p 2 bite 2 Unique vahus (ada, a ts 34 tnig To- D0 a PRE (Physical Addrees Ea bengien) ‘ + Ve oy hit Avchitectune 3a mM Peumal -to Binary [Sian Magaitude d wl preseneaa aes 0 ) i) LD.) C2. a? nA | MoB - | (most Bast 24 ® Addition 4 positivo Nur tabey and negahive | Nucl dives & lover Cinconect eats -lF4 41 © -60 which incerve ct Vegulh, LP T's lomplement-to puree me the problem, | a ib 5 F a . ; Bee 05) 8” ae c MSB sy 32 If : Sa eto | | pf 5a dd 4 a ESS | a ee a) beak s Jie t aa \ as tomplintng 3? 15 ae g | Ta8 Set 22. + Baby ae és ae NY — V4 ’ OE GALT ee ele Mep se) = bite(07) 5 When we use Bytes i Co c++ Wee) (8 (1axy sine Me Wa’ a’ > Smet g) yiigl: bh td Minimum 9 OS D0 + 0. 0. aoe i magimay <1 ! 1 1 ft) ety Caegh i t J TakerviesBi aH i aie —~ leckcode Pelay ~ 10° Bra) ~10' Ed w'poe aia Ma ainsunp Lum ~ Biboise Termary AkA—> OKO —>0 AkA—> IK Ala—> ojo’! 9, Gin 3.540 ee Wea= 100101 aka mero 6 | { joo! foo] ut a= 4 [0!00) aha 0100 100 Chae 10-0 0100 . 000) io a 2201. eal aly 7 E ey | oto | O1roy” o10) a 055) 9! 0 O09) o9mm |) O00T O10; Doo 6 ae “a — ka —, Ak0—p Ak ever e are. ——p alo =e hie Bra —y Arty 4 a" : Wen Am} 5A, tou i i ok ollews tommutatiue and A<¢ociative [ropen O+b~ b+a 25) compueel xb) tc . property a+ lb+ inti by. a + (040 —. pegmanee Imoperty. int powers Tool int N) “ct incuce <¢tdio.h» 7 dot maint > : int We; front ("4.4% Kn), ; acca Ce pewerO! Twoln); } 3 € ’ >i) 5 4)- 4}Z Vtehwin 7 + Hetuin False ik v booluan check Bit (int NV, int iy y Sietuxtn, victwin ( (No>i)k 4)= = 4); i (UW>si) xa)mnd y N=IS ny 008to ol 0: ¥ k24 -6 , int vount.setPite ( inp nz int wunt ~ 0 ; —ter (int leds To al; I++) e i] (checkBit(w,i)) 4 N tlount 4 4 | oe z : vette out ; — | while [Nt =o) | N- 001 Ot ol Oo : : iV(CN& 4) = asd )) | | ° unk +=4; | : Ne Nop digg ; . netroin USunt » N N-4 N& (N- 4) 4 10 (1010) 4( 1001) 1000 —x8) . Ib Cto008 ts (ttl) 00.00 —4(9) S *@ (10010) 14 (10001) a8 (ej 00) 93(tiow) Lo» (10 a(n) Ox N bs power of a, NAW-4) is- equal toro .t ® Fa ech time NA (n—4) wight most fet bib ok osahey ge. yee Il ttoo (Y mAty -4) wr Ones y Zeros ( int 9, ky) t tot value =o > —tor Cint iy; iz (ty -4) 5 i+ aye Value = value 4 (1 z4-(%) um te (aebU%M Balended Euclidian Hai slgnithns , “eee i 1 1 £uclidias Na orit thm. ; a 61 Primary —> Lem galerie tnt albwon (int a wt N) 7 l = link).2 64 +: a wt 2 ne 4 . ers tong poroer - 4; ter ( int }e0; DENS P44) 7 power= (prolr 7M xaxm) 4m 5 | Setwin pooer Sep ; ’ { ptleast (ty e my one ong): 4tbs P woniable “schon ondpus04 Mint a-t'> b- Hackwirank (Baxice) : > Compute axea of rectangle biiusn the Lng and breath of o vuectang k 5 print area of pear { Olea = hog ® bread sLenput format: [ Titst tine input Containe “two positiue inbequre ts < tena bi of ‘the wrectdngle ; and: .B - breadth Qrthe teckanala tonchrainte : “a 42-1, B<=101 L omg wage Att indude 25 AALO = Leb; Ween PIE 7 tay v; beg Qede:ideene tom eu program . verdice: wr] CE] Re| TLE 4 Soci 3 [0441] 2022] B btiven N. Find total number o} cliuigore i (ten = 10") tnt Count Divisdy (int N)T ing, unt 0 5 toy (int “Sart = t—> code wil enecuted tp ir © 345740045 @ 6° 4.0545 “i j at solution works better, — rage Call ; be (%) worst Case: O (nw) NO | ituatior ; {j>0] (N54 N)4 Tc a aD meg late ose ; >Optimiged gl olict 1 for 1 Sl | Canpiiletictorial ( 19! while (4 , can N tint Con i u oh u ements ; . 3 Compile Factorial ae WD) bt Ms +a 44 del factorial _mi(n); fake =4 dor j in range (4,041); fact (act 21) 2M sehen tact tot (in ) nH range tor " r I import . imp java, util.* ; import jova. teats import /4 a. mah * import ju a-U public lay ¢ i publie ttake void main (String ang’) ) thew: T¢9 ; bufjRuade T= mw bafthad ew —Leputtineam Render( ite long [1000901] ; ink me ‘netalae parse dep lr tadline()) ‘Symon uk prin bln lan Im); 7 a isfoalsor» J) biiven unsorted avray wl how tun tlernent repeale Jor fer) twin Caupl or ma te \ j an lo | b Feed 6.6 Hoe 0 yy ~» -fyr( int ! i ! q J a t ‘ Ne 4 or (int fen | \ ‘| (ar tiJ an EI )4 of % ) tount t | i] ( count oY victwin ald ; xOr / ana=0 + opera anb aaab =O. i meee eee Plriwn and N. Compile” 2a! =3x% - . Qt Hones aN P, Ps Po | PN Te A. ee xa a @ P P. cI wots, fs, Py ust be wWiqu e @ | J BEM pte eee \ ie j Eo hi: @ Fa) & Bat) F =H bit ‘i i 0 i “ oe : E 9 ri Bic Ik oe p Sebi y, Pe woot. > 3 f ot NE re ten ia ode! < =(int) 1é beokan Keekel si >) lakde- 52 | CchekBit (arr G35 i Re ie os | (vount % 3 V <0) ] ; i Ee BAw -< =“We0: ') bZ Qe]; os az=-l[axa)% mod b= b42 1 neturn lef main () 1 =int (input (>) for -u range (t) k mapltor, input. split) 7 Computepower(a, b print (ote) th Ne A See IU) int ans -0, m awl); -in (int iso: lem; ita) tov ( int [7% I<"; )++)T YE ANS = ang A(aulijt als); . vietuin ams; 4 ' 0 ' B aA 55,384 int ams =0 ; t- Ai (int int; lem; it adE % Py ans A» 2% amrlil, 2 t 52),.0 Hetwin ams» I 1 1 “bates 6” bit > Pa le axalzQa4 > a ore bit fi Inansg 0x aio : in 6,2" C, a'tcgd + +e2 3I ; v i | vount of Sct laks then Wk » X0R +wo0 number. SoA ee i _ tount of set ans 4 = v W. or s(n Numbers ie jaa veo ge ang ; tn [int cp: (A) " fr (i= ben wt (Kid * ~ aliq) tn a 7 -lor( j=i+ jensj+s) Be f (ali) wl Apsum(int NT (w= =o7 TIN) = Tln-3) 44 —0 (7 (N-2) 4 4) 4 4 = T(N-a)ea —@ Bar(N- 3) 49.5 N-k=! T(N-3) 43 —@ ee For k times :- T(M=E) 4p TODeae = Th) + N-4 V+n-y @ tn) (nN 4 Koy (+ Q+ a + No) tx gta £ o(o"”) OT(n)- a7" )an = weNleq Ns O(ntog.n) OTY)-ar("Z)+4 (ny OT(N)- (4) 40 @r(n)= 1/444 Tla)- c ( 72) Sthocle —for rec widen i— méthocts, Co a Substtlition ‘me aXr( N/ok) +KkN > Tue Ajier kK time a*t(1+knlu) —D SUN. j= T(NA) + TZ) se sample Oulpur ¢ 1g “19D iB 25. 85 1D. Wey. le et » sland with 4 are Lata), (4410), (FS), lugn) , [4+ 8) = 8 tw, 98, 19d. => Lum -fovined with 10 ane (orb) 4 (10710) 4 (10454), lig tu) y (10-48) = 1H, 20,180 52) te S sum formed voit By Me (4 +0), [64 +10), (54 +50) (Sv +), (Sy+9) 2 b& Wy) 108,65, 6o * 5 eum Lpiinéd? with a9 ane (44 +0), lu +to){N FBG) (w +I, (+8) = 15, 91, $6,232, 14 5 Sum Immed with < are (s+u),(8+i0), (s450), ( B+) (848) = 12, 18.69 fib > XR of ail the aboue Stuns = i (8A 1y 298A 1GA12) A 2h te ian (aya 20 ncunst ais) A Oahol v2» Sasim-¢ Tweedy | 0 ? : > Backtracking a > Necloocteio * Backtracking ts algorithm technique {or soluagy Problems Mrecuaisiuely by trying te build a “lution tnvrementally yome piece at a time, we owing these Selutims that {oil te satisly the wnetrainte | the )>voblin at any point a time Fetmutations ancl Combination . SOlHor s > OVIy > K= Sum | avig-T5,-i0; 91% k= Qh 13 + eucry element haus heius @ p; PM The +wo. elements oS vtetwsin Sum = =k; subsetsum (ax,k,n, eum+arLida), ideas 4) I Subseteum (a1,N, 4, cus , ida+1) by rue a(r(n-sea Subset- Pasian nthesis h cub Faun ay , . bli l r } [ N=6 N=¥ Hien N= print all va bee y'5 eee) PAXanth wi in lenivag 2 ((09)) Mey 383 order Be 0 Fy 690.2) PeLi> ¢)) elf Aenicoaraphical rider ben ())) —_— oor ace "Yo. puk (’ NG €C <0c _, put'y’ Void qn Fasanthesis ( chan a4 17, tnt N, tot ida, int Oc, int co)P if lider NIT Prt (Aiy1)- a , , (Mtetorn ul valid a : ; ‘| [oc< NY a WET mivogra phical ; Number WaLiday =") Poutar thesis a , Nn, 1a+4, 0C+4 »CC); ToDo if auTidas = 'y be Jen Paxanthais( ann, idasd, 0¢,Cc +4); 4 , 1 nun USF ta, J You ane given input malra . Find minum nrg V Commute in te Magic Square d 1 buenerale all Pow @ For cack bil = G oi 4 i fe ii, r ¢ mar dor (int j "a Ahonen | 3to} 2025] re Smarticterwier Oe . he tSmarb, ¢ mart gm, inter, vi L » Sm, ler, views | interuiewe 2 d check ty Ll iss POSibk tp fem 2 ~~ | way {om String using L 9 Min de i. : J boo! l inl I th » endo 4 ind + +)5 2 Vielwin t Setter False ; of O mH ont Vord / > Lnlerleaving pC [ptr sje BI ptray) x utes [ pr &. fo (sar, lenglb-4; i>-0;i-3 1 i ee stn (jao. fei sj a4) ; s least = cu Ci); { iplartjd > least) : oS -tor (k jo kK] k=) t ar Tk) = an tk-1] i a arly? . least ; t ae Eg*amyple : 10 30 5 60] 2% o t a arlj]> ay Ci] i a-alr) me: *4) i arti] = all; ie oo 8 4 alj) = “temp ; ay 6 up a BO orto i EF ded 3 |< ar.teng si++) Sorted tinsorted Cin ; 4 tor Cint j= i- or 0; |-—\am t > swap (ar, | i) s 7b VOR Aheca tion Sef (Bey A Void ineertionSort (int arld) 2 while Cant Nr N=ar d anTi +4) lj es J 10 39 20 6p ee atl | if (arty >ar lil) r oid insertion Sor (int art ib or An(int i-35 to int temp » auTiy; F nig ie oe a! while s-o 4a an Ci)» temp) t antit4) . ambi; t 1 ez) av Ty +4) = berop; 4) Th e v r r—» Cadiclate ay 3 5 5 tae a, g—4 oretum g Te Bat OC Mane) int wanVotcs (tot ct], nt N, int MDT imt mancnt=0 , ant ed: tn Cint iso, ie=M, 14 OT ink cut=o ; tov Cink fees jena pHeT i Ci= 2 alj))it cu +t); ui ° Lae as hares eg Ss 2 ee Be oe oe capa are [o te [ int meagvinner (Cnt arf), ink N, ot mM) int cl f- new int Td: Fore fot fap; tem: i¢t) elijzo, ink maaboinne (int art], int n int cl] = muo int Tm] ; tov Cink i-0; icm: ite)y Cli l=o; ie ak id r ctor (int io) jem eet h ( Ti > many ‘waa = CTids e One. F ue wduin cans; is. AGrnunt Loris ) Coumt Sort 0 1) 2 en 71. To am’ [oTs | 4 | t[o [s]o f E "i + 3) 3 Oe me! 2 8 ag 618g Sorted Leet. pe : a Void count Sort { int AtTd,int N. int m) 3 ; i ned itl], "+4 int Domes _ 7 for { ic me itt)y -or( int i-0; iemsi4e)y ibets sored blalitj++: 5 ercating count “ad + mr t-o; os Tims, terCint isteicemm;i+eyg > ™ onal Cit indice M144) 7 OCM+Ny im @-bTiJ; Cn Pe) las a lca alt ata i Em: a--'0 b=0 he (b-a +4) cable} * ~** gta m / ; cutlij] = -4 | cat [b-at+3) = 8 catT a 1 2j g ons Gam = ent [1] = 0 8 }asfocloors) merge fork 2B Menge. vtw0 Sorted, pink -un Sorted cadet meee Ik ig Be ore Mm -2 6 4 9 ; Me? 8 hb lk a 1 ig 2 Solution: | Gow Gite * Solution]. ty, (4? + Imilialise the aviay with ee inn Then. vopy ‘the elements jowm aT Cs } ‘Then use a Sorting algorithm. is i : ce CNM)", Nt 9. Na (NxM), ney cepy err 4 bir es £ ss) ' Me — oe Bis c Time conplone algorithm I Tech nei ue) GALT, EN, ing bill, inkM) int P41 -0, P2-0 ,K=0; int CIn+m] , a while ( p aoutny eo : > Void merge (int 1 Using Tmserbiin Sort, with the es : ' ‘ vile elee T "7 i AG TRe ST © py TP, ++]; Clk ++) -antr +e), Ss af =< antmtn] « 94 “br imd astae 69) ad) tH Sata Me Li apt. Solution: yma (m4N)%, 4 4 Copy bn ia rs|es|e¢ | O (am). wi @s Nt, Nam | ; 7 . te ‘ o : Cepy avi tec -Tnsesting bo lo pointere © elemenlé in ¢ °, ! SF ta tt aaa) 39 20 a2" on RR Pe “a - oo See 4, . 50 K=N+m 1 i Pye N~1 decremnenling porters S, i Pa=mM-4 by qetlouring condition 4 Te 5 NIM, 4 = Grits Bihary: way. BO ee eat i yt By AMOUR! 5 5 | cay @ii Meemoeely oo |, Such ‘that the Se eel Should decrease {rom nN Aolution:@n?, 1 [optimised @ y,4 (nta 4 ee I, Ts] s¢]B¢ Crk any Thane i arting Technigua. | Travesee Tae a ~*~ iY > bount => Count Sort: @ 0 taking +00 pointers in fucha way, .. D Py | th tt | ee > s ary | © Ooh’ Or Ota) rf Pointer 2 f ) Pej *P wilt 4 axe about O ie» it waith hebpilg oH ent, " platy them wv auiay . i bout 4 hey wall balp plang them wu auay TendJ. | q 7 { j ’ ” | ‘ n 999 t nN 4¢ P, 4s)t £ wap [anle,J, an lh, 1) ‘ Py ele (avi Pod 22 47 Fos =d3' ’ leit Cowl Ad > ary thd )4 ewap ( oulA), vo TRI); 1 ! Wy ( Find tount pa | lq: & , 4 } aX ( 9 i. 0 4 (u,4)) 15 le 10:2 f On Output’ Cant '- 23 wuntso -4 o ee ial » V : y iO” pein ‘| (avilid >a tj1) Solution « ) ye tort +0 hima | 7: Fc sola P amen <2 wale toe .g ; y at Ss 4 ty AR ani ee Aa 2 5 00 9 2 oid , a ‘ " Ny Lad, hie 9 \ 10 J t pan ay wh 16.47 et is 3,1 9 4 sie Sa Sig oo ee 3 / a Y > Ss £ tate (8.47% J Cea Z x e fo) : 0 > Void ry dort (int Only, int +19; oo hi, int NE 1( lo == hi) 7 wietuan 5 int mid “Cori / amerge S01 Carry lo hid , ns; a» T{NZ 9 ) amerge Sort Carr, midts, hi si ~ yh hex merge $B (aur, lormid midi, hi), pr. ist merge co ( 8, pos | TC)» eT ea OE Cr =a ¢ avi [lord * oer lo 5 midti=& ae. . 15, 20) ctempr D9 6, mid - 9 hix 4 lo J BOE 09: Cae int terop'| hi-lb+1J, K=0 5 | tf Cart Leo <= au Ixy ) ALemplk++ Je awl tow+s); | t else T | “emp k++] -oulat+)- ) % = veid merge (int ait, int lo, tnt mid , ipt hi) | int temp Chi-to+a); WE a=mid+4, k=0 while (. toe mid 44 Hehi)7 i[lan tog <- avila) zx -lemp [k++J> an Lo+ 4], or l £ deci Count += (idl — lew + 4) : a alate), * = tohile (9 <= mid) Z errno cs Lesa 1a wohon even -the -f 2 Simplified Maelere Theorem: Tlad= 21 pln) = at (™%)4 ab +a ae AG) = ue 7 Od cot o(we) oe tog Gh cer o (wt leg) ee aque Gi) cee OCNE) undion is in wecuytue -tuoction we use “mackere sheorenm” ae ee Seecion - S 4 wel 5 Stu of tio no'g Given” 20 elu Be t Oe ee Tuesday 3 15 1 oN 83 : B ouule f evee olution : ee -0 1 <|f lee # oe DN 4 or [ J 1 A ength +7): ' Cilepp ay: corked am 2 << ae Y(alil+alj1="K) yg 3S ee vteFuun the; [K: 20 a / vickurn Falee; golution ; Two pointer > 9 Nleg N+ Ns Ny mae a 4e:q int a0 —— “Workihg &-Poinker, (erate tba malh-4 : 5 Zend o te arnay. tohile sa: “A ‘|latal +A[b)==k) iteration, a4 victwin. Torus > > Bi bead siete! ae iteratim : 1545 <- 90=k = return serie. a + 182k pe Oma Mie mie gh "y ot by defa in 2 Wty! & ©. 8, 1m iN a #5 ae a | 3 38 56 ag 41 | | ki a3? is . De F Phreany sensch ) few - 0 ! T Therative J | highs n-4 J while (ee. high) sold low + high rz autted IM katbmids VC : maid a wetuan mid; elec i ( alad] > key )E high = We sa: | necun sine] & ; z eh tnt BS| int ania, Ut Tey ew ditah= mid +4 ; ue Oo mid + a i boosie ) | “ we bun Nebwin -4 y - e as Tis) = at(n4)4 a annua wusive Master ¢ Theorw t(N) . (NZ )+4 insorted arr unsorbed an (0-9) ee arr : (Q= _(a-4) J earch ye nay ee si atiisty., Nlog n+loqne4 NleqN+Gaaa loqnaQy i i ; z 2 J2 > = : carc e e — Df q Nad 5) > i ra ‘ ; a 3 6% > S ar: 12 8) 4S 6m int lows 7 i j int high= -4L i mano tohile (low < high) Tit mid - (ter0+rhigh i (an [mid Je: 4 We aaliated ‘ . t QO sort Cary i we ist low = 0 phigh *N- 45 ink as = INT min; while (16.9 < hi h) x lok amid = (Crew thigh, 3 ae | i (a1Tmid] ey ang = anlmid]; en loudel Vs toww= mid+4 ; é else i[ Can Tad J==) 7 ee mid J, Wekuin ame ; high mid -4 nebwin ans U 2 — alitd+ al) webu 1/ fF ~ ant J BSR( ano, } -4 yk-an tj) or MejtaN-2,K-arljl) POWN 5 10 ¢ IS ~ BSR | 110.10 -2.. (o> inieng a aaa Qn, i peiez' — oe 0-2 16 3 -5 re i Q = a<-anlil <=b eee al ' Bereinhs sn gue | 224 oe 4 CLT pra 4 eo CCITT Trt . > populate cat ay ia | a wa Sprotunt(a) oe oe) Q + to 424 w 4 Soy @ + @ -5 -5 -2 3 10 10 10 10 tp he 15 4 12-0 Desi ee PES (i) Sort usw ] merge Cort 5 ee Ci) Using ¢ oe dina 9 UW rom pe 1a mous elt wight te updalt nk of. Bt: tew-0, high=0 intr, --1) tol wlan: niaga <0 Cased, N while ( te high he Mar pe ee merge Biman amid = Yowi( nigh low); i cal tale . 'f au [mid] -=@ e me ede \ SP ‘ = etn amid/_ nea? 9 low=6, hig 4 . i hie id= LY mid=6 4 elge if avi Laid ] >a ae high = amid -4 3S Demia Bs, 3 ection | if Cour Pri] =) T NloqN + wlio + toy pa=ouid , ; | tow = mid +4, ie | Occunene Decury ase i] C at [mid] >a) | high-id -4 . zg alee 5 lew =mid+4 5 7 $ . vnetunn Pp, > y ® Pa bo ihe 1 n 12 48 . OWN i -6 -5 -2 333 3 10 t0 101040 toa BY y v z | Pid = 5 “a 4 N+NH [ RYN Y | eb 3 Bi is Ms, ( Sa NleqN +1) +a v Oh Puy, 6| elerse Ae es distenct elementi is ae Two pourter . cio Sort The qitun arvcay Ads W) ti tie Covecuys Al] Hor distinct 811 [4or fovequenyy a dlomuntel. C © pal eae, eRe eis 294 0 0 1 oe a. 338 10 0 10 Ip lo 15 1§ Be 3 e Lerneris] 2 C2 pointers) | lo 1a 15 20 3 mm 0 © 8 oe ie be mm Qu: iQulorbing ancy ® se4ing all the queryits i» Am. ‘0 copy Qm to Sriqunab Ram anny . '® gort &™m ‘6 Use 2 pounter to updati tount vig ) US Oviqinal QM ard Be on gw qt tnequniy. JlogN +0[n 4 Ni i Q(N4+n4 NlogN + (cq) r | f / a < gN+n+Q. 2 12+ N+ @l0q mj af : "bee ot ut 1y¢ TWO poind 1 Twa (1, ' pomtue mi Hach wv | Hagan eit rar Hashn ap<=()) Prt . Hath “gO dictiong Z 2 mi le thi : a i mid % » ze[s Mid-=4 cli, arr Tiel) to-mi : alta} 2083 Tsatwiday J [session - 44] ; > Gran job ichich hae been diuidd ile vi tasks » Each takes g; Secs te tempi .& workers cellocated Only Continu take. B worker tan work on a Single task ak ; qiuen point o time corks pasate oD Ailfeneot tasks Minimap possille time to empl Job Each Worker Lan take Lontinupiy +0rks workers kik y . Oty, ! uo Ss | he Sh 4 3/6 1 5 . Pastis: — Ib 13 hi 2 Stag : ‘i . Sum { posite | al ‘ © ans «mf | ( back Hacking ) a int gans - INT.MAX; / qlebal ane Lees | veid sa me sink K, ine ide ink wn int cong) 2 Woke aA) T ‘ . | | Sum =0; Ma viz na | for(int i= iden sTeny l4a)T fi 4 ‘ Solution : Sum +> awiliz, ey 4 Cang = maa| um , cane), © Na K-1 a 4 gaps > iol cans, a) g ifGda = wil 35 (valid) a (vad) 15 (wot wali) 19 (valid) m 19 Ib Cwok valid) 4 q 1+ (wok valid) # “4 > mid) Ee = rE valid ant s éo IX 18 14 1a a3 a0‘ Bea : 7 a T 2a T | pi ‘i mA 13\ ralec a ; {9 min (ans, | Srna); 10 bed aed tx , 40 4A, BOR: binary Seanh). 7 Be ydid (au, Nk» mid) 2a (EMME bs (int coord, i by OE NDT as jay . it lo = maalav, hi = sum Caxw) , ans ~. wohik (ve < hi) t int mid - (loo hy , i Cwalia (a1, n, 6, mid)) L ang smid} ta Dr reas, cs int k, ib md 7 Pky kis ent- 4; ter (int feo; den5 i++] Can Ti] >mid) wietwan Fale } re += anni]; iC Sum >mid)z Cnt+=4; 4 Sum awtiy, x x > i Le a (arr) meant = Yletwin Cont < k) 4 gf s Ken Minima possible Valid uncon > u've N houses ard yeu hawe k stelati | houses. Minimum chictame bebo le as large aS possible v © pultog. pointer at cai : ge N ‘ —" , géplution wsing Binany Search. alow von be an loj Ttow = an loI} Gor) do abbetmid)y al > Median of no(@) ake aways: 3 Det 3 1B al as 45 6 9 zg Byb@-o % 8 fh -20 99 a5 tc c Nm —s odd, No duplication A Oring” Pp 4 moe ae me + tg - 17 10 " 2 ¥n Pee 2 yr ID Ig 13 16 18 20 21 aQ a5 aw oo iy Solution. CO! Ss th 1% a) a8 45 DN+m » Neng ereae se tf x Y 2 13 16 3 8a a5 *TwO pointers ia ; 2 Varulab le * By using ! by using Cony pointes twhich tnt and _ any COmpaste both avraye 2) N+nm 4 . cnt BI YUL ST yy ae . < v * using Bina Search ‘a mya ( id= Q 23 lex (hig 1G at i . a Pte “. - 23 ds loo +4): é fae tin Sp 4 si aid atten legsent U5 a3 lay 3 ine a4 QQ IF g to Q | a aa 12 i Ag 3

You might also like