-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_10157_House_Robber.json
33 lines (33 loc) · 1.34 KB
/
q_10157_House_Robber.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
{
"question": {
"qid": "q_10157",
"diff": 2,
"tags": ["Dynamic Programming"],
"title": "House Robber",
"prompt": [
"You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were broken into on the same night.",
"Given an integer array {{ nums }} representing the amount of money of each house, return the maximum amount of money you can rob tonight without alerting the police."
],
"examples": [
{
"input": "[1,2,3,1]",
"output": "4",
"explanations": [
"Rob house 1 (money = 1) and then rob house 3 (money = 3). Total amount you can rob = 1 + 3 = 4."
]
}
],
"constraints": ["0 <= nums.length <= 100", "0 <= nums[i] <= 400"],
"functionArguments": ["nums"],
"hints": [
"Since you cannot rob adjacent houses, the maximum amount of money can be obtained from robbing either house i or house i - 2."
]
},
"testcases": [
{ "tid": "1", "input": [[1, 2, 3, 1]], "expected": 4 },
{ "tid": "2", "input": [[2, 7, 9, 3, 1]], "expected": 12 }
],
"submitted": 0,
"accepted": 0,
"questionLevel": 5
}