Question:
https://leetcode.com/problems/house-robber/ except you need to return indices contributing to the maximum sum and not the maximum sum itself.
Example 1:
Input: [4, 0, 11, 3]
Output: [0, 2]
Explanation: Max sum is 4 + 11 = 15.Example 2:
Input: [2, 7, 9, 3, 1]
Output: [0, 2, 4]
Explanation: Max sum is 2 + 9 + 1 = 12.I solved it by using a dictionary and using running sum as the key and contributing indices as values. It did not seem like an efficient approach. I'm wondering if others have better ideas.
Looking forward to see what others ideas are