Competitive Coding
Unit 7: Capstone โ Contest Strategy & Career Launchpad
Synthesize everything from Units 1โ6, build a killer portfolio, master contest strategy, ace coding interviews, and launch your competitive programming career.
โฑ๏ธ Time to Complete: 8โ10 hours | ๐ฐ Earning Potential: โน10,000โโน50,000/month | ๐ 30 MCQs (Bloom's Mapped)
๐ผ Jobs this unlocks: SDE-1 (โน8โ25 LPA) | Problem Setter (โน15Kโโน50K/month freelance) | Competitive Programming Coach (โน20Kโโน80K/month)
Opening Hook โ From Zero Rating to โน18 LPA at Razorpay
๐ How Arjun from Jaipur Went from Codeforces 0 โ Expert (1600+) in 6 Months
Arjun Meena was a 2nd-year BCA student at a tier-3 college in Jaipur. He had never written a competitive programming solution. His first Codeforces contest? He solved zero problems and his rating was 0. He felt humiliated watching others solve problems in minutes that he couldn't crack in 2 hours.
But Arjun had a plan. He followed the "3-2-1 Rule": solve 3 easy problems, 2 medium problems, and attempt 1 hard problem every single day. He used a spreadsheet to track every problem โ topic, time taken, whether he needed the editorial. He gave one virtual contest every week on Codeforces.
Month 1: Rating 800 (Newbie). Month 2: 1000 (Pupil). Month 3: 1200 (Pupil). Month 4: 1400 (Specialist). Month 5: 1500. Month 6: 1623 โ Expert.
His Codeforces profile became his resume. Razorpay's hiring team noticed his consistent contest participation during their off-campus drive. In the interview, Arjun solved a DP optimization problem in 12 minutes that stumped other candidates for 45 minutes. Offer: โน18 LPA as SDE-1.
What changed? Not talent โ strategy. Arjun didn't grind randomly. He followed a structured approach: identify weak topics โ practice deliberately โ compete regularly โ build a visible profile. This chapter teaches you that exact strategy.
Learning Outcomes โ Bloom's Taxonomy Mapped (12 Outcomes)
| Bloom's Level | Learning Outcome |
|---|---|
| ๐ต Remember | List the rating tiers of Codeforces (Newbie โ Legendary Grandmaster) and recall Big-O complexities for all major algorithms covered in Units 1โ6 |
| ๐ต Remember | Identify the top 5 competitive programming platforms and their contest formats (Codeforces, CodeChef, LeetCode, AtCoder, HackerRank) |
| ๐ข Understand | Explain contest strategy: how to read all problems first, sort by estimated difficulty, and decide when to skip a problem |
| ๐ข Understand | Describe the "brute force โ observe pattern โ optimize โ reduce to known problem" framework for approaching contest problems |
| ๐ก Apply | Set up profiles on Codeforces, CodeChef, and LeetCode; participate in at least one live contest; solve 5+ problems across difficulty levels |
| ๐ก Apply | Build and deploy at least 3 portfolio projects from Units 1โ6 with proper GitHub READMEs and live demos |
| ๐ Analyze | Compare rating systems across platforms (Codeforces ELO vs CodeChef vs LeetCode) and determine which best suits personal career goals |
| ๐ Analyze | Analyze the top 30 interview coding questions by pattern (arrays, DP, backtracking, etc.) and identify which patterns are most frequently asked at top Indian companies |
| ๐ด Evaluate | Assess your own competitive programming profile and create a personalized 90-day improvement plan with measurable milestones |
| ๐ด Evaluate | Evaluate a cold email template for SDE applications and critique its effectiveness for the Indian job market |
| ๐ฃ Create | Design a complete competitive programming portfolio website showcasing projects, ratings, achievements, and a resume tailored for SDE roles |
| ๐ฃ Create | Create a 6-month competitive programming training plan that integrates contest participation, topic mastery, portfolio building, and interview preparation |
Concepts โ Contest Strategy, Portfolio, Interviews & Career
Part 1: Contest Strategy
1.1 How to Approach a Competitive Programming Contest
๐ฏ The First 10 Minutes โ The Most Important Phase
Step 1: Read ALL problems (5โ8 min). Don't start coding the first problem immediately. Quickly scan every problem statement. Read the input/output examples. Identify which problems are implementation-based (easy), which require a known algorithm, and which are tricky.
Step 2: Sort by YOUR difficulty (2โ3 min). Codeforces problems are roughly sorted A (easiest) โ F (hardest), but not always. You might find C easier than B if it matches your strengths. Mark each problem mentally: ๐ข (can solve), ๐ก (might solve), ๐ด (skip for now).
Step 3: Solve ๐ข problems first. Get the easy AC (Accepted) verdicts quickly. Each solved problem gives you confidence and rating points. Speed matters โ for equal scores, faster submission time wins.
Step 4: Attack ๐ก problems. Try your approach. If stuck for 15 minutes, move on. Come back later with fresh eyes.
Step 5: Final 10 minutes โ review and hack. Double-check edge cases. On Codeforces, you can "hack" other solutions during the hack phase to gain extra points.
1.2 Time Management โ When to Skip a Problem
| Situation | Action | Why |
|---|---|---|
| Stuck for 15 min with no progress | Skip. Move to next problem. | Diminishing returns โ fresh problems = fresh energy |
| You see the approach but implementation is 100+ lines | Estimate time. If <30 min left, skip to simpler ones. | Long implementation = more bugs = more debugging time |
| Getting Wrong Answer on test case #47 | Check edge cases: n=0, n=1, max values, negative numbers | 90% of WA errors are edge cases, not logic errors |
| Time Limit Exceeded (TLE) | Is your solution O(nยฒ) when it needs O(n log n)? | Optimize algorithm, don't micro-optimize code |
| Runtime Error (RE) | Check array bounds, division by zero, stack overflow (recursion depth) | Use sys.setrecursionlimit() in Python; check INT_MAX in C++ |
1.3 Common Problem-Solving Patterns
๐ The 4-Step Pattern Recognition Framework
Step 1 โ Brute Force First: Can you solve it with nested loops / recursion checking all possibilities? If N โค 20, brute force works. Write it, get AC or partial score, then optimize.
Step 2 โ Observe Pattern: Run your brute force on small inputs. Print intermediate results. Do you see a mathematical pattern? A recurrence relation? Repeated subproblems (โ DP)?
Step 3 โ Optimize: Can you remove redundant computation? Use prefix sums, sliding window, binary search, or memoization to reduce complexity? Sort the input first?
Step 4 โ Reduce to Known Problem: Does this look like a shortest path (โ Dijkstra/BFS)? Maximum subarray (โ Kadane's)? Subset sum (โ DP)? String matching (โ KMP/Z-algo)? Recognizing known problems is the #1 skill of expert competitive programmers.
C++ โ Brute Force โ Optimized Example // Problem: Find two numbers in array that sum to target // BRUTE FORCE: O(nยฒ) for(int i=0; i<n; i++) for(int j=i+1; j<n; j++) if(a[i]+a[j]==target) return {i,j}; // OPTIMIZED: O(n) using hash map unordered_map<int,int> mp; for(int i=0; i<n; i++){ if(mp.count(target-a[i])) return {mp[target-a[i]], i}; mp[a[i]] = i; }
1.4 Rating Systems Explained
| Platform | Rating System | Key Tiers | Contest Frequency |
|---|---|---|---|
| Codeforces | ELO-based (like chess) | Newbie(<1200), Pupil(1200), Specialist(1400), Expert(1600), CM(1900), Master(2100), GM(2400), IGM(2600+), LGM(3000+) | 2โ3/week |
| CodeChef | Star-based | 1โ (<1400), 2โ (1400), 3โ (1600), 4โ (1800), 5โ (2000), 6โ (2200), 7โ (2500+) | Weekly + Long/Cook-Off |
| LeetCode | Contest Rating | Unrated, Guardian(โฅ2000), Knight(โฅ1800) | Weekly + Biweekly |
| AtCoder | ELO-based | Gray(<400), Brown(400), Green(800), Cyan(1200), Blue(1600), Yellow(2000), Orange(2400), Red(2800+) | Weekly |
1.5 The Ideal Practice Schedule
๐ Weekly Schedule for Rating Growth
Daily (1.5โ2 hours):
โข Solve 2โ3 problems on Codeforces/LeetCode (1 easy, 1 medium, attempt 1 hard)
โข If you can't solve in 30 min, read the editorial, understand it, then implement from scratch
โข Log every problem: topic, time, solved/unsolved, key insight
Weekly (2โ3 hours):
โข Participate in 1 live rated contest (Codeforces Div. 2 or LeetCode Weekly)
โข After contest: upsolve โ solve the problems you couldn't during contest using editorials
Monthly:
โข Review your problem log. Identify weakest topics.
โข Dedicate next month's practice to those weak areas
โข Update your Codeforces/GitHub profile
Part 2: Portfolio Projects (from All 6 Units)
These 6 projects, built throughout Units 1โ6, form your competitive programming portfolio. Each project demonstrates a different algorithmic skill set.
๐ Project 1: Complexity Analyzer Tool Unit 1
Description: A web-based tool that takes a code snippet (C++/Python/Java) and estimates its time complexity by analyzing loop structures, recursion depth, and known algorithm patterns. Displays the Big-O notation with an explanation of how it was derived.
Tech Stack: HTML/CSS/JavaScript (frontend), Python Flask (backend for parsing), Regular Expressions for pattern matching
Key Features:
โข Paste code โ get O(n), O(nยฒ), O(log n), etc.
โข Visual complexity graph showing growth curves
โข Side-by-side comparison of O(n) vs O(nยฒ) vs O(n log n) for user-provided input size
GitHub README Template:
Markdown
# โฑ๏ธ Complexity Analyzer Tool
> Analyze time complexity of code snippets instantly
## Features
- Paste C++/Python/Java code and get Big-O estimate
- Visual growth curve comparison
- Supports loops, recursion, and common patterns
## Tech Stack
- Frontend: HTML, CSS, JavaScript (Chart.js)
- Backend: Python (Flask), AST parsing
## Setup
```bash
pip install flask
python app.py
```
## Screenshots
[Add screenshots here]
## Author
[Your Name] | Codeforces: [handle] | LinkedIn: [URL]
๐ข Project 2: Prime Number Generator & Sieve Visualizer Unit 2
Description: An interactive visualizer that demonstrates the Sieve of Eratosthenes in real-time. Users input N and watch as the sieve eliminates composite numbers step by step, with color-coded cells. Also includes prime factorization and prime gap analysis.
Tech Stack: HTML/CSS/JavaScript (vanilla), Canvas API for animation
Key Features:
โข Step-by-step animation of Sieve of Eratosthenes
โข Speed control slider (slow for learning, fast for large N)
โข Prime factorization calculator
โข Statistics: prime count, density, largest gap
GitHub README Template:
Markdown
# ๐ข Prime Sieve Visualizer
> Watch the Sieve of Eratosthenes in action
## Features
- Real-time step-by-step sieve animation
- Color-coded prime/composite cells
- Prime factorization tool
- Works up to N = 100,000
## Tech Stack
- Pure HTML/CSS/JavaScript
- Canvas API for animation
## Live Demo
[Deploy on GitHub Pages โ link here]
๐ Project 3: N-Queens / Sudoku Solver with Visualization Unit 3
Description: A visual backtracking solver that animates the placement and removal of queens on an NรN chessboard, or fills a Sudoku grid step-by-step. Users can see the backtracking algorithm "think" in real-time as it explores and prunes branches.
Tech Stack: HTML/CSS Grid for board layout, JavaScript for backtracking engine, CSS animations
Key Features:
โข Animated queen placement with conflict highlighting
โข Adjustable board size (4ร4 to 12ร12)
โข Sudoku solver: input any puzzle or generate random ones
โข Step counter and backtrack counter to show algorithm efficiency
GitHub README Template:
Markdown
# ๐ N-Queens & Sudoku Visual Solver
> Watch backtracking algorithms solve puzzles in real-time
## Features
- N-Queens solver with animated queen placement
- Sudoku solver with step-by-step filling
- Adjustable speed and board size
- Backtrack counter shows algorithm efficiency
## Tech Stack
- HTML/CSS Grid, JavaScript
- No external dependencies
## How It Works
Uses recursive backtracking with constraint propagation.
๐ Project 4: DP Problem Solver with Table Visualization Unit 4
Description: An interactive tool that visualizes how dynamic programming tables are filled for classic problems: Fibonacci, Coin Change, Edit Distance, and Matrix Chain Multiplication. Users see cells being filled in real-time with arrows showing dependencies.
Tech Stack: HTML/CSS/JavaScript, D3.js for dependency arrows
Key Features:
โข Select from 5+ classic DP problems
โข Watch the DP table fill cell-by-cell with animation
โข Dependency arrows show which cells contribute to each result
โข Toggle between top-down (memoization) and bottom-up (tabulation) views
GitHub README Template:
Markdown
# ๐ DP Table Visualizer
> See how Dynamic Programming tables are filled step-by-step
## Supported Problems
- Fibonacci, Coin Change, Edit Distance
- 0/1 Knapsack, LCS, Matrix Chain Multiplication
## Features
- Animated table filling
- Dependency arrows
- Top-down vs Bottom-up comparison
## Tech Stack
- HTML/CSS/JavaScript, D3.js
๐ Project 5: Knapsack / LIS / LCS Interactive Demo Unit 5
Description: A hands-on interactive demo where users input their own items (weight, value) for Knapsack, or sequences for LIS/LCS, and watch the algorithm solve it. Includes side-by-side comparison of greedy vs DP approaches for Knapsack.
Tech Stack: React.js (or vanilla JS), CSS Grid for tables, Chart.js for comparison graphs
Key Features:
โข Custom input: add/remove items for Knapsack, edit sequences for LIS/LCS
โข Greedy vs DP comparison with visual output
โข Optimal solution highlighted in the DP table
โข Export results as image or PDF
GitHub README Template:
Markdown
# ๐ Knapsack / LIS / LCS Interactive Demo
> Explore classic optimization problems interactively
## Features
- Custom input for all problems
- Greedy vs DP visual comparison
- Step-by-step solution tracing
- Responsive design
## Tech Stack
- JavaScript, Chart.js, CSS Grid
๐ Project 6: Sorting Algorithm Visualizer & Benchmarker Unit 6
Description: A comprehensive sorting visualizer that animates 8+ sorting algorithms side-by-side. Includes a benchmarking mode that times each algorithm on the same random data and displays results in a chart. Users can see WHY Quick Sort beats Bubble Sort.
Tech Stack: HTML/CSS/JavaScript, Canvas API for bar animations, Web Workers for non-blocking sort execution
Key Features:
โข Algorithms: Bubble, Selection, Insertion, Merge, Quick, Heap, Counting, Radix
โข Side-by-side race mode: watch 2โ4 algorithms sort simultaneously
โข Benchmark mode: time comparison graph for arrays of size 100 to 100,000
โข Sound mode: each swap produces a tone (pitch = element value)
GitHub README Template:
Markdown
# ๐ Sorting Algorithm Visualizer & Benchmarker
> See sorting algorithms race in real-time
## Algorithms
Bubble, Selection, Insertion, Merge, Quick, Heap, Counting, Radix
## Features
- Real-time animated sorting
- Side-by-side algorithm racing
- Benchmarking with performance charts
- Sound mode for auditory learning
## Tech Stack
- Vanilla JavaScript, Canvas API, Web Workers
Part 3: Top 30 Competitive Coding Interview Questions
These 30 questions are organized by pattern. Each includes the approach hint, code, complexity, and which company has asked it. Master these patterns, and you'll handle 80% of coding interview questions.
๐ต Pattern 1: Array / String Manipulation (5 Questions)
Q1. Two Sum โ Find two numbers that add up to a target
Asked at: Amazon, Google, FlipkartApproach: Use a hash map. For each element, check if (target - element) exists in the map.
C++ vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> mp; for(int i=0; i<nums.size(); i++){ if(mp.count(target - nums[i])) return {mp[target-nums[i]], i}; mp[nums[i]] = i; } return {}; }
Complexity: Time O(n), Space O(n)
Q2. Kadane's Algorithm โ Maximum Subarray Sum
Asked at: Microsoft, Razorpay, PaytmApproach: Track current_sum and max_sum. If current_sum goes negative, reset to 0.
C++ int maxSubArray(vector<int>& nums) { int maxSum = nums[0], curSum = 0; for(int x : nums){ curSum = max(x, curSum + x); maxSum = max(maxSum, curSum); } return maxSum; }
Complexity: Time O(n), Space O(1)
Q3. Longest Substring Without Repeating Characters
Asked at: Amazon, Adobe, IntuitApproach: Use sliding window with a hash set to track characters in current window.
C++ int lengthOfLongestSubstring(string s) { unordered_set<char> seen; int l = 0, ans = 0; for(int r = 0; r < s.size(); r++){ while(seen.count(s[r])){ seen.erase(s[l]); l++; } seen.insert(s[r]); ans = max(ans, r - l + 1); } return ans; }
Complexity: Time O(n), Space O(min(n, 26))
Q4. Next Permutation
Asked at: Google, Flipkart, UberApproach: Find rightmost ascent, swap with next larger element, reverse suffix.
C++ void nextPermutation(vector<int>& nums) { int n = nums.size(), i = n-2; while(i >= 0 && nums[i] >= nums[i+1]) i--; if(i >= 0){ int j = n-1; while(nums[j] <= nums[i]) j--; swap(nums[i], nums[j]); } reverse(nums.begin()+i+1, nums.end()); }
Complexity: Time O(n), Space O(1)
Q5. Rotate Array by K Positions
Asked at: TCS, Infosys, WiproApproach: Reverse the whole array, then reverse first K elements, then reverse remaining.
C++ void rotate(vector<int>& nums, int k) { k %= nums.size(); reverse(nums.begin(), nums.end()); reverse(nums.begin(), nums.begin()+k); reverse(nums.begin()+k, nums.end()); }
Complexity: Time O(n), Space O(1)
๐ข Pattern 2: Two Pointer / Sliding Window (5 Questions)
Q6. Container With Most Water
Asked at: Amazon, Google, PhonePeApproach: Two pointers at ends. Move the shorter line inward โ we can only get more water by finding a taller line.
C++ int maxArea(vector<int>& h) { int l = 0, r = h.size()-1, ans = 0; while(l < r){ ans = max(ans, min(h[l],h[r])*(r-l)); if(h[l] < h[r]) l++; else r--; } return ans; }
Complexity: Time O(n), Space O(1)
Q7. 3Sum โ Find all unique triplets summing to zero
Asked at: Facebook, Atlassian, RazorpayApproach: Sort array. Fix one element, use two pointers for the remaining pair. Skip duplicates.
C++ vector<vector<int>> threeSum(vector<int>& nums) { sort(nums.begin(), nums.end()); vector<vector<int>> res; for(int i = 0; i < (int)nums.size()-2; i++){ if(i > 0 && nums[i]==nums[i-1]) continue; int l=i+1, r=nums.size()-1; while(l < r){ int s = nums[i]+nums[l]+nums[r]; if(s==0){ res.push_back({nums[i],nums[l],nums[r]}); while(l<r && nums[l]==nums[l+1]) l++; while(l<r && nums[r]==nums[r-1]) r--; l++; r--; } else if(s<0) l++; else r--; } } return res; }
Complexity: Time O(nยฒ), Space O(1) extra
Q8. Minimum Window Substring
Asked at: Google, Microsoft, UberApproach: Expand window right to include all chars of t, then shrink from left to minimize.
C++ string minWindow(string s, string t) { unordered_map<char,int> need, have; for(char c : t) need[c]++; int required = need.size(), formed = 0; int l = 0, bestL = 0, bestLen = INT_MAX; for(int r = 0; r < s.size(); r++){ have[s[r]]++; if(need.count(s[r]) && have[s[r]]==need[s[r]]) formed++; while(formed == required){ if(r-l+1 < bestLen){ bestLen = r-l+1; bestL = l; } have[s[l]]--; if(need.count(s[l]) && have[s[l]]<need[s[l]]) formed--; l++; } } return bestLen==INT_MAX ? "" : s.substr(bestL, bestLen); }
Complexity: Time O(|s| + |t|), Space O(|s| + |t|)
Q9. Trapping Rain Water
Asked at: Amazon, Google, Goldman SachsApproach: Two pointers from both ends. Track leftMax and rightMax. Water at position = min(leftMax, rightMax) - height.
C++ int trap(vector<int>& h) { int l=0, r=h.size()-1, lMax=0, rMax=0, ans=0; while(l < r){ if(h[l] < h[r]){ h[l] >= lMax ? lMax=h[l] : ans += lMax-h[l]; l++; } else { h[r] >= rMax ? rMax=h[r] : ans += rMax-h[r]; r--; } } return ans; }
Complexity: Time O(n), Space O(1)
Q10. Longest Repeating Character Replacement
Asked at: Microsoft, Flipkart, SwiggyApproach: Sliding window. Track max frequency char in window. If window_size - max_freq > k, shrink window.
C++ int characterReplacement(string s, int k) { int cnt[26]={}, l=0, maxF=0, ans=0; for(int r=0; r<s.size(); r++){ maxF = max(maxF, ++cnt[s[r]-'A']); while(r-l+1-maxF > k) cnt[s[l++]-'A']--; ans = max(ans, r-l+1); } return ans; }
Complexity: Time O(n), Space O(1)
๐ก Pattern 3: Recursion / Backtracking (5 Questions)
Q11. Generate All Permutations of a String/Array
Asked at: Google, Amazon, ZohoApproach: Fix one element, recursively permute the rest. Use swap-based backtracking.
C++ void permute(vector<int>& nums, int idx, vector<vector<int>>& res){ if(idx == nums.size()){ res.push_back(nums); return; } for(int i = idx; i < nums.size(); i++){ swap(nums[idx], nums[i]); permute(nums, idx+1, res); swap(nums[idx], nums[i]); // backtrack } }
Complexity: Time O(n ร n!), Space O(n)
Q12. N-Queens Problem
Asked at: Google, Apple, DirectiApproach: Place queens row by row. Use sets/arrays to track columns and diagonals under attack.
C++ void solve(int row, int n, vector<string>& board, vector<bool>& col, vector<bool>& d1, vector<bool>& d2, vector<vector<string>>& res){ if(row==n){ res.push_back(board); return; } for(int c=0; c<n; c++){ if(col[c]||d1[row-c+n-1]||d2[row+c]) continue; board[row][c] = 'Q'; col[c]=d1[row-c+n-1]=d2[row+c]=true; solve(row+1, n, board, col, d1, d2, res); board[row][c] = '.'; col[c]=d1[row-c+n-1]=d2[row+c]=false; } }
Complexity: Time O(n!), Space O(nยฒ)
Q13. Subset Sum โ Does a subset exist with given sum?
Asked at: Amazon, Samsung, WalmartApproach: For each element, two choices: include or exclude. Recursion with memoization (DP).
C++ bool subsetSum(vector<int>& nums, int target) { int n = nums.size(); vector<vector<bool>> dp(n+1, vector<bool>(target+1, false)); for(int i=0; i<=n; i++) dp[i][0] = true; for(int i=1; i<=n; i++) for(int j=1; j<=target; j++){ dp[i][j] = dp[i-1][j]; if(j >= nums[i-1]) dp[i][j] = dp[i][j] || dp[i-1][j-nums[i-1]]; } return dp[n][target]; }
Complexity: Time O(n ร target), Space O(n ร target)
Q14. Word Search in Grid
Asked at: Microsoft, Google, UberApproach: DFS from each cell. Mark visited cells, backtrack after exploring.
C++ bool dfs(vector<vector<char>>& board, string& word, int i, int j, int k){ if(k==word.size()) return true; if(i<0||j<0||i>=board.size()||j>=board[0].size()||board[i][j]!=word[k]) return false; char tmp = board[i][j]; board[i][j] = '#'; // mark visited bool found = dfs(board,word,i+1,j,k+1) || dfs(board,word,i-1,j,k+1) || dfs(board,word,i,j+1,k+1) || dfs(board,word,i,j-1,k+1); board[i][j] = tmp; // backtrack return found; }
Complexity: Time O(m ร n ร 4^L), Space O(L) where L = word length
Q15. Sudoku Solver
Asked at: Amazon, Flipkart, DirectiApproach: Try digits 1โ9 in empty cells. Check row, column, and 3ร3 box constraints. Backtrack on conflict.
C++ bool isValid(vector<vector<char>>& b, int r, int c, char d){ for(int i=0; i<9; i++){ if(b[r][i]==d || b[i][c]==d) return false; if(b[r/3*3+i/3][c/3*3+i%3]==d) return false; } return true; } bool solve(vector<vector<char>>& b){ for(int i=0;i<9;i++) for(int j=0;j<9;j++) if(b[i][j]=='.'){ for(char d='1';d<='9';d++){ if(isValid(b,i,j,d)){ b[i][j]=d; if(solve(b)) return true; b[i][j]='.'; } } return false; } return true; }
Complexity: Time O(9^(empty cells)), Space O(81)
๐ Pattern 4: Dynamic Programming (5 Questions)
Q16. Longest Common Subsequence (LCS)
Asked at: Google, Amazon, IntuitApproach: Classic 2D DP. If chars match, dp[i][j] = dp[i-1][j-1]+1; else max of dp[i-1][j], dp[i][j-1].
C++ int longestCommonSubsequence(string a, string b) { int m=a.size(), n=b.size(); vector<vector<int>> dp(m+1, vector<int>(n+1, 0)); for(int i=1; i<=m; i++) for(int j=1; j<=n; j++) dp[i][j] = a[i-1]==b[j-1] ? dp[i-1][j-1]+1 : max(dp[i-1][j], dp[i][j-1]); return dp[m][n]; }
Complexity: Time O(m ร n), Space O(m ร n) [can optimize to O(n)]
Q17. 0/1 Knapsack Problem
Asked at: Flipkart, Samsung, PaytmApproach: For each item, choose to include (if weight allows) or exclude. Tabulate bottom-up.
C++ int knapsack(vector<int>& wt, vector<int>& val, int W) { int n = wt.size(); vector<vector<int>> dp(n+1, vector<int>(W+1, 0)); for(int i=1; i<=n; i++) for(int w=0; w<=W; w++){ dp[i][w] = dp[i-1][w]; if(wt[i-1]<=w) dp[i][w] = max(dp[i][w], val[i-1]+dp[i-1][w-wt[i-1]]); } return dp[n][W]; }
Complexity: Time O(n ร W), Space O(n ร W)
Q18. Longest Increasing Subsequence (LIS)
Asked at: Google, Microsoft, AtlassianApproach: O(n log n) using binary search with a tails array. Maintain the smallest possible tail for each LIS length.
C++ int lengthOfLIS(vector<int>& nums) { vector<int> tails; for(int x : nums){ auto it = lower_bound(tails.begin(), tails.end(), x); if(it == tails.end()) tails.push_back(x); else *it = x; } return tails.size(); }
Complexity: Time O(n log n), Space O(n)
Q19. Coin Change โ Minimum coins to make amount
Asked at: Amazon, Razorpay, PhonePeApproach: DP where dp[i] = minimum coins needed for amount i. Try each coin denomination.
C++ int coinChange(vector<int>& coins, int amount) { vector<int> dp(amount+1, amount+1); dp[0] = 0; for(int i=1; i<=amount; i++) for(int c : coins) if(c <= i) dp[i] = min(dp[i], dp[i-c]+1); return dp[amount] > amount ? -1 : dp[amount]; }
Complexity: Time O(amount ร coins), Space O(amount)
Q20. Edit Distance (Levenshtein Distance)
Asked at: Google, Meta, DirectiApproach: 2D DP. dp[i][j] = min operations to convert word1[0..i-1] to word2[0..j-1].
C++ int minDistance(string a, string b) { int m=a.size(), n=b.size(); vector<vector<int>> dp(m+1, vector<int>(n+1)); for(int i=0; i<=m; i++) dp[i][0] = i; for(int j=0; j<=n; j++) dp[0][j] = j; for(int i=1; i<=m; i++) for(int j=1; j<=n; j++){ if(a[i-1]==b[j-1]) dp[i][j] = dp[i-1][j-1]; else dp[i][j] = 1 + min({dp[i-1][j], dp[i][j-1], dp[i-1][j-1]}); } return dp[m][n]; }
Complexity: Time O(m ร n), Space O(m ร n)
๐ด Pattern 5: Number Theory / Math (5 Questions)
Q21. Sieve of Eratosthenes โ Generate all primes up to N
Asked at: Samsung, Zoho, TCS NQTApproach: Mark multiples of each prime starting from 2. Only need to check up to โN.
C++ vector<bool> sieve(int n) { vector<bool> is_prime(n+1, true); is_prime[0] = is_prime[1] = false; for(int i=2; i*i<=n; i++) if(is_prime[i]) for(int j=i*i; j<=n; j+=i) is_prime[j] = false; return is_prime; }
Complexity: Time O(n log log n), Space O(n)
Q22. GCD using Euclidean Algorithm
Asked at: Infosys, Wipro, CapgeminiApproach: GCD(a, b) = GCD(b, a % b). Base case: GCD(a, 0) = a.
C++ int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } // LCM(a,b) = (a / gcd(a,b)) * b (avoid overflow)
Complexity: Time O(log(min(a,b))), Space O(log(min(a,b))) recursive / O(1) iterative
Q23. Modular Exponentiation (Fast Power)
Asked at: Codeforces, CodeChef, GoogleApproach: Binary exponentiation: a^b = (a^(b/2))ยฒ if even, a ร a^(b-1) if odd. All mod p.
C++ long long power(long long a, long long b, long long mod) { long long res = 1; a %= mod; while(b > 0){ if(b & 1) res = res * a % mod; a = a * a % mod; b >>= 1; } return res; }
Complexity: Time O(log b), Space O(1)
Q24. Count Trailing Zeros in N!
Asked at: Amazon, Flipkart, ZohoApproach: Count factors of 5 in N! โ N/5 + N/25 + N/125 + ...
C++ int trailingZeros(int n) { int count = 0; while(n >= 5){ count += n / 5; n /= 5; } return count; }
Complexity: Time O(logโ n), Space O(1)
Q25. Check if a Number is Power of Two
Asked at: TCS NQT, Infosys, MicrosoftApproach: A power of 2 has exactly one bit set. n & (n-1) removes the lowest set bit โ if result is 0, it's a power of 2.
C++ bool isPowerOfTwo(int n) { return n > 0 && (n & (n - 1)) == 0; }
Complexity: Time O(1), Space O(1)
๐ฃ Pattern 6: Sorting / Searching (5 Questions)
Q26. Binary Search โ Search in Rotated Sorted Array
Asked at: Amazon, Google, UberApproach: Modified binary search. Determine which half is sorted, then check if target lies in that half.
C++ int search(vector<int>& nums, int target) { int l=0, r=nums.size()-1; while(l <= r){ int mid = l+(r-l)/2; if(nums[mid]==target) return mid; if(nums[l] <= nums[mid]){ if(target >= nums[l] && target < nums[mid]) r = mid-1; else l = mid+1; } else { if(target > nums[mid] && target <= nums[r]) l = mid+1; else r = mid-1; } } return -1; }
Complexity: Time O(log n), Space O(1)
Q27. Merge Sort โ Count Inversions in Array
Asked at: Google, Goldman Sachs, FlipkartApproach: During merge step of merge sort, count when right element is placed before left elements.
C++ long long mergeCount(vector<int>& arr, int l, int r){ if(l >= r) return 0; int mid = (l+r)/2; long long inv = mergeCount(arr,l,mid) + mergeCount(arr,mid+1,r); vector<int> tmp; int i=l, j=mid+1; while(i<=mid && j<=r){ if(arr[i]<=arr[j]) tmp.push_back(arr[i++]); else{ tmp.push_back(arr[j++]); inv += mid-i+1; } } while(i<=mid) tmp.push_back(arr[i++]); while(j<=r) tmp.push_back(arr[j++]); for(int k=l; k<=r; k++) arr[k]=tmp[k-l]; return inv; }
Complexity: Time O(n log n), Space O(n)
Q28. Kth Largest Element (Quick Select)
Asked at: Meta, Amazon, MicrosoftApproach: Partition like Quick Sort. If pivot index = n-k, found. Else search in appropriate half.
C++ int findKthLargest(vector<int>& nums, int k) { int n = nums.size(); nth_element(nums.begin(), nums.begin()+n-k, nums.end()); return nums[n-k]; } // STL nth_element uses Introselect: avg O(n), worst O(n)
Complexity: Time O(n) average, Space O(1)
Q29. Merge K Sorted Lists / Arrays
Asked at: Google, Amazon, UberApproach: Use a min-heap (priority queue). Push first element of each list. Pop min, push next from that list.
C++ // Merging K sorted vectors vector<int> mergeKSorted(vector<vector<int>>& lists) { // {value, list_index, element_index} priority_queue<tuple<int,int,int>, vector<tuple<int,int,int>>, greater<>> pq; for(int i=0; i<lists.size(); i++) if(!lists[i].empty()) pq.push({lists[i][0], i, 0}); vector<int> res; while(!pq.empty()){ auto [val, li, ei] = pq.top(); pq.pop(); res.push_back(val); if(ei+1 < lists[li].size()) pq.push({lists[li][ei+1], li, ei+1}); } return res; }
Complexity: Time O(N log K), Space O(K) where N = total elements, K = number of lists
Q30. Find Peak Element
Asked at: Microsoft, Amazon, PhonePeApproach: Binary search. If mid > mid+1, peak is in left half (including mid). Else in right half.
C++ int findPeakElement(vector<int>& nums) { int l = 0, r = nums.size()-1; while(l < r){ int mid = l + (r-l)/2; if(nums[mid] > nums[mid+1]) r = mid; else l = mid + 1; } return l; }
Complexity: Time O(log n), Space O(1)
Part 4: Career Guidance for Competitive Programmers
4.1 Codeforces / CodeChef Profile Optimization
๐ Your CP Profile = Your Resume
Codeforces Profile Checklist:
โ Real name (not a meme handle) โ recruiters need to identify you
โ Organization: "BCA Student at [College Name]" or "B.Tech CSE at [University]"
โ City: Add your city โ helps with local job matching
โ Contribution: +ve contribution shows you're an active community member (write editorials!)
โ Consistent contest participation: Minimum 1 contest/week. Rating curve should trend upward
โ Blogs: Write 2โ3 editorials for problems you solved โ shows communication skills
CodeChef Profile Checklist:
โ Link GitHub and LinkedIn accounts
โ Earn badges: Problem Setter, Contest Winner, etc.
โ Complete the "Practice" section problems by difficulty
4.2 LinkedIn for Competitive Programmers
๐ LinkedIn Headline Formula
Formula: [Role Target] | [CP Achievement] | [Tech Stack]
Example: "Aspiring SDE | Codeforces Expert (1650+) | C++ โข Python โข DSA | 500+ Problems Solved"
About Section Template:
Text
๐ Competitive Programmer | Codeforces Expert (1650+) | CodeChef 4โ
๐ 500+ problems solved across Codeforces, LeetCode, and CodeChef
๐ป Proficient in C++, Python, Data Structures & Algorithms
๐ฏ Key Achievements:
โข Codeforces Expert (1600+) โ Top 8% globally
โข Ranked in Top 500 in CodeChef Starters #128
โข Built 6 algorithm visualization projects (links below)
๐ง Technical Skills:
โข Languages: C++, Python, Java
โข DS/Algo: DP, Graphs, Trees, Number Theory, Segment Trees
โข Tools: Git, VS Code, GDB
๐ซ Open to SDE roles and internships.
Email: your.email@gmail.com
4.3 How Top Indian Companies Hire via CP
| Company | Hiring Channel | What They Look For | Typical CTC (Fresher) |
|---|---|---|---|
| Google Kickstart, Google Code Jam, direct referral | Codeforces 1800+ (CM), strong problem solving | โน25โ45 LPA | |
| Meta | Meta HackerCup, direct application | HackerCup Round 2+, LeetCode hard problems | โน30โ50 LPA |
| Amazon | Amazon CodeDev, OA (Online Assessment) | LeetCode medium-hard, system design basics | โน15โ25 LPA |
| Flipkart | Flipkart Grid, campus hiring | Codeforces 1400+, CodeChef 3โ + | โน15โ22 LPA |
| Razorpay | Direct application, referrals, off-campus | Strong CP profile, problem-solving speed | โน14โ22 LPA |
| Atlassian | Online test + interviews | LeetCode medium, system design | โน25โ40 LPA |
| PhonePe | Hiring challenges, referrals | Codeforces 1400+, practical coding ability | โน12โ20 LPA |
| TCS Digital | TCS CodeVita, TCS NQT | CodeVita National Rank, aptitude | โน7โ9 LPA |
4.4 CP Rating to Salary Mapping (Indian Market 2024โ25)
| CP Rating (Codeforces) | Equivalent Level | Expected Salary Range | Companies in Range |
|---|---|---|---|
| 1200โ1400 (Pupil/Specialist) | Clears most OA rounds | โน4โ8 LPA | TCS, Infosys, Wipro, Cognizant |
| 1400โ1600 (Specialist/Expert) | Clears product company interviews | โน8โ18 LPA | Flipkart, Razorpay, PhonePe, Paytm, Swiggy |
| 1600โ1900 (Expert/CM) | Strong problem solver | โน15โ30 LPA | Google, Amazon, Microsoft, Atlassian |
| 1900โ2200 (CM/Master) | Elite competitive programmer | โน25โ50 LPA | Google, Meta, Tower Research, DE Shaw |
| 2200+ (Master/GM) | World-class | โน40โ80+ LPA | Google L4+, HFT firms, Quant firms |
4.5 Cold Email Template for SDE Applications
๐ง Cold Email Template That Gets Responses
Email Template
Subject: BCA Grad | Codeforces Expert (1650+) | Interested in SDE Role at [Company]
Hi [Name],
I'm [Your Name], a recent BCA graduate from [College], Jaipur. I've been
following [Company]'s engineering blog and was impressed by [specific
technical post or product feature].
I'm a competitive programmer with:
โข Codeforces Expert rating: 1650+ (Top 8% globally)
โข 500+ problems solved on Codeforces + LeetCode
โข 6 algorithm visualization projects on GitHub: [link]
I noticed [Company] is hiring for SDE-1 roles. I believe my strong
problem-solving skills and project portfolio make me a good fit.
Would you be open to a 10-minute chat or could you refer me to the
hiring team?
Resume: [Google Drive link]
GitHub: [link]
Codeforces: [link]
LinkedIn: [link]
Thank you for your time!
Best regards,
[Your Name]
[Phone Number]
Tips: Send to engineering managers, not HR. Find them on LinkedIn. Mention something specific about the company. Follow up once after 5 days. Send 10โ20 per week.
Learn by Doing โ 3-Tier Lab Structure
๐ข Tier 1 โ GUIDED TASK: Set Up Your CP Ecosystem
Step 1: Create Codeforces Account
Go to codeforces.com โ Click "Register" โ Use your real name โ Set organization to "[Your College]"
Step 2: Create CodeChef Account
Go to codechef.com โ Sign up โ Link your GitHub account โ Complete your profile
Step 3: Create LeetCode Account
Go to leetcode.com โ Sign up โ Start with "Top Interview 150" problem set
Step 4: Set Up Your Local Environment
Terminal # Install C++ compiler (if not already installed) # Windows: Install MinGW or use WSL # Mac: xcode-select --install # Linux: sudo apt install g++ # Create your CP workspace mkdir competitive-programming cd competitive-programming mkdir codeforces leetcode codechef # Create a template file cat > template.cpp << 'EOF' #include <bits/stdc++.h> using namespace std; #define ll long long #define vi vector<int> #define pii pair<int,int> #define all(x) x.begin(),x.end() #define fast ios::sync_with_stdio(0);cin.tie(0); void solve(){ // Your solution here } int main(){ fast int t; cin >> t; while(t--) solve(); } EOF echo "Template created! Ready to compete."
Step 5: Solve Your First 5 Problems
Go to Codeforces โ Problemset โ Sort by difficulty (800) โ Solve these 5:
| # | Problem | Rating | Topic |
|---|---|---|---|
| 1 | Watermelon (4A) | 800 | Math / Implementation |
| 2 | Way Too Long Words (71A) | 800 | Strings |
| 3 | Team (231A) | 800 | Implementation |
| 4 | Next Round (158A) | 800 | Implementation |
| 5 | Domino Piling (50A) | 800 | Math |
๐ Congratulations! You now have accounts on 3 major platforms, a local setup, and 5 solved problems. You're officially a competitive programmer!
๐ก Tier 2 โ SEMI-GUIDED TASK: Participate in a Live Contest
Your Mission:
Participate in a Codeforces Div. 2 contest (or a Virtual Contest if no live contest is happening).
Strategy Guide:
- Before the contest: Open your template.cpp. Have a browser tab with C++ reference ready.
- First 5 minutes: Read all problems A through E. Mark them ๐ข๐ก๐ด.
- Solve A within 10 minutes. If it's simple implementation, submit fast.
- Solve B within 20 minutes. Check edge cases before submitting.
- Attempt C: If stuck for 15 min, move to D if it looks doable.
- After contest: Read editorials for ALL problems. Upsolve C and D.
๐ด Tier 3 โ OPEN CHALLENGE: Deploy Your CP Portfolio Website
The Brief:
Create and deploy a personal portfolio website showcasing your competitive programming journey. It should include:
- Hero Section: Name, CP handles (linked), current ratings, tagline
- Projects Section: 6 portfolio projects with descriptions, tech stacks, and GitHub/demo links
- Achievements: Contest participations, best ranks, badges earned
- Problem Statistics: Problems solved by topic (embed Codeforces/LeetCode stats)
- Resume Download: PDF resume button
- Contact Section: Email, LinkedIn, GitHub links
Deployment: Use GitHub Pages (free) or Vercel (free). Your site URL should be yourname.github.io
Cross-Unit Synthesis Problems
These problems require combining concepts from multiple units. They test your ability to choose the right approach from your entire algorithmic toolkit.
๐งฉ Problem 1: Efficient Event Scheduler (Units 1 + 4 + 6)
Problem: Given N events with start times, end times, and profit values, find the maximum profit subset of non-overlapping events.
Synthesis:
โข Unit 6 (Sorting): Sort events by end time
โข Unit 4 (DP): dp[i] = max(dp[i-1], profit[i] + dp[last_non_overlapping])
โข Unit 1 (Complexity): Use binary search for finding last non-overlapping โ O(n log n)
This is a real interview question asked at Google and Amazon.
๐งฉ Problem 2: Optimized Prime Factor Knapsack (Units 2 + 5)
Problem: Given N items where weights are prime factorizations, find the maximum value subset where the product of selected weights doesn't exceed W.
Synthesis:
โข Unit 2 (Number Theory): Prime factorize each weight. Use log-space to convert product constraint to sum constraint
โข Unit 5 (Knapsack): Apply 0/1 knapsack on log(weights) with capacity log(W)
This transforms a multiplicative constraint into an additive one โ a powerful technique.
๐งฉ Problem 3: Maze Solver with Checkpoints (Units 3 + 6)
Problem: Solve a maze from start to end, but you must visit K checkpoints in any order. Find the shortest path.
Synthesis:
โข Unit 3 (Backtracking): Generate all permutations of checkpoint visit order (K! possibilities)
โข Unit 6 (Sorting/BFS): For each pair of checkpoints, precompute shortest path using BFS
โข Combine: TSP-like DP on bitmask over checkpoints โ O(2^K ร Kยฒ + nรm)
This is a bitmask DP problem โ a favorite in Codeforces Div 1 contests.
๐งฉ Problem 4: String Matching with Edit Budget (Units 3 + 4)
Problem: Given a text and pattern, find all positions where the pattern occurs with at most K edits (insertions, deletions, substitutions).
Synthesis:
โข Unit 4 (DP): Edit distance computation for each starting position
โข Unit 3 (Backtracking): Pruning positions where partial edit distance already exceeds K
โข Optimization: Sliding window on the DP table for O(n ร m) instead of O(n ร m ร K)
๐งฉ Problem 5: Competitive Rating Predictor (Units 1 + 4 + 6)
Problem: Given your past contest performances (rank, problem count), predict your Codeforces rating after the next contest using ELO calculation.
Synthesis:
โข Unit 6 (Sorting): Sort contestants by current rating for ranking calculation
โข Unit 1 (Complexity): Optimize the expected rank calculation from O(nยฒ) to O(n log n)
โข Unit 2 (Math): Implement the ELO formula with expected vs actual performance
Build this as a portfolio project โ it shows you understand both algorithms AND competitive programming!
MCQ Assessment Bank โ 30 Cross-Unit Questions (Bloom's Mapped)
Remember / Identify (Q1โQ5)
What is the time complexity of the Sieve of Eratosthenes to find all primes up to N?
- O(Nยฒ)
- O(N log log N)
- O(N log N)
- O(โN)
In Codeforces, a user with rating 1600 falls under which tier?
- Pupil
- Specialist
- Expert
- Candidate Master
What does "upsolving" mean in competitive programming?
- Solving problems faster than others
- Solving problems you couldn't solve during the contest, after the contest ends
- Solving problems in a higher division
- Solving problems without looking at editorials
The time complexity of Merge Sort is:
- O(nยฒ)
- O(n log n)
- O(n)
- O(log n)
In the 0/1 Knapsack problem, each item can be:
- Used unlimited times
- Used at most once
- Split into fractions
- Used exactly twice
Understand / Explain (Q6โQ10)
Why should you read ALL problems before starting to code in a contest?
- To impress the judges
- Because later problems might be easier for you than earlier ones
- Because you can only submit once
- To count the total number of problems
Why does Kadane's algorithm work in O(n) time for maximum subarray sum?
- It uses binary search
- It only processes each element once, tracking running max and current sum
- It uses a hash map
- It sorts the array first
Why is n & (n-1) == 0 a valid check for power of 2?
- It divides n by 2
- A power of 2 has exactly one set bit, and n-1 flips all bits from that position, making AND = 0
- It checks if n is even
- It counts the number of bits
In backtracking, why do we "undo" our choices after exploring a branch?
- To save memory
- To restore the state for exploring other branches
- To make the code faster
- To avoid compiler errors
What is the advantage of bottom-up DP (tabulation) over top-down DP (memoization)?
- It's always faster
- It avoids recursion overhead and stack overflow for large inputs
- It uses less memory
- It's easier to code
Apply (Q11โQ15)
Given an array [3, 1, 4, 1, 5, 9, 2, 6], what is the length of the Longest Increasing Subsequence?
- 3
- 4
- 5
- 6
You need to find if a sum of 15 can be formed using coins [1, 5, 10, 25]. What is the minimum number of coins?
- 2
- 3
- 5
- 6
After applying Kadane's algorithm on [-2, 1, -3, 4, -1, 2, 1, -5, 4], the maximum subarray sum is:
- 4
- 5
- 6
- 7
How many solutions does the 4-Queens problem have?
- 1
- 2
- 4
- 8
Given strings "ABCBDAB" and "BDCAB", the LCS length is:
- 3
- 4
- 5
- 2
Analyze (Q16โQ20)
A problem has constraints N โค 10โถ. Which algorithm complexity is suitable?
- O(Nยฒ)
- O(N log N)
- O(2^N)
- O(Nยณ)
Why is Quick Sort generally faster than Merge Sort in practice despite both being O(N log N)?
- Quick Sort has lower constant factors and is cache-friendly (in-place)
- Quick Sort uses less memory
- Quick Sort is easier to implement
- Merge Sort has bugs
A Codeforces problem gives TLE with O(Nยฒ) but passes with O(N log N). What technique most likely helped?
- Using printf instead of cout
- Sorting + binary search or merge sort-based approach
- Using smaller data types
- Adding more test cases
Compare the space complexity of BFS vs DFS for traversing a binary tree with N nodes:
- BFS: O(N), DFS: O(N) โ both always same
- BFS: O(width), DFS: O(height) โ depends on tree shape
- BFS: O(1), DFS: O(N)
- BFS: O(log N), DFS: O(log N) โ always balanced
Which problem-solving pattern should you try FIRST when you see a new problem in a contest?
- Dynamic Programming
- Greedy approach
- Brute force on small inputs
- Binary search
Evaluate (Q21โQ25)
A student has solved 500 problems on LeetCode but has never participated in a live contest. Is this an effective CP strategy?
- Yes, problem count is all that matters
- No, live contests build time pressure skills and contest strategy that pure practice cannot
- Yes, companies only check problem count
- No, LeetCode problems are not useful
You're building a portfolio. Which is more impressive to recruiters?
- 6 well-documented projects with live demos on GitHub
- 20 simple "Hello World" variations
- A single massive project with no documentation
- Screenshots of solved problems without code
Evaluate: "Competitive programming is only about speed, not code quality." Is this true?
- True โ only AC (Accepted) matters
- Partially true โ in contests speed matters, but in interviews clean code is crucial
- False โ code quality always matters
- True โ companies don't care about code quality
A student wants to prepare for Google SDE-1. Which combination is most effective?
- Only LeetCode grinding (1000+ problems)
- Codeforces contests + LeetCode top patterns + 3 projects + mock interviews
- Only reading algorithm textbooks
- Only attending hackathons
Assess: Is Python a good language for competitive programming?
- Yes, it's the best for all CP problems
- Good for prototyping and math problems, but too slow for tight time limits in C++-era contests
- No, it cannot be used at all
- Only for beginners
Create (Q26โQ30)
Design a practice plan for a beginner who wants to reach Codeforces Specialist (1400) in 3 months. Which schedule is best?
- Solve 10 random problems daily
- 2โ3 problems/day (sorted by topic) + 1 contest/week + upsolve after each contest
- Only participate in contests, no practice
- Read editorials without implementing
You want to create a "Sorting Visualizer" project. Which tech stack combination is most appropriate?
- Python + Tkinter
- HTML/CSS/JavaScript + Canvas API
- Java + Swing
- C++ + OpenGL
You're writing a GitHub README for your DP visualizer project. Which section is MOST important for recruiters?
- License information
- A clear "Features" section with screenshots and a live demo link
- List of contributors
- Installation instructions for Linux only
Design a cold email strategy for SDE applications. What should the subject line contain?
- "Need a job urgently"
- [Your degree] | [Key achievement] | Interested in [Role] at [Company]
- "Please hire me"
- No subject line needed
Create a 90-day CP improvement plan. What should Week 1 focus on?
- Segment trees and advanced graph algorithms
- Setting up accounts, solving easy problems (800โ1000 rating), and understanding the platform
- Participating in Div. 1 contests immediately
- Learning 5 programming languages
Short Answer Questions (8 Questions)
SA-1. Explain the "First 10 Minutes" contest strategy with at least 3 steps.
Model Answer: The first 10 minutes of a contest should be spent strategically: (1) Read ALL problem statements without coding โ scanning input/output examples to understand what's being asked. (2) Mentally categorize each problem: green (definitely solvable), yellow (maybe solvable), red (unlikely in this contest). (3) Start with the easiest green problem โ not necessarily Problem A, but whichever you're most confident about. This prevents wasting time on a tricky A while ignoring an easy C. (4) Estimate time for each solvable problem to plan your 2-hour window. Top competitive programmers emphasize that these first 10 minutes determine the entire contest outcome.
SA-2. Compare Codeforces and LeetCode as platforms for job preparation in India.
Model Answer: Codeforces is a competitive programming platform with ELO-based ratings, regular contests (2โ3/week), and problems that test algorithmic thinking, number theory, and creative problem-solving. It's valued by top companies like Google and Flipkart who check CP profiles. LeetCode focuses on interview-style problems organized by patterns (arrays, DP, trees, graphs), with a "Top Interview 150" list that directly maps to what Amazon, Microsoft, and Meta ask. For Indian job seekers, the ideal combination is: Codeforces for building a visible competitive profile + LeetCode for targeted interview preparation. Codeforces gets you noticed; LeetCode gets you hired.
SA-3. What is "upsolving" and why is it the most effective CP learning technique?
Model Answer: Upsolving is the practice of solving problems you failed during a contest, after the contest ends, using editorials and discussions. It's the most effective technique because: (1) You've already spent time thinking about the problem, so the editorial makes more sense. (2) It fills specific knowledge gaps exposed during the contest. (3) It builds your pattern recognition for similar problems in future contests. (4) It converts a "failed attempt" into a learning experience. Top competitive programmers spend more time upsolving than competing. The rule is: after every contest, upsolve at least 1โ2 problems you couldn't solve.
SA-4. Describe the "Brute Force โ Observe โ Optimize โ Reduce" problem-solving framework.
Model Answer: This is a 4-step framework for approaching any competitive programming problem: (1) Brute Force โ Write a simple solution that checks all possibilities, even if O(2^n). This works for small inputs and validates understanding. (2) Observe โ Run brute force on small inputs, print intermediate results, and look for patterns (mathematical formula, recurrence, greedy property). (3) Optimize โ Apply algorithmic techniques: memoization (DP), sorting + binary search, prefix sums, sliding window, or two pointers to reduce complexity. (4) Reduce โ Recognize that the problem maps to a known problem type (shortest path โ Dijkstra, substring matching โ KMP, subset selection โ Knapsack). This framework prevents getting stuck by providing a structured approach.
SA-5. Why are portfolio projects important for BCA graduates seeking SDE roles?
Model Answer: Portfolio projects are critical for BCA graduates because: (1) They compensate for the perceived "tier gap" โ projects prove you can build, regardless of college brand. (2) They demonstrate practical skills: a sorting visualizer shows you understand algorithms AND frontend development. (3) They provide talking points in interviews: "Tell me about a project" is a common question. (4) Deployed projects (GitHub Pages/Vercel) show you can deliver working products, not just write code. (5) Well-documented READMEs show engineering maturity and communication skills. A BCA graduate with 6 solid GitHub projects is more attractive than a B.Tech graduate with zero projects.
SA-6. How do you decide when to skip a problem during a live contest?
Model Answer: Skip a problem when: (1) You've been stuck for 15โ20 minutes with no clear approach โ diminishing returns set in. (2) The implementation will take 100+ lines and you have less than 30 minutes left. (3) You're getting Wrong Answer on a late test case and can't identify the edge case after 2โ3 tries. (4) A simpler problem later in the set matches your strengths better. The key rule: a solved easy problem is always worth more than time wasted on an unsolved hard one. After skipping, come back if time permits. After the contest, upsolve the skipped problem.
SA-7. Explain the CP rating-to-salary correlation in the Indian job market.
Model Answer: In India, CP ratings correlate with salary ranges: Pupil/Specialist (1200โ1600) typically clears OA rounds at service companies (โน4โ8 LPA at TCS, Infosys). Expert (1600โ1900) cracks product company interviews (โน8โ18 LPA at Flipkart, Razorpay). Candidate Master (1900+) opens doors to top-tier companies (โน25โ50 LPA at Google, Amazon, HFT firms). However, rating alone isn't sufficient โ companies also evaluate system design knowledge, communication skills, and project experience. A Specialist with strong projects and interview skills can outperform a Master with poor communication.
SA-8. What makes a good GitHub README for a portfolio project?
Model Answer: A good README includes: (1) Clear project title with emoji and one-line description. (2) Features section listing 4โ5 key capabilities. (3) Screenshots or GIF showing the project in action โ visual impact matters. (4) Tech stack listed clearly (languages, frameworks, libraries). (5) Live demo link (deployed URL). (6) Setup instructions (3โ4 commands max to run locally). (7) Author section with links to Codeforces/LinkedIn profiles. The README is your project's "resume" โ recruiters judge projects by READMEs, not source code. A well-written README takes 30 minutes but increases project impact 10ร.
Long Answer Questions (3 Questions)
LA-1. Design a complete 6-month competitive programming training plan for a BCA student starting from scratch. Include weekly milestones, tools, and expected outcomes. (15 marks)
Model Answer:
Month 1 โ Foundations: Set up Codeforces/LeetCode accounts. Learn C++ STL (vectors, maps, sets, sorting). Solve 60 problems (rating 800โ1000). Topics: basic math, implementation, strings. Participate in 4 contests (target: solve A). Expected rating: 800โ900.
Month 2 โ Core DSA: Learn arrays, two pointers, binary search, basic recursion. Solve 60 problems (rating 1000โ1200). Build Project 1 (Complexity Analyzer) and Project 2 (Sieve Visualizer). Participate in 4 contests (target: solve A+B). Expected rating: 1000โ1100.
Month 3 โ Intermediate Algorithms: Learn sorting algorithms, backtracking, basic DP (Fibonacci, coin change, knapsack). Solve 60 problems (rating 1100โ1400). Build Project 3 (N-Queens Solver) and Project 4 (DP Visualizer). Participate in 4 contests (target: solve A+B consistently). Expected rating: 1100โ1300.
Month 4 โ Advanced DP & Optimization: Master LCS, LIS, matrix chain, interval DP. Learn greedy algorithms. Solve 50 problems (rating 1200โ1500). Build Project 5 (Knapsack/LIS/LCS Demo). Start LeetCode "Top Interview 150." Expected rating: 1300โ1400.
Month 5 โ Contest Performance: Focus on contest strategy, time management, upsolving. Learn graphs (BFS, DFS, shortest path). Solve 50 problems. Build Project 6 (Sorting Visualizer). Participate in 4+ contests. Deploy portfolio website. Expected rating: 1400โ1500.
Month 6 โ Interview Prep & Job Hunt: Solve top 30 interview questions by pattern. Practice mock interviews (Pramp, peers). Optimize LinkedIn/Codeforces profiles. Send 50+ cold emails. Apply via CodeDev, Kickstart, etc. Target: Specialist (1400+), 6 projects on GitHub, 3+ interview calls.
LA-2. Compare and contrast three problem-solving patterns (DP, Greedy, Backtracking) with examples. When should you use each? (15 marks)
Model Answer:
Dynamic Programming (DP): Used when a problem has overlapping subproblems and optimal substructure. The solution to the overall problem can be built from solutions to smaller subproblems. Example: 0/1 Knapsack โ choosing items to maximize value given weight constraint. DP stores subproblem results to avoid recomputation. Time: typically O(n ร W) for knapsack. Use DP when: the problem asks for "count", "minimum", "maximum", or "is it possible" and involves choices with constraints.
Greedy: Used when making the locally optimal choice at each step leads to the globally optimal solution. Simpler and faster than DP but not always correct. Example: Activity Selection โ always pick the activity with earliest end time. Time: O(n log n) for sorting + O(n) for selection. Use greedy when: a greedy choice property can be proven (usually involves sorting by some criterion first). Common greedy mistakes: assuming greedy works without proof.
Backtracking: Used when you need to explore all valid configurations (exhaustive search with pruning). Builds solutions incrementally and abandons invalid paths. Example: N-Queens โ try placing queens row by row, backtrack when a conflict is found. Time: typically exponential but pruning makes it practical. Use backtracking when: the problem asks "find all solutions" or the solution space is a tree of choices.
Key Differences: DP remembers past results (memoization), greedy commits to choices without looking back, backtracking explores and reverts. DP guarantees optimality, greedy may not (but is faster when it works), backtracking finds all solutions but is slowest.
LA-3. Explain how competitive programming skills translate to real-world software engineering, using examples from Indian tech companies. (15 marks)
Model Answer:
Algorithm Design: CP problems train you to design efficient algorithms under constraints โ the same skill needed when a Flipkart engineer must optimize search ranking to handle 100 million products in milliseconds. The difference between O(nยฒ) and O(n log n) can mean the difference between a feature that works and one that crashes under load.
Time Pressure & Debugging: In CP contests, you have 2 hours to solve 5 problems, debug edge cases, and handle stress. This directly transfers to production incident handling at companies like Razorpay where payment gateway issues must be diagnosed and fixed within minutes โ every minute of downtime costs lakhs.
Pattern Recognition: After solving 500+ problems, you develop pattern recognition: "This API rate-limiting problem is essentially a sliding window." At Swiggy, delivery route optimization is essentially a variant of the Travelling Salesman Problem. At Paytm, fraud detection uses graph algorithms to find suspicious transaction clusters.
Code Quality Under Constraints: Writing correct code the first time (few bugs, handles edge cases) is a CP skill that saves weeks of debugging in production. Amazon India values this โ their bar raiser interviews test specifically for this ability.
Problem Decomposition: CP teaches breaking complex problems into subproblems. This is exactly how microservice architecture works at companies like PhonePe โ each service solves one subproblem, and the overall system combines them.
Indian Context: Many Indian startups (Razorpay, Zerodha, CRED) have competitive programmers as founding engineers. Their engineering culture values algorithmic thinking. CP skills give Indian students from tier-2/3 colleges a path to these companies that traditional campus placement doesn't provide.
Portfolio Lab โ Build Your Complete CP Portfolio
This section ties together all the project work from Sections C and D. Use the project descriptions, README templates, and deployment guides from the concepts section to build your complete portfolio.
๐ Portfolio Completion Checklist
โ All 6 projects built and pushed to GitHub with READMEs
โ At least 3 projects deployed with live demo links (GitHub Pages / Vercel)
โ Codeforces account active with 50+ problems solved
โ LeetCode account with 30+ problems solved (by pattern)
โ Portfolio website deployed at yourname.github.io
โ LinkedIn profile optimized with CP achievements
โ Resume updated with projects, ratings, and achievements
โ 5 cold emails drafted and ready to send
Industry Spotlight โ Competitive Programmer Turned Google SDE
๐จโ๐ป Vikram Sahu, 23 โ SDE at Google Bangalore
Background: B.Tech from a tier-3 college in Indore, MP. Started competitive programming in 2nd year after attending a DSA workshop. Had no coding experience before college โ his first program was "Hello World" in C.
The Journey:
Year 1: Learned basic C/C++, struggled with even basic loops. Codeforces rating: 0.
Year 2 (Sem 3): Discovered Codeforces. Solved 3 problems/day for 6 months. Rating: 800 โ 1200.
Year 2 (Sem 4): Focused on DP and graphs. Participated in Google Kickstart Round A. Rating: 1200 โ 1500.
Year 3 (Sem 5): Reached Expert (1650). Built 4 algorithm visualization projects. Started LeetCode for interview prep.
Year 3 (Sem 6): Applied to Google through Kickstart portal. Cleared 3 interview rounds. Offer: โน32 LPA.
What he says: "Nobody from my college had ever gone to Google. They said it was impossible without IIT/NIT. I proved them wrong with consistent effort and a visible online profile. My Codeforces graph โ 18 months of green squares โ convinced the hiring committee more than any certificate could."
| Detail | Info |
|---|---|
| Total Problems Solved | 800+ (Codeforces: 450, LeetCode: 250, CodeChef: 100+) |
| Peak Codeforces Rating | 1850 (Candidate Master) |
| Key Projects | Sorting Visualizer, DP Table Visualizer, Competitive Programming Tracker Chrome Extension |
| Contest Participations | 80+ Codeforces contests, 3 Google Kickstart rounds |
| Time Investment | 2โ3 hours/day for 18 months |
| Salary (2024) | โน32 LPA + RSUs + benefits |
Earn With It โ Multiple Income Paths
๐ฐ Your Earning Paths After This Course
Path 1: SDE Jobs (Full-time)
With Codeforces Specialist+ rating and portfolio projects โ โน8โ25 LPA at product companies
Path 2: Freelance Problem Setting
Set problems for CodeChef, HackerEarth, HackerRank โ โน1,500โโน5,000 per problem
Path 3: CP Coaching / Tutoring
Teach competitive programming to juniors on platforms like Topmate, Preplaced โ โน500โโน2,000/hour
Path 4: Technical Content Writing
Write editorials, tutorials, algorithm explainers for blogs, YouTube โ โน5,000โโน20,000/month
Path 5: Contest Prize Money
Win CodeChef/Codeforces contests โ โน5,000โโน50,000 per contest win
| Earning Path | Requirements | Monthly Potential | Time to Start |
|---|---|---|---|
| SDE Job | CF 1400+, 6 projects, interviews | โน65Kโโน2L/month (CTC) | 3โ6 months |
| Problem Setting | CF 1600+, strong problem design skills | โน10Kโโน50K/month | 4โ6 months |
| CP Coaching | CF 1400+, teaching ability | โน20Kโโน80K/month | 2โ3 months |
| Content Writing | Good writing + CP knowledge | โน5Kโโน20K/month | 1โ2 months |
| Contest Prizes | CF 1800+, top contest performance | Variable (โน5Kโโน50K) | 6โ12 months |
Chapter Summary
๐ Unit 7 Capstone โ Key Takeaways
Contest Strategy: Read all problems first (10 min), sort by YOUR difficulty, solve easy ones fast, skip after 20 min of no progress, always upsolve after contests.
Problem-Solving Framework: Brute Force โ Observe Pattern โ Optimize โ Reduce to Known Problem. This 4-step approach works for any problem.
Rating Systems: Codeforces (ELO, global standard) + LeetCode (interview-focused) = winning combo for Indian job market.
Portfolio Projects: 6 projects from Units 1โ6 โ Complexity Analyzer, Sieve Visualizer, N-Queens Solver, DP Visualizer, Knapsack Demo, Sorting Benchmarker. All deployed with GitHub READMEs.
Interview Preparation: 30 questions across 6 patterns (Array, Two Pointer, Backtracking, DP, Number Theory, Sorting). Master these patterns = 80% of coding interviews covered.
Career Paths: SDE jobs (โน8โ50 LPA), problem setting, CP coaching, content creation. Multiple income streams possible.
The Formula: Consistent Practice (2โ3 problems/day) + Contest Participation (1/week) + Visible Profile (Codeforces + GitHub) + Projects (6 deployed) + Networking (LinkedIn + cold emails) = Career Launch ๐
Earning Checkpoint โ Are You Ready?
| Skill / Topic | Tools Used | Portfolio Piece | Earn-Ready? |
|---|---|---|---|
| Complexity Analysis (Unit 1) | Custom Web Tool | Complexity Analyzer Project | โ Yes โ demonstrates understanding |
| Number Theory (Unit 2) | JavaScript, Canvas | Prime Sieve Visualizer | โ Yes โ deploy on GitHub Pages |
| Backtracking (Unit 3) | HTML/CSS/JS | N-Queens / Sudoku Solver | โ Yes โ impressive visual project |
| Dynamic Programming (Unit 4) | JavaScript, D3.js | DP Table Visualizer | โ Yes โ shows deep understanding |
| Greedy / Optimization (Unit 5) | JavaScript, Chart.js | Knapsack/LIS/LCS Demo | โ Yes โ interactive and educational |
| Sorting (Unit 6) | Canvas, Web Workers | Sorting Visualizer & Benchmarker | โ Yes โ most visually impactful |
| Contest Strategy (Unit 7) | Codeforces, LeetCode | Rating graph + contest history | โ Yes โ proves consistent effort |
| Interview Prep (Unit 7) | LeetCode patterns | 30 solved pattern problems | โ Yes โ ready for SDE interviews |
| Portfolio Website (Unit 7) | HTML/CSS/JS, GitHub Pages | Complete portfolio site | โ Yes โ your job-hunting weapon |
| Career Outreach (Unit 7) | LinkedIn, Email | Optimized profiles + cold emails | โ Yes โ start applying NOW |
๐ Appendix A: Complexity Cheat Sheet (All Big-O with Examples)
| Big-O | Name | Example | N=10โถ Operations | Verdict |
|---|---|---|---|---|
O(1) | Constant | Array access, hash lookup | 1 | โ Instant |
O(log n) | Logarithmic | Binary search | 20 | โ Very fast |
O(โn) | Square root | Trial division primality | 1,000 | โ Fast |
O(n) | Linear | Linear search, Kadane's | 10โถ | โ Fast |
O(n log n) | Linearithmic | Merge sort, sort() | 2ร10โท | โ OK |
O(nโn) | โ | Mo's algorithm | 10โน | โ ๏ธ Tight |
O(nยฒ) | Quadratic | Bubble sort, nested loops | 10ยนยฒ | โ TLE |
O(nยฒ log n) | โ | Some DP + binary search combos | 2ร10ยนยณ | โ TLE |
O(nยณ) | Cubic | Floyd-Warshall, matrix mult | 10ยนโธ | โ Way TLE |
O(2โฟ) | Exponential | Subset enumeration | 10ยณโฐโฐโฐโฐโฐ | โ Impossible |
O(n!) | Factorial | Permutation generation | โ | โ Only nโค12 |
๐ Appendix B: Common DP Patterns Quick Reference
| Pattern | Recurrence | Classic Problems | Complexity |
|---|---|---|---|
| Linear DP | dp[i] = f(dp[i-1], dp[i-2], ...) | Fibonacci, Climbing Stairs, House Robber | O(n) |
| Knapsack | dp[i][w] = max(skip, take) | 0/1 Knapsack, Subset Sum, Coin Change | O(n ร W) |
| LCS / Edit Distance | dp[i][j] from dp[i-1][j-1], dp[i-1][j], dp[i][j-1] | LCS, Edit Distance, Interleaving String | O(m ร n) |
| LIS | Binary search on tails array | LIS, Russian Doll Envelopes | O(n log n) |
| Interval DP | dp[i][j] = merge(dp[i][k], dp[k+1][j]) | Matrix Chain, Burst Balloons, Palindrome Partition | O(nยณ) |
| Bitmask DP | dp[mask] over subsets | TSP, Assignment Problem | O(2โฟ ร n) |
| Digit DP | dp[pos][tight][state] | Count numbers with property in [L, R] | O(digits ร states) |
| Tree DP | dp[node] from dp[children] | Diameter of Tree, Max Independent Set | O(n) |
๐ Appendix C: Sorting Algorithm Comparison Table
| Algorithm | Best Case | Average | Worst Case | Space | Stable? | Best For |
|---|---|---|---|---|---|---|
| Bubble Sort | O(n) | O(nยฒ) | O(nยฒ) | O(1) | โ Yes | Teaching only |
| Selection Sort | O(nยฒ) | O(nยฒ) | O(nยฒ) | O(1) | โ No | Minimum swaps needed |
| Insertion Sort | O(n) | O(nยฒ) | O(nยฒ) | O(1) | โ Yes | Nearly sorted data, small n |
| Merge Sort | O(n log n) | O(n log n) | O(n log n) | O(n) | โ Yes | Linked lists, stable sort needed |
| Quick Sort | O(n log n) | O(n log n) | O(nยฒ) | O(log n) | โ No | General purpose (fastest avg) |
| Heap Sort | O(n log n) | O(n log n) | O(n log n) | O(1) | โ No | Guaranteed O(n log n), low space |
| Counting Sort | O(n+k) | O(n+k) | O(n+k) | O(k) | โ Yes | Small range integers |
| Radix Sort | O(d(n+k)) | O(d(n+k)) | O(d(n+k)) | O(n+k) | โ Yes | Fixed-length integers/strings |
sort() (C++ STL IntroSort) or sorted() (Python TimSort). These are hybrid algorithms optimized for real-world data. You'll rarely implement sorting from scratch in contests โ but understanding how they work is essential for interview questions and optimization decisions.
๐ Appendix D: Top 30 Interview Questions โ Quick Reference
| # | Problem | Pattern | Complexity | Asked At |
|---|---|---|---|---|
| 1 | Two Sum | Hash Map | O(n) | Amazon, Google |
| 2 | Maximum Subarray (Kadane's) | DP / Greedy | O(n) | Microsoft, Razorpay |
| 3 | Longest Substring Without Repeating | Sliding Window | O(n) | Amazon, Adobe |
| 4 | Next Permutation | Array | O(n) | Google, Flipkart |
| 5 | Rotate Array | Array Reversal | O(n) | TCS, Infosys |
| 6 | Container With Most Water | Two Pointer | O(n) | Amazon, PhonePe |
| 7 | 3Sum | Sort + Two Pointer | O(nยฒ) | Facebook, Atlassian |
| 8 | Minimum Window Substring | Sliding Window | O(n) | Google, Uber |
| 9 | Trapping Rain Water | Two Pointer | O(n) | Amazon, Goldman |
| 10 | Longest Repeating Char Replacement | Sliding Window | O(n) | Microsoft, Flipkart |
| 11 | Permutations | Backtracking | O(n!) | Google, Zoho |
| 12 | N-Queens | Backtracking | O(n!) | Google, Apple |
| 13 | Subset Sum | DP / Backtracking | O(nรS) | Amazon, Samsung |
| 14 | Word Search | DFS + Backtracking | O(mรnร4^L) | Microsoft, Uber |
| 15 | Sudoku Solver | Backtracking | O(9^cells) | Amazon, Directi |
| 16 | Longest Common Subsequence | 2D DP | O(mรn) | Google, Intuit |
| 17 | 0/1 Knapsack | 2D DP | O(nรW) | Flipkart, Samsung |
| 18 | Longest Increasing Subsequence | DP + Binary Search | O(n log n) | Google, Atlassian |
| 19 | Coin Change | 1D DP | O(nรamt) | Amazon, Razorpay |
| 20 | Edit Distance | 2D DP | O(mรn) | Google, Meta |
| 21 | Sieve of Eratosthenes | Number Theory | O(n log log n) | Samsung, Zoho |
| 22 | GCD (Euclidean) | Math | O(log n) | Infosys, Wipro |
| 23 | Modular Exponentiation | Binary Exponentiation | O(log n) | Codeforces, Google |
| 24 | Trailing Zeros in N! | Math | O(log n) | Amazon, Zoho |
| 25 | Power of Two Check | Bit Manipulation | O(1) | TCS, Microsoft |
| 26 | Search in Rotated Array | Binary Search | O(log n) | Amazon, Uber |
| 27 | Count Inversions (Merge Sort) | Divide & Conquer | O(n log n) | Google, Goldman |
| 28 | Kth Largest Element | Quick Select | O(n) avg | Meta, Amazon |
| 29 | Merge K Sorted Lists | Heap / Priority Queue | O(N log K) | Google, Uber |
| 30 | Find Peak Element | Binary Search | O(log n) | Microsoft, PhonePe |
๐ Appendix E: 20 Practice Problems (Unsolved with Hints)
These problems are for self-practice. Try solving them without looking at the solutions. Hints are provided to guide your thinking.
| # | Problem | Difficulty | Topic | Hint |
|---|---|---|---|---|
| 1 | Product of Array Except Self | Medium | Array / Prefix | Can you solve without division? Think prefix and suffix products. |
| 2 | Valid Parentheses | Easy | Stack | Use a stack. Push opening brackets, pop on closing. Match types. |
| 3 | Merge Intervals | Medium | Sorting | Sort by start time. Merge overlapping intervals greedily. |
| 4 | Climbing Stairs (n steps, 1 or 2 at a time) | Easy | DP | It's literally Fibonacci. dp[i] = dp[i-1] + dp[i-2]. |
| 5 | Longest Palindromic Substring | Medium | DP / Expand | Expand around center for each character. O(nยฒ) is acceptable. |
| 6 | Binary Tree Level Order Traversal | Medium | BFS | Use a queue. Process one level at a time. |
| 7 | Group Anagrams | Medium | Hash Map | Sort each string โ use as key in hash map. |
| 8 | Course Schedule (detect cycle in DAG) | Medium | Graph / Topo Sort | Topological sort using BFS (Kahn's algo). If sorted size โ n, cycle exists. |
| 9 | Minimum Path Sum in Grid | Medium | DP | dp[i][j] = grid[i][j] + min(dp[i-1][j], dp[i][j-1]). |
| 10 | Decode Ways (count ways to decode digit string) | Medium | DP | Similar to climbing stairs but with valid 1-digit and 2-digit checks. |
| 11 | Maximum Product Subarray | Medium | DP | Track both max and min at each step (negative ร negative = positive). |
| 12 | Find Median in Data Stream | Hard | Heap | Use two heaps: max-heap for lower half, min-heap for upper half. |
| 13 | Serialize and Deserialize Binary Tree | Hard | Tree / DFS | Preorder traversal with null markers. Rebuild using queue. |
| 14 | Largest Rectangle in Histogram | Hard | Stack | Monotonic stack. For each bar, find nearest smaller on left and right. |
| 15 | Regular Expression Matching | Hard | DP | 2D DP. Handle '.' (any char) and '*' (zero or more of prev char). |
| 16 | Count Primes less than N | Easy | Number Theory | Sieve of Eratosthenes. Count true values in boolean array. |
| 17 | Partition Equal Subset Sum | Medium | DP / Knapsack | If total sum is odd โ impossible. Else, find subset with sum = total/2. |
| 18 | Palindrome Partitioning | Medium | Backtracking + DP | Backtrack with palindrome check. Precompute palindrome DP table. |
| 19 | Unique Paths in Grid (with obstacles) | Medium | DP | dp[i][j] = dp[i-1][j] + dp[i][j-1] if no obstacle. Else dp[i][j] = 0. |
| 20 | Minimum Coins for Target (unbounded) | Medium | DP | Like 0/1 knapsack but items can be reused. Inner loop goes forward. |
๐ Appendix F: CP Portfolio Checklist
| Item | Status | Priority | Notes |
|---|---|---|---|
| Codeforces Account | โ Created | ๐ด Critical | Real name, college, city filled. Active contest participation. |
| CodeChef Account | โ Created | ๐ก Important | GitHub linked. Badges earned. |
| LeetCode Account | โ Created | ๐ด Critical | Start with "Top Interview 150" list. |
| GitHub Profile | โ Optimized | ๐ด Critical | Profile photo, bio with CP handles, pinned projects. |
| Project 1: Complexity Analyzer | โ Built โ Deployed โ README | ๐ก Important | Tech: HTML/JS + Python Flask |
| Project 2: Prime Sieve Visualizer | โ Built โ Deployed โ README | ๐ก Important | Tech: HTML/JS + Canvas |
| Project 3: N-Queens Solver | โ Built โ Deployed โ README | ๐ก Important | Tech: HTML/CSS Grid + JS |
| Project 4: DP Table Visualizer | โ Built โ Deployed โ README | ๐ด Critical | Tech: HTML/JS + D3.js |
| Project 5: Knapsack/LIS/LCS Demo | โ Built โ Deployed โ README | ๐ก Important | Tech: JS + Chart.js |
| Project 6: Sorting Visualizer | โ Built โ Deployed โ README | ๐ด Critical | Tech: Canvas + Web Workers |
| Portfolio Website | โ Built โ Deployed | ๐ด Critical | Deploy on GitHub Pages: yourname.github.io |
| LinkedIn Profile | โ Optimized | ๐ด Critical | Headline with CP rating. About section with achievements. |
| Resume (PDF) | โ Created | ๐ด Critical | 1 page. Projects, ratings, skills, education. |
| Cold Email Templates (5) | โ Drafted | ๐ก Important | Personalized for 5 target companies. |
| 50+ Problems Solved (CF) | โ Achieved | ๐ด Critical | Visible on Codeforces profile. |
| 5+ Contests Participated | โ Achieved | ๐ด Critical | Show consistent contest history. |
| Rating Graph Trending Up | โ Achieved | ๐ด Critical | Most important visual indicator for recruiters. |
โ
Competitive Coding: COMPLETE!
You are Contest-Ready & Interview-Ready. ๐
From zero rating to Expert. From zero projects to a deployed portfolio.
From "I can't code" to "I solve problems for a living."
[QR: Link to EduArtha video tutorial โ Competitive Coding Capstone]