Skip to content

Commit 6ac827e

Browse files
add 3142
1 parent e74e7ca commit 6ac827e

File tree

3 files changed

+46
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+46
-0
lines changed

paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
| 3164 | [Find the Number of Good Pairs II](https://leetcode.com/problems/find-the-number-of-good-pairs-ii/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3164.java) | | Medium |
2424
| 3162 | [Find the Number of Good Pairs I](https://leetcode.com/problems/find-the-number-of-good-pairs-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3162.java) | | Easy |
2525
| 3157 | [Find the Level of Tree with Minimum Sum](https://leetcode.com/problems/find-the-level-of-tree-with-minimum-sum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3157.java) | | Medium |BFS
26+
| 3142 | [Check if Grid Satisfies Conditions](https://leetcode.com/problems/check-if-grid-satisfies-conditions/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3142.java) | | Easy |
2627
| 3131 | [Find the Integer Added to Array I](https://leetcode.com/problems/find-the-integer-added-to-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3131.java) | | Easy |
2728
| 3127 | [Make a Square with the Same Color](https://leetcode.com/problems/make-a-square-with-the-same-color/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3127.java) | | Easy |
2829
| 3120 | [Count the Number of Special Characters I](https://leetcode.com/problems/count-the-number-of-special-characters-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3120.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3142 {
4+
public static class Solution1 {
5+
public boolean satisfiesConditions(int[][] grid) {
6+
for (int i = 0; i < grid.length - 1; i++) {
7+
for (int j = 0; j < grid[0].length; j++) {
8+
if (grid[i][j] != grid[i + 1][j]) {
9+
return false;
10+
}
11+
}
12+
}
13+
for (int i = 0; i < grid.length; i++) {
14+
for (int j = 0; j < grid[0].length - 1; j++) {
15+
if (grid[i][j] == grid[i][j + 1]) {
16+
return false;
17+
}
18+
}
19+
}
20+
return true;
21+
}
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.fourththousand;
2+
3+
import com.fishercoder.solutions.fourththousand._3142;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class _3142Test {
10+
private static _3142.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _3142.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(false, solution1.satisfiesConditions(new int[][]{{1}, {2}, {3}}));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)