Rishi Srivastava Pseudo code: public int rob(int nums) if 1) return nums0; int dp new dp0 nums0; dp1 MAX(nums1, dp0); for (int i 2; i is less than i++) dpi MAX(numsi + dpi 2, dpi 1); return 1; return Time complexity: O(n) Space complexity: O(n) Leetcode: Github:
0
0
Related videos
Preparing
To view the site materials you should be more than or equal to 18 years old