← Cohesity Interview Insights

Cohesity·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jul 2026

Summary

Cohesity software engineer interview with a classic backtracking problem. Nothing too exotic but you need to actually know your recursion cold or you'll fumble the edge cases.

Questions Asked (1)

Q1

Given an array of distinct positive integers and a target value, find all unique combinations of numbers from the array that sum to the target. A number can be reused as many times as needed, but two combinations that contain the same numbers in different orders count as one.

Algorithms & Data Structures
Author's notes

The unlimited reuse part is what trips people up.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a backtracking algorithm that builds combinations incrementally, ensuring each combination is non-decreasing to avoid duplicates. At each step, choose a number from the array (starting from the current index) and recurse with the remaining target, allowing reuse of the same number. When the target becomes zero, add the current combination to the result; if the target becomes negative, backtrack.

Pro tip: Sort the input array first to enable efficient pruning: if the current number exceeds the remaining target, you can break out of the loop early. Also, emphasize that by always choosing numbers from the current index onward, you naturally avoid permutations and generate only unique combinations.

1. Clarify and Sort

Confirm that the array contains distinct positive integers and that combinations are unordered. Sort the array to facilitate duplicate avoidance and pruning.

2. Define Recursive Backtracking

Design a recursive function that takes the current index, remaining target, and current combination. Iterate from the current index to the end of the array, adding each number to the combination and recursing with the same index (to allow reuse) and reduced target.

3. Base Cases and Pruning

If the remaining target is zero, add the current combination to the result. If the remaining target becomes negative, stop the recursion. Also, if the current number exceeds the remaining target, break the loop (since the array is sorted).

4. Avoid Duplicates

By iterating from the current index and not looking back, ensure that each combination is generated in non-decreasing order, thus avoiding permutations. No additional set is needed because the input has distinct numbers.

5. Analyze Complexity

Discuss the time complexity, which is exponential in the worst case (e.g., O(N^(T/M)) where N is the number of elements, T is the target, and M is the smallest element). Mention that space complexity is proportional to the recursion depth and the output size.

Key Points to Mention

  • Backtracking approach with recursion
  • Sorting the array for pruning and duplicate avoidance
  • Allowing reuse of the same number by recursing with the same index
  • Avoiding permutations by enforcing non-decreasing order in combinations
  • Base cases: target == 0 (add to result) and target < 0 (backtrack)
  • Time and space complexity analysis

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.