If you're a PHP developer prepping for a coding round, brushing up on data structures and algorithms in a short window is doable. This roadmap assumes you can do about 2–3 problems per day and targets 50+ core problems across arrays, linked lists, trees, graphs, and dynamic programming. Use LeetCode, GeeksForGeeks, or InterviewBit—pick one and stick with it so your progress stays in one place.
Week 1: Arrays and Hashing
Start with arrays and hashing. You'll use sorting, frequency counting, prefix sums, and Kadane's algorithm. PHP's array functions will help, but try to implement logic yourself first.
Day 1–2: Basic arrays and two pointers
- Two Sum (Easy)
- Best Time to Buy and Sell Stock (Easy)
- Contains Duplicate (Easy)
- Remove Duplicates from Sorted Array (Easy)
Day 3–4: Sliding window and prefix sum
- Maximum Subarray (Kadane's Algorithm) (Medium)
- Longest Substring Without Repeating Characters (Medium)
- Sliding Window Maximum (Hard)
Day 5–7: Hash maps and sorting
- Group Anagrams (Medium)
- Valid Anagram (Easy)
- Longest Consecutive Sequence (Medium)
Week 2: Linked Lists, Stacks and Queues
PHP doesn't have a built-in linked list, so implement a simple Node class and practice pointer-style logic. Stacks and queues will feel familiar if you've used array_push/array_pop; the goal here is to see how they solve specific problems.
Day 8–9: Linked list basics
- Reverse Linked List (Easy)
- Merge Two Sorted Lists (Easy)
Day 10–11: Fast and slow pointers
- Linked List Cycle (Medium)
- Find the Middle of Linked List (Easy)
- Remove Nth Node from End of List (Medium)
Day 12–13: Stacks and queues
- Valid Parentheses (Easy)
- Next Greater Element (Medium)
- Implement Queue using Stack (Medium)
Day 14: One harder stack problem
- LRU Cache (Hard)
Week 3: Trees and Graphs
Trees and graphs show up often in interviews. Get comfortable with recursion, then BFS and DFS. PHP's recursion limit can bite you on deep trees, so prefer iterative solutions when the problem allows.
Day 15–16: Tree traversals
- Binary Tree Inorder Traversal (Easy)
- Invert Binary Tree (Easy)
Day 17–18: Binary search trees
- Lowest Common Ancestor of a BST (Medium)
- Diameter of a Binary Tree (Medium)
Day 19–20: Graphs (DFS and BFS)
- Number of Islands (Medium)
- Detect Cycle in Directed Graph (Medium)
Day 21: Shortest path and ordering
- Dijkstra's Algorithm (Shortest Path) (Hard)
- Topological Sorting (Hard)
Week 4: Dynamic Programming and Recursion
DP is usually the trickiest part. Start with recursion and memoization, then move to classic problems like Fibonacci-style, LCS, and knapsack. Don't rush—understanding one pattern helps with the next.
Day 22–23: Recursion and backtracking
- Subsets (Medium)
- Word Search (Medium)
Day 24–25: Basic DP
- Climbing Stairs (Fibonacci-based DP) (Easy)
- Longest Common Subsequence (Medium)
Day 26–27: More DP
- Coin Change (Medium)
- 0/1 Knapsack Problem (Medium)
Day 28: One hard DP-style problem
- N-Queens (Hard)
After the 4 weeks
Spend the following days on mixed practice: pick random Medium and Hard problems, implement a few in PHP to get used to the language in an interview setting, and do at least one full-length timed run (e.g. 90 minutes, 2–3 problems) to simulate the real test.
Tips that helped me as a PHP dev
Use PHP's array functions where they fit—array_map, array_filter, and associative arrays for hashmaps—but avoid relying on them to hide the algorithm. Write clear, step-by-step logic so you can explain it in an interview. Prefer a small OOP layer (e.g. a Node class for linked lists) over one big procedural script. Always test with edge cases: empty input, single element, large n, and negative numbers. If a problem feels impossible, look at the solution only after trying for 20–30 minutes, then implement it yourself the next day without peeking.