We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cec2243 commit a318e4fCopy full SHA for a318e4f
house_robber.java
@@ -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
@@ -0,0 +1,25 @@
+ public int[] findErrorNums(int[] nums) {
+ int x[] = new int[nums.length+1];
+
+ for(int i:nums){
+ x[i]++;
+ int dup=0 , miss=0;
+ for(int i=1;i<x.length;i++){
+ if(x[i]==2){
+ 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