You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* In essence, this is the same as House Robber: https://leetcode.com/problems/house-robber/
15
+
* Notes:
16
+
* 1. In essence, this is the same as House Robber: https://leetcode.com/problems/house-robber/
17
+
* 2. We are adding the number itself into values, instead of its frequency because we will directly use this value to compute the result
14
18
*/
15
19
publicintdeleteAndEarn(int[] nums) {
16
20
intn = 10001;
@@ -30,4 +34,29 @@ public int deleteAndEarn(int[] nums) {
30
34
returnMath.max(take, skip);
31
35
}
32
36
}
37
+
38
+
publicstaticclassSolution2 {
39
+
/**
40
+
* A simplified version using treemap instead of an array, credit: https://leetcode.com/problems/delete-and-earn/discuss/109895/JavaC++-Clean-Code-with-Explanation/111626
0 commit comments