Skip to content

Commit 2c8c2bc

Browse files
Merge pull request PawanJaiswal08#18 from kishanrajput23/newcodes
Added 268.Missing_Number.java
2 parents a4ec1bc + 9751fd5 commit 2c8c2bc

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

268.Missing_Number.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public int missingNumber(int[] nums) {
3+
int n = nums.length;
4+
int sum = (n * (n+1)) / 2;
5+
for(int i=0; i<n; i++) {
6+
sum -= nums[i];
7+
}
8+
return sum;
9+
}
10+
}

832.Flipping_an_Image.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int[][] flipAndInvertImage(int[][] image) {
3+
for(int i=0;i<image.length;i++){
4+
int low = 0;
5+
int high = image.length-1;
6+
while(low<=high){
7+
if(image[i][low]==image[i][high])
8+
image[i][low]=image[i][high] = 1-image[i][low];
9+
low++;
10+
high--;
11+
}
12+
}
13+
return image;
14+
}
15+
}

0 commit comments

Comments
 (0)