How do you decide if you can reach the last index when each value is a max jump length?
Simple meaning
Track the farthest reachable index while scanning left to right
Open the full page for Why, Steps, Example and Key takeaway.
Panel-ready DSA interview set questions for freshers and experienced developers. Practice at Coding Cadre in Faridabad, or Online from Delhi NCR.
Track the farthest reachable index while scanning left to right
Open the full page for Why, Steps, Example and Key takeaway.
If total gas is less than total cost, no start works.
Open the full page for Why, Steps, Example and Key takeaway.
Sort by end time and keep an interval if it starts after or at the last kept end
Open the full page for Why, Steps, Example and Key takeaway.
Sort items by value/weight and take whole items then a fraction of the next, which is optimal for the fractional version.
Open the full page for Why, Steps, Example and Key takeaway.
Slide a min-heap of size k+1: push the next element and pop the min into the result.
Open the full page for Why, Steps, Example and Key takeaway.
There are n!
Open the full page for Why, Steps, Example and Key takeaway.
A geometric resize (double the capacity) copies O(n) elements only occasionally.
Open the full page for Why, Steps, Example and Key takeaway.
Backtrack: at each index either include nums[i] or skip it, recording a copy when i reaches n.
Open the full page for Why, Steps, Example and Key takeaway.
Backtrack by swapping the next position with each remaining candidate, or by choosing unused indices with a used array.
Open the full page for Why, Steps, Example and Key takeaway.
XOR everything
Open the full page for Why, Steps, Example and Key takeaway.
I scan once and store seen values in a hash set or map.
Open the full page for Why, Steps, Example and Key takeaway.
I push opening brackets and pop when a matching closer arrives.
Open the full page for Why, Steps, Example and Key takeaway.
Ordering tasks with prerequisites in a DAG.
Open the full page for Why, Steps, Example and Key takeaway.
Big-O upper-bounds how time or space grow as input size grows, ignoring constants.
Open the full page for Why, Steps, Example and Key takeaway.
Preorder with null markers or level order with queue.
Open the full page for Why, Steps, Example and Key takeaway.
Scan tokens, push numbers, pop operands for operators.
Open the full page for Why, Steps, Example and Key takeaway.
BFS for shortest path in unweighted graphs and level order.
Open the full page for Why, Steps, Example and Key takeaway.
Overlapping subproblems plus optimal substructure.
Open the full page for Why, Steps, Example and Key takeaway.
When you need ongoing top-k or priority extraction.
Open the full page for Why, Steps, Example and Key takeaway.