Skip to main content
Open navigation menu
Close suggestions
Search
Search
en
Change Language, English
Upload
Sign in
Sign in
0 ratings
0% found this document useful (0 votes)
15 views
47 pages
Dynamic Programming
Uploaded by
guptaaman0409
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
Save
Save Dynamic Programming For Later
Share
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
15 views
47 pages
Dynamic Programming
Uploaded by
guptaaman0409
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
Go to previous items
Download
Save
Save Dynamic Programming For Later
Share
0%
0% found this document useful, Mark this document as useful
0%
0% found this document not useful, Mark this document as not useful
Print
Embed
Report
Go to next items
Download
classmate Lecture $ 69 Dynome Pp a dp _kaam €k boar kar Bute Cae pase falco - Fibonace’ series 2 fer) 20, 4, 4, 2, 398/803, 2h, FEE Dynomic programming problem can _Selved in -fuo ways? + Nemoizaton ©) Fep claw Pipa © Tabstaon (eatin poppin) Amara : oa (loop) ___ Space optimization. nt frbanoee number 3 fir) = Pema + fines) Bae ne S F(2) Re amis paint We use our F(e) = 0 Lo NIZZ post Memory pecause ED ea) 3 £Cu) Ine solved FC2) v\S Previously 24) VEC2)) C Fea), ro : 2fo) 140 vN Fu Fw Y 0Divide ANd Conquer ly DP ke proviem Ko pohle divide korte Joo OF uake baad usko ex Ge Kar Ke Jodte Joo. Overla pping Subproblen 5 Je problem Ka part solve kar chuxe hai Usko _dubara Solve noni Karo, Memory me Store S Karun Kar ako direct use kar lo. Before Dp * Aver bP erm 2234 a Fon N= 10 fr 4 =10 a= Ga) S iN t L See the diPference Of bor How +2 Store Re Value whith We calwloted previowly9 Maxe an affay OF size (as) FC> b&b ort) gaitially out Sik ony fcc me) FO) =ast value in each _stepclassmate aaa oO VS ist ea + 2 eai=3 a a Pet = cy ae TNE TSN =! 3144 OUO@®s TIERS 1 SENOOR Io § oo g = Tetum > a Ways = & ae Nef Vata fefarn 6 —— i n==5 _ Cedurn 1 5 — ars fetum 0 3 i es ete’ 6) era eg) YV Ee me a) Io = ee YES = © WY OES ESS pe 1 XO Pen) = _@ ent) + FCn+2) Qh => ferum 2 >A = fetum 0classmate Bottom up Approach 8 eas nein be i = mae = 2414) =4 aro % 2{e Ve ' o AC sir G)o a K i se a Ac 3 Arfeady) Calculated, & oO code 2 long long _CountWays Lint _n) ( 9 op Vector < long long) dp (n+); dpind = 1) dpins = 0; Apins 2} = 0, foe Cint i= n-1; i>=0,; ED Spe ES RL sate Xaplits]) fe \o0000g00F; 3 feturn apie; 5int find Cint rndex , Vector
= 9) | Peturn 0} fetarn max (nums Lindex) + find Cindex +2, nums, n), Sind Cindex +1, nums, 9); int rob (vector = 9) Ceturn 07 cerurn find Cindex , amount Coins Lindex], Coins, 0) + eee *+\) amount, Coins , %)/ ink change (int amount, Vector
£ coins) ¢ im \= Coins. sized) fetum fmdC Or Amount, Cons, 9+| mee OS classnate ~ Dynamic _progomming _Appsoach * i Ta Gia dlassn Approseh) ~. We use Qp pp hee® cal ~ access 9 wate Cine LNG Sa ~ )_ index i 2) Armourt eS va S aaa Se ~ Fer storing the caleulate “value tle _ Woe : — ab Array here 8 eo becouse fir index = tthe Value Oh “— amwn Nes lw a> te 5 - == RA So,We we ad _— firroy! [= index 2 0 ® 2 4 J nm.) ~~ Matix (SxO fequired. Qndex 3 > O-Q “) M+!) Amougt $ Amount + | BD Dp Size % (nay) % Camount 41) We understand With an Examples eins. ¢ Up DSi Amount = S|code 2 Cop down Approach ) classmate ik Comount_ == 0) feturn 1; ub Cindex < 0) (eturn 0; uf Cap LindexJ LamountJ j= -1) feturn — dpLindex] amount) » ig (Coins Lindex] > amount ) 1 Fefurn ApLindexILameum] = find Cindex I, Amount, Coins, dP); else { fekarn dp Linder] amount) = find (index , amounts Coins Linderd, Coins, Ip) + find (index -1, amount, Gins, dp); j int change ( int amount, vector
£ Coins) f int 0 = Coins.srze0)) Vechr Cvector< int)) dp (n+), vector cint> Camount +1, =e feturn find (n-1, amount, Qins, dlp);amounNe as an re] Las Ys] Soe ‘ 7 i oe cas = ~ = a. Cn SRS On iis a2 aa da Add Ad: C a o i " ae Siuciem cite i exist 4 cae ae fd Ph a . a Sie ca : Ie 1E £4 | Ser a a DSSS = se c 2 +e is Xin | Xe a ee oa i vey a a att 7 a Finol_ answer = 4 a coded w ie ime _chanye Cink amount, Veelord ints L Goins ) { i wt N= Goins. size; ~ ue Vector < int) dp Camount + 4, 0); a APpLed = 4; a ye fer Lint i= Veni tana) . fer Lint 3 = GinsLi=1]) 3 \ fedtura dp Lamounsy;Count _Woys to Nh Stair (Order does mot matter) => Mere are _N_ Staitss => person Can Clim (1, 2,45, {201,14 (1, 2) are Considered Qs same. aa Becowe ohrequen AZ 2 ase same in On. int index, int a, int Steper) f a >n return, ad Lindex -\, 9, saep)> else (etut Bad (index, o~ step Cinder ~0, step) + od (index -1, 9, step) > int cwdstair Cint a) ( int srepL2d = (11245 Pefurn od C210, step);nT PEE 80 fh _ problem 4 2 values chanjee 4 index & © So, 2D Dp __ required here cas Down roach (lode) o.| _ int ind _Cint index, iat n,_ int Spl, vector vector < iotss£eP) { if (9 == 0) fefurn 41; Cindex == 0) fetum 0; dp Lindex][n]J J= -1 fefum dplindexICr1; sep Lindex -1] ) 1) feturn dppLindexd En] = fod (soder 1, 0, step, dp): else fetarn dp CinderxI[a]= find ( index , A step Lindex ~ 1], np) + fiod(inder-1, 0, step, dp) 4 [a int _ntStair Cit 0) £ int stepC2J= [11 2}; Vector
You might also like
5 Keys to Succeed in Tech Interviews
PDF
No ratings yet
5 Keys to Succeed in Tech Interviews
14 pages
Redis Slave Election Process Explained
PDF
No ratings yet
Redis Slave Election Process Explained
1 page
Full Stack Curriculum for MAANG Success
PDF
No ratings yet
Full Stack Curriculum for MAANG Success
13 pages
Deploying Redis Exporter with Helm
PDF
No ratings yet
Deploying Redis Exporter with Helm
4 pages
Hindi Numbers: English Translations
PDF
No ratings yet
Hindi Numbers: English Translations
1 page
Graph Algorithms for FAANG Interviews
PDF
No ratings yet
Graph Algorithms for FAANG Interviews
98 pages
Data Consistency in Microservices
PDF
No ratings yet
Data Consistency in Microservices
10 pages
System Design Fellowship Program Overview
PDF
No ratings yet
System Design Fellowship Program Overview
21 pages
Redis Cluster Setup and Operations Guide
PDF
No ratings yet
Redis Cluster Setup and Operations Guide
3 pages
Amazon Glacier Overview and Features
PDF
No ratings yet
Amazon Glacier Overview and Features
31 pages
Building Effective Agentic AI Systems
PDF
No ratings yet
Building Effective Agentic AI Systems
10 pages
Software Engineer Interview Guide
PDF
No ratings yet
Software Engineer Interview Guide
8 pages
Redis Data Structures Overview
PDF
No ratings yet
Redis Data Structures Overview
62 pages
Overview of Large Language Models
PDF
No ratings yet
Overview of Large Language Models
3 pages
Caching Strategies: Part 2 Overview
PDF
No ratings yet
Caching Strategies: Part 2 Overview
9 pages
Masterclass Plan for DSA & Development
PDF
No ratings yet
Masterclass Plan for DSA & Development
7 pages
Understanding Python Hash Tables
PDF
No ratings yet
Understanding Python Hash Tables
5 pages
Heap Sort Algorithm Explained
PDF
No ratings yet
Heap Sort Algorithm Explained
9 pages
String Processing in Competitive Programming
PDF
No ratings yet
String Processing in Competitive Programming
42 pages
Comprehensive Java and C Programming Guide
PDF
No ratings yet
Comprehensive Java and C Programming Guide
10 pages
Java and Python Sorting Techniques
PDF
100% (4)
Java and Python Sorting Techniques
31 pages
Backend Interview Preparation Guide
PDF
No ratings yet
Backend Interview Preparation Guide
46 pages
UML Class and Sequence Diagram Cheatsheet
PDF
No ratings yet
UML Class and Sequence Diagram Cheatsheet
1 page
Machine Learning Engineer Foundations
PDF
No ratings yet
Machine Learning Engineer Foundations
22 pages
Top 25 DSA Questions for MAANG
PDF
No ratings yet
Top 25 DSA Questions for MAANG
16 pages
Key Graph Algorithms for DSA Interviews
PDF
No ratings yet
Key Graph Algorithms for DSA Interviews
19 pages
Java 8: Lambda Expressions & Interfaces
PDF
No ratings yet
Java 8: Lambda Expressions & Interfaces
11 pages
Designing a Video Sharing Service
PDF
No ratings yet
Designing a Video Sharing Service
51 pages
Gopuff Delivery System Design Guide
PDF
No ratings yet
Gopuff Delivery System Design Guide
18 pages
7 Techniques to Optimize Learning
PDF
No ratings yet
7 Techniques to Optimize Learning
11 pages
Master DSA & System Design Courses
PDF
No ratings yet
Master DSA & System Design Courses
6 pages
Understanding Theta Notation in Complexity
PDF
No ratings yet
Understanding Theta Notation in Complexity
9 pages
Essential C# Concepts for Beginners
PDF
100% (1)
Essential C# Concepts for Beginners
33 pages
Backtracking Algorithm Fundamentals
PDF
No ratings yet
Backtracking Algorithm Fundamentals
14 pages
DSA Preparation in 25 Days
PDF
No ratings yet
DSA Preparation in 25 Days
6 pages
Hashing Techniques and Collision Resolution
PDF
100% (2)
Hashing Techniques and Collision Resolution
31 pages
CS Fundamentals Interview Questions
PDF
No ratings yet
CS Fundamentals Interview Questions
45 pages
Bit Manipulation Techniques Explained
PDF
100% (1)
Bit Manipulation Techniques Explained
18 pages
Dynamic Programming: 0/1 Knapsack Problem
PDF
No ratings yet
Dynamic Programming: 0/1 Knapsack Problem
18 pages
An Overview of C++11 and C++14 - Leor Zolman - CppCon 2014
PDF
100% (2)
An Overview of C++11 and C++14 - Leor Zolman - CppCon 2014
55 pages
1e9a63b1-42ea-434b-b9e7-36aa19e72e66
PDF
No ratings yet
1e9a63b1-42ea-434b-b9e7-36aa19e72e66
15 pages
Data Science Learning Roadmap Guide
PDF
No ratings yet
Data Science Learning Roadmap Guide
55 pages
Shiva Kumara: CTO Resume Summary
PDF
No ratings yet
Shiva Kumara: CTO Resume Summary
9 pages
MAANG Internship Success Roadmap
PDF
No ratings yet
MAANG Internship Success Roadmap
5 pages
DSA Tutorial - GeeksforGeeks
PDF
No ratings yet
DSA Tutorial - GeeksforGeeks
7 pages
Linked List Basics and Implementation Guide
PDF
No ratings yet
Linked List Basics and Implementation Guide
95 pages
Comprehensive DSA Notes Overview
PDF
No ratings yet
Comprehensive DSA Notes Overview
2 pages
Linked Lists Overview and Operations
PDF
100% (1)
Linked Lists Overview and Operations
40 pages
DSA Roadmap 2026 01 04
PDF
100% (1)
DSA Roadmap 2026 01 04
6 pages
Concurrency Coordination
PDF
No ratings yet
Concurrency Coordination
13 pages
NISM Exam 2025: Eligibility and Syllabus
PDF
No ratings yet
NISM Exam 2025: Eligibility and Syllabus
20 pages
Lagrange's Four-Square Theorem Explained
PDF
No ratings yet
Lagrange's Four-Square Theorem Explained
2 pages
Understanding CQRS in Microservices
PDF
No ratings yet
Understanding CQRS in Microservices
20 pages
DSA Mastery: 150 Problems & Templates
PDF
No ratings yet
DSA Mastery: 150 Problems & Templates
3 pages
System Design Interview Success Guide
PDF
No ratings yet
System Design Interview Success Guide
232 pages
Array Patterns Cheat Sheet for DSA
PDF
No ratings yet
Array Patterns Cheat Sheet for DSA
9 pages
Backtracking vs. Branch and Bound Methods
PDF
No ratings yet
Backtracking vs. Branch and Bound Methods
34 pages
Caching Techniques and Strategies
PDF
No ratings yet
Caching Techniques and Strategies
7 pages
DP - ClassII - Notes - 7th June 2023
PDF
No ratings yet
DP - ClassII - Notes - 7th June 2023
11 pages
Fractional Knapsack and Job Scheduling
PDF
No ratings yet
Fractional Knapsack and Job Scheduling
16 pages