Skip to content

Commit a318e4f

Browse files
Add files via upload
1 parent cec2243 commit a318e4f

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

house_robber.java

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public int rob(int[] nums) {
3+
int rob = 0;
4+
int norob = 0;
5+
for (int i = 0; i < nums.length; i ++) {
6+
int newRob = norob + nums[i];
7+
int newNoRob = Math.max(norob, rob);
8+
rob = newRob;
9+
norob = newNoRob;
10+
}
11+
return Math.max(rob, norob);
12+
}
13+
}

set_mismatch.java

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Solution {
2+
public int[] findErrorNums(int[] nums) {
3+
int x[] = new int[nums.length+1];
4+
5+
for(int i:nums){
6+
x[i]++;
7+
}
8+
9+
int dup=0 , miss=0;
10+
11+
for(int i=1;i<x.length;i++){
12+
if(x[i]==2){
13+
dup=i;
14+
}
15+
if(x[i] ==0){
16+
miss=i;
17+
}
18+
}
19+
20+
return new int[]{dup,miss};
21+
22+
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)