Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
35 views
11 pages
DP - ClassII - Notes - 7th June 2023
Uploaded by
Sisir
AI-enhanced title
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
Download now
Download
Save DP_ClassII_Notes_7th June 2023 For Later
Download
Save
Save DP_ClassII_Notes_7th June 2023 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
35 views
11 pages
DP - ClassII - Notes - 7th June 2023
Uploaded by
Sisir
AI-enhanced title
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
Download now
Download
Save DP_ClassII_Notes_7th June 2023 For Later
Carousel Previous
Carousel Next
Download
Save
Save DP_ClassII_Notes_7th June 2023 For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
escnty ez— 07/06/2033 a Ofn_change problem (Leetcode 322) f/p> coins = Cis 255) Qmount = 12 O/pa 3 (5+1+5) © minimum no. ef coins thave te yetunn -i. Sf we aut notable +e make the amounts we Sn. £ — which 1s equal +e the «): calls —_— ee cofna and hence” 3 cotys ma Fhe. for each node. We ~ a a Can say thot we — ‘te Mun on for Qoob Pram “0 to ne a Ico/ns + _— Dry un 7 Bt is Import ° om Tamount becomes O swe hove Succers, the — — . . & stove the ‘minimum— prsSp—Sel9s eee ny vuaiicu wiur vam. \\\ \\\ classmate coins > Cl>2I itonget /amount = 2G) 2 Overterpping. - ‘ubbroblems 1S) iz _ Coe ES (Oy OF G5, OTE = @) €)* _ Store An min Tin — Store Min tien Recuoalve cast —for cach anova valle CSimple Sor fook pobesn) the coins antay. [Lf lint colve Ree Cvector
4 ovaiiicu wiur vanclassmate. Date__~ Bese. =| 3 a xyetwin minis 3 i (vector
& Colns s int_omourt)l nt coin Change. Z Cobh. Xha funder. : 7 int ang = solve Ree (coins » Amount) (f Cans == INT-MAX) xetuin — 15 Directed by question wetuxnnh ans 3 3 int Solve TopDown. (vector
& coins s vin amount, vector
4 dp) f if Camount ==0) setunn O 5 if (amount <0) xveturn INT-MAX) WSkep 38 Check if ans olneady if (db (amount | = - 1) . yetwin db lamount]s fot mint = INT- MAX) on for (int C205 (
dp) 5 — / If Cans | =ZNT-MAX) F 3 Mint = min Cminr, |+ans)2—~ z Y / Step 2 % Update tn_dp Gray. ovanneu wiuramclassmate. A 4 Ap Camount] = mini’: _ Attwin db Camount) 5 mk __|ine corn Ch (vector
& Coing » Int amount){ WStep |i Create dp asviay amount chaaying in. vectoy
db fone i, Int_ans = Solve TopDown (colns, amounts dp)s if Cans = = ENT-MAX) webusn —\s _ Wetwsn Qns J Te = OCamount) 3 Sc= Ol(n+n) [iit ttt [Bottom sup approach CTabulatien) aa We need te Bnous—by which valus should wwe linthalige the db away here. dp arian 4 1 kontainina minimum no-s, coins 4 hence store ENT —MA X_jnitiolhy lint solve Tah Cvector
& coins, intamoupt)i- W/ Step ti Crea dp wunog “veckoy
db Camount +15 ENT- MAX) 5 WStep 2 + Opsenve hore cane et tob-down Aplo}=0 4 WStep 3% Reverse fpow fn top-down obbyoo/ | foy (int rats (2 =amount J cee) t iG - —— , - Sorat Fox (ink a0 1s ce0ne Sipe bhi a : : if. Ce~ coins (42 2=0 Kbdp ee coins (4) |=INT- MAX) ~ i : i. =a (c-coins CG IJ > ap Ct} = min (Apt, Itans) 3 7 M(t il fy j vvuaimicu wiur vamclasstate Date, Pege a, 3 — 3 ; — retwin db Camount Js 7 5 =— int coin Change Cicector
& coins s int _amount)i [nt_ang = Solve Tab (coins s amount) > if (ang = = INT. MAX) yetusn —( vetuyn ans + 3 Dry sun = coins 4 Cis 25 5) amount > 7 ES 212} [ale a a OE ee dp Co} = 0 negohive index Ip C1) = min (+l, xXx) a2 g Tefahive thdex aa laplad = Min (itt, 0+2, xX) = ZL __ b(3] =min C442, 441, x) 2 Q _ Epl4d= min Ci+2, (+1, x) = 9 (5) =min (Qt! , Atl, 04) = 4 Hplé) = min Ctl, 2+), 1+1) = 2 Idp(D) = min (atl, I+), /+/) =a : Zz Y Fina answen ~~ vuaimicu wiur Gam4 Ap C4) = min (202 ys 2) U x 7 go ere INdex berincd y > go two index behind 27 9° Hive index behinck Coins size © Ly | OCamount X_N) OCn) Tc sc Space spbimigaher—— Hene Shace a - is not possible as Ab (Ct) _clepends en. ea C= coina j.J] and coina C7.) 18 not_a extain value. Here we canst a a - _| woblem. _CLéetcode _198) 4 ipa Cl, 22 3219 lp 4 Ct3 =4) | A robbex can?t xob_adjacent houses 60 sols ight Wie have tox ebush—Max! mune EPS ~~ Yobher can. —tob_at_same_nighh ia [3 [2] include (exclude wii L [2 3 2] exclude includ! 3 [t le p p E] oa scease cone) £ S — Bc —svarmmen wir van 7 Ceinclude 3 2° moves by 2 inde sc : exclude 7 4° moves by 4 _fndex ae Recunai Co. \ Oe int solve Ree (vector
& numa, int nt Z/ Bane case i Invalid howe A hence nolhing if (n <0) te stead o yetuun © 5 if (n = =0) vetunn numa [Co] 4 U Inelude casa. \ _ — Int fnclude =nums (n) +Solve Ree (nurs, n-&)5 _ xclude cosh int exclude = O + Solve Rec Chums pati ; vetunn max (include , exclude) _— int vob (vector 2 numa) f » int p= nums- Size () =} ee xyebunn solve Rec (numa, n) 5 3 S te ee S Tep down. abbroach. ‘nt _solve Tc op Down (vector
Bramy nen — vector int2&dp) £ Bare Case i£ (n
2 numa) f == —| = | = num. PIP ad ikea Tn *retaraton — — : —L__ vector
rQacl ol J : — Lint Solve Tab (vector < int > & NUM > Int. n) £ a — Seep ts Crea. ap amare will wovk wilh IE “vector
=0) —_ temb = dp Cr-a05 a Int_include = temp tnums Ct’) 5 a int exclude = O+ Ab CL- 195 dp (22 max (include , exclude) j j vetusn db (njs 3 Int rob (vector
& nums) ft int m= Nnums-sizeco -! 3 3 yetuun solve Tab Chums yn Jo 7 Te=0m) Dry yun a bums [2]@] 3] 2 J —_ ot 2 38 j __ (t(] + money eauned Coming up te im howe _ N= 3 __ We have te creat. dp pe 24 ea pS ata Ta] 022 2 -s IdpfoJ = 17 num Co) (Bane case) aa dp OJ =max (2,4) =2Q Y 7 o+dptop a O+ Mums liz 4 (2) = mance (1+3, 4) = 4 _ temp 7 7 Corapriy _— Tyre C2) ovuamicu win GamY Z Zemp Space ©, \:\) ay dpl3J =max C2 +], 04 4) = a C ophmigatien ou dp Ct) dependa en _dpli-!3 ond dpCi-2)- Hence we can Simply dewith the help 6, 3 —— x 4 ap l2] nue Cay nt Space Obt (vector
&numis Ink nt : int preva =0 4 int brev| = Dumas [od + Int cus = O + for Cink Us 1s U4 sneint) £ CUM = 3 (ano Ske ne cee Tnt_ temp =° 3 Pare er | = a> Op CH) int extlude= Ot pveviy ma> “Cinclude , exclude) 3 / r dfdty 2 Apl-37 — p=prev2 2 fear emb+numa Ces ) wevl 5 BESKOKds)) — | x etusn prev ls ——————-= 5 3 eS Sc = OU) | lng breva = 0 9 prev) = SCE ‘uo wit VainClassinate Date. Page | include = 2 exclude = 2 Us = ob veo breva-1 , prev! =2 temp = + include = 4 exclude = 2 Cun = 4 £23 prevdQ =2 , previ = 4 temp= =2 Include = 3 ee 4 Cunn = 4 Nour prevd= 4, eae meed te netunn 4 & hence we Scanned with Cam
You might also like
DP Notes Aditya Verma
PDF
No ratings yet
DP Notes Aditya Verma
104 pages
DAA Elab 1
PDF
0% (1)
DAA Elab 1
127 pages
1
PDF
No ratings yet
1
8 pages
Dynamic Programming
PDF
No ratings yet
Dynamic Programming
47 pages
DP ClassV Notes 11th June 2023
PDF
No ratings yet
DP ClassV Notes 11th June 2023
9 pages
Dynamic Programming
PDF
No ratings yet
Dynamic Programming
47 pages
DP - ClassIV - Notes - 10th June 2023
PDF
No ratings yet
DP - ClassIV - Notes - 10th June 2023
8 pages
DP - ClassI - Notes - 3rd June 2023
PDF
No ratings yet
DP - ClassI - Notes - 3rd June 2023
7 pages
SDE Sheet by Striver - 240502 - 085409
PDF
No ratings yet
SDE Sheet by Striver - 240502 - 085409
58 pages
SDE Sheet Striver Solutions
PDF
No ratings yet
SDE Sheet Striver Solutions
58 pages
dp-notes-aditya-verma
PDF
No ratings yet
dp-notes-aditya-verma
104 pages
Dynamic Programming NOTE
PDF
No ratings yet
Dynamic Programming NOTE
18 pages
Dec 13, Doc 1
PDF
No ratings yet
Dec 13, Doc 1
28 pages
daa-elab-1
PDF
No ratings yet
daa-elab-1
128 pages
daa-elab-elab-soln
PDF
No ratings yet
daa-elab-elab-soln
128 pages
DAA E-Lab
PDF
No ratings yet
DAA E-Lab
25 pages
Raushan Kumar - 22scse2120040 (DAA)
PDF
No ratings yet
Raushan Kumar - 22scse2120040 (DAA)
18 pages
Array Level - 3
PDF
No ratings yet
Array Level - 3
16 pages
Week_15-Learn Dsa With c++
PDF
No ratings yet
Week_15-Learn Dsa With c++
21 pages
03 DSA Spiral
PDF
No ratings yet
03 DSA Spiral
25 pages
Computer Science Discrete Mathematics
PDF
No ratings yet
Computer Science Discrete Mathematics
11 pages
Arrays
PDF
No ratings yet
Arrays
44 pages
Arrays - Class 1
PDF
No ratings yet
Arrays - Class 1
13 pages
DynamicProgrammingNotes
PDF
No ratings yet
DynamicProgrammingNotes
24 pages
Dynamic Programming
PDF
No ratings yet
Dynamic Programming
104 pages
Oacp End Term
PDF
No ratings yet
Oacp End Term
33 pages
BA-Mastering Dynamic Programming
PDF
No ratings yet
BA-Mastering Dynamic Programming
13 pages
CH-4
PDF
No ratings yet
CH-4
48 pages
Lab1 07-0258
PDF
No ratings yet
Lab1 07-0258
8 pages
BCS Question Bank
PDF
No ratings yet
BCS Question Bank
360 pages
Dashrath Notes
PDF
No ratings yet
Dashrath Notes
20 pages
04 - C Example Programs
PDF
No ratings yet
04 - C Example Programs
21 pages
DP Class 03 Notes
PDF
No ratings yet
DP Class 03 Notes
38 pages
DSP - Lab 2
PDF
No ratings yet
DSP - Lab 2
15 pages
Ch08_Dynamic Programming
PDF
No ratings yet
Ch08_Dynamic Programming
31 pages
Kamal Rohilla 2K18/CO/166 ADA Assignment 13 Apr. 2020
PDF
No ratings yet
Kamal Rohilla 2K18/CO/166 ADA Assignment 13 Apr. 2020
10 pages
Competitive Programming Notebook: Joao Carreira 2010
PDF
No ratings yet
Competitive Programming Notebook: Joao Carreira 2010
21 pages
A2SV __ G5 - DP [Bottom Up Approach] (with Code)
PDF
No ratings yet
A2SV __ G5 - DP [Bottom Up Approach] (with Code)
60 pages
Cheat Sheet
PDF
No ratings yet
Cheat Sheet
14 pages
Competitive Programmer Notebook
PDF
No ratings yet
Competitive Programmer Notebook
42 pages
1. Flow Chart
PDF
No ratings yet
1. Flow Chart
12 pages
Raushan Kumar - 22scse2120040 (DAA)
PDF
No ratings yet
Raushan Kumar - 22scse2120040 (DAA)
18 pages
kactl
PDF
No ratings yet
kactl
34 pages
Sure
PDF
No ratings yet
Sure
50 pages
Week 2-6
PDF
No ratings yet
Week 2-6
44 pages
Discrete Maths Programs
PDF
No ratings yet
Discrete Maths Programs
12 pages
Session 1:-: in The Following Figure, You Can See A Rectangular
PDF
No ratings yet
Session 1:-: in The Following Figure, You Can See A Rectangular
25 pages
AD 1 assignment
PDF
No ratings yet
AD 1 assignment
32 pages
E Lab
PDF
No ratings yet
E Lab
744 pages
Dynamic Programming: Data Structures and Algorithms
PDF
No ratings yet
Dynamic Programming: Data Structures and Algorithms
9 pages
Lab Problem
PDF
No ratings yet
Lab Problem
15 pages
Module 4 ADA
PDF
No ratings yet
Module 4 ADA
23 pages
Notebook CIAM
PDF
No ratings yet
Notebook CIAM
26 pages
Bss PR NM
PDF
No ratings yet
Bss PR NM
58 pages
Array Extra Cls
PDF
No ratings yet
Array Extra Cls
11 pages
Coin Row
PDF
No ratings yet
Coin Row
4 pages
Finding Inverse Matrix Source Code 1
PDF
No ratings yet
Finding Inverse Matrix Source Code 1
9 pages
Bhavya C++ Week-3 Quiz Solutions
PDF
No ratings yet
Bhavya C++ Week-3 Quiz Solutions
6 pages
Bhavya 1st - February - 2023 Notes (Revision Important Points Only)
PDF
No ratings yet
Bhavya 1st - February - 2023 Notes (Revision Important Points Only)
3 pages
Bhavya C++ Week-1 Quiz Solutions
PDF
No ratings yet
Bhavya C++ Week-1 Quiz Solutions
11 pages
Homework Solutions 1st February 2023
PDF
No ratings yet
Homework Solutions 1st February 2023
3 pages
Backtracking - ClassIV - Notes - 25th March 2023
PDF
No ratings yet
Backtracking - ClassIV - Notes - 25th March 2023
5 pages
Bhavya 28th January 2023 Notes
PDF
No ratings yet
Bhavya 28th January 2023 Notes
13 pages