Skip to main content
All Questions

Subset Sum.

Unlock detailed company stats for this questionUpgrade

Subset sum with 10 elements. Follow-ups: write test cases including corner cases (empty list, single element equal to target, large numbers, no valid subset); print the actual subset forming the sum; handle a list of 100 elements (backtracking is O(2^n), so use dynamic programming with memoization); discuss time and space complexity.

Expect follow-ups like

  • Write test cases, including corner cases (empty list, single element equal to target, large numbers, no valid subset).
  • Print the actual subset of numbers forming the sum.
  • How would you handle larger inputs, e.g. 100 elements? (Backtracking is O(2^n); proposed DP with memoization for the overlapping subproblems - interviewer asked for the DP implementation, which I wrote but could not execute in time due to time constraints and compilation issues.)

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.