Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

DSA in Python – Geek’s Training | 2D DP on Activities | GFG Practice | Part 195 [Hindi]

3.9K views on YouTube

📘 Welcome to Part 195 of Code & Debug’s DSA in Python Course!

In this video, we tackle the classic 2D dynamic programming problem: Geek’s Training from GeeksforGeeks. Each day, Geek must choose between Running, Fighting, and Learning, but cannot perform the same activity on consecutive days. We’ll implement all 4 approaches, evolving from pure recursion to the optimal space-optimized DP solution, just as explained in our companion article.

This is a perfect exercise to master DP state management by introducing an extra dimension (task/day), frequently seen in advanced DP interview questions.

👨🏫 What’s covered in this video:
1. Problem statement and key constraints
2. Approach 1: Brute Force Recursion
3. Approach 2: Memoization (Top-Down DP)
4. Approach 3: Tabulation (Bottom-Up DP)
5. Approach 4: Space-Optimized Tabulation
6. Full Python code walkthrough for each approach
7. Dry run examples & transition explanations
8. State definition: f(day, last_task)
9. Complexity analysis and summary
10. Interview tips on how “activity restriction” drives DP state

By the end of this session, you’ll confidently model and solve complex 2D DP problems!

🔗 GFG Problem – Geek’s Training:
https://www.geeksforgeeks.org/problems/geeks-training/1

🔗 In-depth Article with Code and Explanations:

Geek’s Training | 2D Dynamic Programming | GFG Practice

📄 Full Playlist Sheet (All Questions in Order):
https://docs.google.com/spreadsheets/d/1AWE15Fy3wD2iqu2vjK_R7cCiuvSsjYQclcdZmHpF66o/edit?usp=sharing

🎓 Enroll in the FREE Python DSA Course:
https://codeanddebug.in/course/master-dsa-with-leetcode

🚀 Advance Python DSA for FAANG (Zero to Hero Course):
https://codeanddebug.in/course/zero-to-hero-python-dsa

Stay focused and keep coding with Code & Debug.
Like | Share | Subscribe | Hit the 🔔

#GeeksTraining #DynamicProgramming #2DDP #Memoization #Tabulation #SpaceOptimization #PythonDSA #GFGPractice #CodeAndDebug #Part195 #ActivitySelection #DSAPatterns #InterviewPrep