As reported: Visa software engineer (.NET/Angular stack), technical round 1 (2026): resume questions on .NET/C# and Angular, then with the remaining time a DSA question similar to House Robber — a brute-force solution first, then the optimized one. Also asked in another Visa loop (2025) as the second question of a DSA and problem-solving interview, after a binary-search problem.
nums[i] is the money in house i along a street. Two adjacent houses cannot both be taken. Return the most money you can collect.
This is LeetCode 198 — House Robber.
Example
nums = [1,2,3,1] -> 4 (houses 0 and 2)
nums = [2,7,9,3,1] -> 12 (houses 0, 2 and 4)
Constraints: 1 ≤ nums.length ≤ 100; 0 ≤ nums[i] ≤ 400.
Code runner format: one JSON value per line: nums. Implement rob(nums); the harness prints the amount.