Answer: Twitter SWE Interview Question 2022 July | Backtracking | on-campus
Answer · Posted Jun 2026
Solution: Backtracking with Reuse and Target Reduction Approach Use backtracking starting from a given index in candidates. At each step, try adding each candidate starting from the current index (not from the beginning — this prevents duplicate combinations like [3,2] after [2,3]). Since elements can be reused, recurse with the same index (not index+1) after picking a candidate. Subtract the candidate from the remaining target on each pick. If remaining target equals 0, a valid combination is found. If remaining ...
The full answer & interview discussion are available to premium members.
Log in Create a free account