0% found this document useful (0 votes)
21 views25 pages

03 DSA Spiral

Uploaded by

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

03 DSA Spiral

Uploaded by

Sarthak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 25

Notu

Totel purt 1330


20
I336
nates
o
1330-|300= 30 do it wng Suvteh Case

30
0
36-l0
(int (peuer la,b)
Jutum yhe Fun dhon hWarne
tuk
etun ow;

int peun Cnta, int b) {


Int ans =lj bud tey to Jsunt
or Cint i-l; ic-h; i+)1 Cout ce a c<ond

anchon doau
tuncthn ke Vesuebles
int meun () Ro aecs nh karsakt.
int a, b
showo
it
Ceutc peus (o.b); but heu
be
c ,b.
ant

beol is Even linta)


Wodd

setum o;?
2:(1-2)!

#incbucl iestuam)

int tacteical (intn)


int fact - |;
torlinti= 1; ien;){
taet = Aact t ;

int nCa lint n, int)!


fect trt tutorinlln);
focttot tt acteuicd ) ntectoval(n);
t an mum/ dememe;

int neun ()
)
#incudu (iosteam
lng xnjaca stel; ucl to
e dod
to funcho
inondig
ton Cinti-) ;i<=n;it)
uhems Sttemant use
kan sakte h
witaut any vale
nt men () {
int n

Bume Net
#incudu< ibstucn)
lsmg namesjoct stol;

ton Cimnti-2;icn; it+)E

int mcun ()

4lnBine(m)) ondl;?
" IS ABrune No.'
Covt ee emdl;
sun " Cl
Cout <eK NoT A
Füncton Call Staek
þum no code (houoteu)

uten

meun()

tact
tactebl
Faderèl

mcun() moun
meunC) manl)

Frctoial

Sustio maln run

n tom

’ total no" set bit in akb


a=2

Fibomnaci

n Fbonnc no. : I2 3 5 8&


Foche Call by \/ale

tncde (ietsrav)

dmmy(ut )f

"dummy valeon'enteenl',
?
nt meun()

Cin )n

Cut le n = '2 n

'Output
dummy valu y. n=is bamgayi

n ki valee (5
mauh
karsatta
hou iske soh koi oedehad hti

hcunl ) Aomny titn)


heete la);

ud t

ind ufolte (intu)

Hutwen a;

(nd a =(S,;
u,dak (a),
Caut kca <lemell;

utwn cns

updote (o)
ARRAYS
ge data in
(etiqugus Memery docahion

odden is odelus
that's wy
* Thik is callid cortiyues mamey Jocation.
doratiom
’ Index (sed to
te wse

* Mustihe valu f Ainlo deta yhe uguinig mulijpd variobla


con be oterud in a ingle vaiohe wsing y
Delaration

stods

Subheac
boe adeey = (00

adesus = 100 + 4(o)

adde (00+ )
(108
oata
a-)
nullndd itaiatie
mt mumber |3] =4S, 7,121
(5 |?|n nlme

wm he

L Al wtel be cotinirg

int an Cioooo] = (oi:


toi; Ony howa in case
olololo

Nethoxib

How to maku it hosible?


dame velu ?

ind onlisJ - (2,7:


(nt n 15}

valy
tws
oly value5
s t hemong
itialize luyil
h e2ERO
Fly odh fumchy

nt e to ratutate tu

(an be dtonined.

Ques

auahle

bhtja Pactia
Betten
lieoo:l;
nd
t max = INTMIN;

Max

sutm max} 3
ind qt rin "a], ivt n)
t min = INT_ MAX}
torlinti=o;icn;it Can be
liniatel by brsdlied
Luneh'on
)
tubm un
ivd main (04 mini = min Cmini, avyli);
Jo dhote hoe
hogjaygo
int an );
ter (ivt i= D; iln ; it1)1

Cin )a[i]
Cout (e endli ?
Cout cc Mevinem
Min emi
how mcun
1,2,
3
sulol
be it hut
3 2720
(an,3); update
haek
te to
mu 3 2120
timeton Trsde
he t13-{,2,3}; asn int
Gutbut
1(0
men (t
back gong
tohack
cc t
emdl; "
cfneho meun Cout
=120; U1lo
indn)( l], an (mt eyscdate veid
Ciostam) clucle #
emut all
Sum hunt
be. em
hers m =5sipe
hou' taha ypclak
ho
kinahoj dja adrus bane hla unchon
ko hune
hlok mumoy
(ans,
3) ufsdak
Punchon
au
Sd
pdede Rucuon
Linar Seomch

indo
Ry 12 2nd 12
chuck he

kya ye equal hou

#ineuole liostsuam)
namahace ttelj

mon l)
int conlio) {5,1, -2, i0, 22,-2, 0,5, 22,13;
Ceut <<" Entr Jk elemen to seateh on " <C endll

bo ol tound sewrch (a, 10, Ry):

Elemnt Feumd"<endl'
,53; ,2,3, [s] an
2/ 3
4 5
?Put Out
it+) 4=n; (inti=
0; Aon
n)4 eserl,
ind (id pound VeBd
sttt+;
emd)1 stt- whilel
=) end int
Cintasn3,
itn) suoe Veid
ciosteem) ced jn #
stef
enel- +tStet
eld ) Endirg obtet (stating qwah+ Nyo:
Staot
3456 32 Sq
2
2 3 S C
3 2
cbsowcchon
no
odldl 9 5 4 3
9] ,5, [2,3,4
Ruroue Quation
Cn
Rrchlen

Ateonde

elmts

fonl i’ 0s)

Auoaf (antil,afinD);

#inelud <iestuam)
Laing nams þau ata;
vecl puintAroy Cint en , intn)
fer (imti-o; i<n; itt){

vud swapAstay (int arl], int eize )4


tor (int i= 0, i< siz;
it=2)
suap (anlil, enfi);!
22
ind man 0{
int en 7-{,2,3,4,S, .4,8};
jnt odd[s){,2,3,4,5!
Suapfvauy (eutn, &);
sinilandy Aunt Aopay (euen, 3);
52
/ now ettt tomp- 2

Yau tawe been guen indegun amay /dist(ARR) qsize N. whue


Coding Nes equal do [im +1. New', in Je gien ay uat ,
Ninja

Sample in buti

23|6 3 2
OPTIMI2EO SOLUTION
latatia Bute toe ng XOR
lemt Joh same che ko KoR
2’ 2 acta hecu
3’2

a wo
Cnsu hau'
elmnt o ne

nt tnd Wniqe Cint Hoch, int si) alady gia


IYt an =0

ton (nti-o; icsihe; l+){


() Lut rodl 1207. Uq Number Oee

Lut od y42Find al Dujslinteu in am


ind duy dcte chmeut
4tind m n

t233
3 12 3 41’
41 lelmd ramging rom I-(51) =1-4
I2 34

’ for lind i- o; i< aot Sia i++)

found XOR

|2^3 ^y
Intereton twoaays
AHeeh

fon Cint i o; ic; itt){


ind clmt cenl iJ;
fer Cint jo; jem 3j+)4 ma ebnuk
ebrut matchu)
Orss puh-back (elmeit);
Coon 2 = TNT MN; it will bush ttat elat
bruakj

Ualu Jo theut t will not


gut mafsed agan.
Logje is qoo d but ojraat
dac to TLE .
2þointu Apeoe

stete in eto
17 incude Cbits/stdc++ h
(in) nel Aooy Iloachn (vtor Cin&anl, indn, vetotnPar2, int m)
veta
IIwute codle hu

colh'sn
wtilel ic nkk /<m)

ans. push back (osoltiJ);


itt jt; 1

Fain Sum

To ereeudte this
tye trawolal
4
|+4=S
2+3 =S ’ 2,3
wetor <yeton (int) >and

Por ( ind j: i) J
(anti J+ amlj7= s)4
ton <int) tem}i
tet puhbaed (rin lom liJ, ang );
tmp puohback (manlanfi,alj]);
an pushback ltemmb)
3

Ts metoh ame cendtom ie


Rum te st

Tujplt with Gisen Sun

5
tor lint i-0 (n-1))

k
for( int K= i1 -(){
234
a 35

2 2 S
Count
Sihg trayal.
iynene

Tuse tihey
nloyn

tue fointe approaeh : -


ototo

teriiae loct

You might also like