Counting Numbers | CSES Problem | Digit DP Explained | No Adjacent Equal Digits
🔢 𝐂𝐒𝐄𝐒 – 𝐂𝐨𝐮𝐧𝐭𝐢𝐧𝐠 𝐍𝐮𝐦𝐛𝐞𝐫𝐬 | 𝐃𝐢𝐠𝐢𝐭 𝐃𝐏 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 𝐄𝐱𝐩𝐥𝐚𝐢𝐧𝐞𝐝 (𝐍𝐨 𝐀𝐝𝐣𝐚𝐜𝐞𝐧𝐭 𝐒𝐚𝐦𝐞 𝐃𝐢𝐠𝐢𝐭𝐬) In this video, we solve the Counting Numbers problem from the CSES Problem Set, using one of the most fundamental techniques in competitive programming: Digit DP (Number DP). We explore the idea of counting all numbers in a range [a,b] such that no two adjacent digits are equal — a perfect beginner-friendly problem for building intuition in Digit DP. This video covers everything from concept → state design → transitions → implementation in C++. 💡 𝐖𝐡𝐚𝐭 𝐘𝐨𝐮’𝐥𝐥 𝐋𝐞𝐚𝐫𝐧 - What is Digit DP? - How to design DP states: - position - previous digit - tight constraint - leading zero logic - Handling range queries using countUpTo(b) – countUpTo(a-1) - Avoiding adjacent equal digits - Clean, contest-ready C++ implementation - Understanding a classic CSES DP problem step-by-step This is part of my 𝐃𝐢𝐠𝐢𝐭 𝐃𝐏 𝐒𝐞𝐫𝐢𝐞𝐬, where I cover smart and creative problems that teach you how to build solutions from logic — a key skill in competitive programming 🚀 💡 𝐓𝐡𝐢𝐬 𝐯𝐢𝐝𝐞𝐨 𝐰𝐢𝐥𝐥 𝐡𝐞𝐥𝐩 𝐲𝐨𝐮 𝐮𝐧𝐝𝐞𝐫𝐬𝐭𝐚𝐧𝐝 𝐡𝐨𝐰 𝐭𝐨 𝐭𝐡𝐢𝐧𝐤 𝐜𝐨𝐧𝐬𝐭𝐫𝐮𝐜𝐭𝐢𝐯𝐞𝐥𝐲, 𝐛𝐮𝐢𝐥𝐝 𝐬𝐨𝐥𝐮𝐭𝐢𝐨𝐧𝐬 𝐥𝐨𝐠𝐢𝐜𝐚𝐥𝐥𝐲, 𝐚𝐧𝐝 𝐬𝐭𝐫𝐞𝐧𝐠𝐭𝐡𝐞𝐧 𝐲𝐨𝐮𝐫 𝐩𝐫𝐨𝐛𝐥𝐞𝐦-𝐬𝐨𝐥𝐯𝐢𝐧𝐠 𝐦𝐢𝐧𝐝𝐬𝐞𝐭 — 𝐩𝐞𝐫𝐟𝐞𝐜𝐭 𝐟𝐨𝐫 𝐂𝐒𝐄𝐒, 𝐂𝐨𝐝𝐞𝐟𝐨𝐫𝐜𝐞𝐬, 𝐀𝐭𝐂𝐨𝐝𝐞𝐫, 𝐚𝐧𝐝 𝐈𝐂𝐏𝐂 𝐜𝐨𝐧𝐭𝐞𝐬𝐭𝐬. 📘𝐍𝐨𝐭𝐞𝐬: https://github.com/yash7xm/cp_notes/blob/master/Digit%20DP/Counting%20Numbers.pdf 𝐂𝐨𝐝𝐞: https://github.com/yash7xm/cp-topics/blob/master/digit-dp/CountingNumbers.cpp 👉 𝐏𝐫𝐨𝐛𝐥𝐞𝐦 𝐋𝐢𝐧𝐤: https://cses.fi/problemset/task/2220/ 🔗 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭: https://youtube.com/playlist?list=PLtfqa971vD5FqhXGZOkc9bmybbM9Mkxb4&si=1mplrS1YQ6LDEIz7 💡 𝐏𝐞𝐫𝐟𝐞𝐜𝐭 𝐟𝐨𝐫: - Competitive programmers - Data structure & algorithms learners - Coding interview prep 📌 Watch this till the end to fully understand the intuition, not just the code. 👉 Whether you’re a beginner or looking to strengthen your logical thinking, this course will help you 𝐭𝐡𝐢𝐧𝐤 𝐥𝐢𝐤𝐞 𝐚 𝐜𝐨𝐦𝐩𝐞𝐭𝐢𝐭𝐢𝐯𝐞 𝐩𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐞𝐫 𝐚𝐧𝐝 𝐝𝐞𝐬𝐢𝐠𝐧 𝐜𝐨𝐧𝐬𝐭𝐫𝐮𝐜𝐭𝐢𝐯𝐞 𝐬𝐨𝐥𝐮𝐭𝐢𝐨𝐧𝐬 𝐜𝐨𝐧𝐟𝐢𝐝𝐞𝐧𝐭𝐥𝐲 𝐢𝐧 𝐜𝐨𝐧𝐭𝐞𝐬𝐭𝐬. 👋 𝐖𝐞𝐥𝐜𝐨𝐦𝐞 𝐭𝐨 𝐭𝐡𝐞 𝐜𝐡𝐚𝐧𝐧𝐞𝐥! I create content on 𝐂𝐨𝐦𝐩𝐞𝐭𝐢𝐭𝐢𝐯𝐞 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐦𝐢𝐧𝐠, 𝐃𝐚𝐭𝐚 𝐒𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞𝐬 & 𝐀𝐥𝐠𝐨𝐫𝐢𝐭𝐡𝐦𝐬 (𝐃𝐒𝐀), 𝐚𝐧𝐝 𝐓𝐞𝐜𝐡𝐧𝐢𝐜𝐚𝐥 𝐈𝐧𝐭𝐞𝐫𝐯𝐢𝐞𝐰 𝐏𝐫𝐞𝐩𝐚𝐫𝐚𝐭𝐢𝐨𝐧. If you find this video helpful, don’t forget to: 👍 Like the video 💬 Comment your doubts/questions (I reply to everyone!) 🔔 Subscribe and turn on notifications to never miss upcoming tutorials 📌 𝐂𝐨𝐧𝐧𝐞𝐜𝐭 𝐰𝐢𝐭𝐡 𝐦𝐞: 🐦 X: https://x.com/Yash_Poonia_ 💼 LinkedIn: https://www.linkedin.com/in/yashpoonia/ 💻 GitHub: https://github.com/yash7xm 🌐 Discord: https://discord.gg/dAp2PbKFpV #DigitDP #CSES #DynamicProgramming #CompetitiveProgramming #DSA #Cplusplus #NumberDP #AlgorithmTutorial #CodingInterviewPrep #LearnDSA
Download
0 formatsNo download links available.