Skip to content

Commit 161c76b

Browse files
authored
update comment for house-robber
1 parent d606f26 commit 161c76b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

house-robber/samcho0608.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
class Solution {
2+
// Problem:
23
// * can't rob two adj houses in the same night
34
// * return: max amount of money robbale in one night
5+
// Solution:
6+
// * Time Complexity: O(N)
7+
// * Space Complexity: O(N)
48
public int rob(int[] nums) {
59
if(nums.length == 1) return nums[0];
610
if(nums.length == 2) return Math.max(nums[0], nums[1]);
711

8-
// maxSum[i] = max sum possible at i (inclusive)
12+
// maxSum[i] = max sum possible with nums[i]
913
int[] maxSum = new int[nums.length];
1014
maxSum[0] = nums[0];
1115
maxSum[1] = nums[1];

0 commit comments

Comments
 (0)