Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9649b7e

Browse files
add 3239
1 parentefd44e5 commit9649b7e

File tree

2 files changed

+33
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+33
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
3+
| 3239|[Minimum Number of Flips to Make Binary Grid Palindromic I](https://leetcode.com/problems/minimum-number-of-flips-to-make-binary-grid-palindromic-i/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3239.java)|| Easy|
34
| 3238|[Find the Number of Winning Players](https://leetcode.com/problems/find-the-number-of-winning-players/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3238.java)|| Easy|
45
| 3237|[Alt and Tab Simulation](https://leetcode.com/problems/alt-and-tab-simulation/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3237.java)|| Medium|
56
| 3234 |[Count the Number of Substrings With Dominant Ones](https://leetcode.com/problems/count-the-number-of-substrings-with-dominant-ones/) |[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3234.java) | | Medium | Sliding Window
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
publicclass_3239 {
4+
publicstaticclassSolution1 {
5+
publicintminFlips(int[][]grid) {
6+
intm =grid.length;
7+
intn =grid[0].length;
8+
intans =m *n;
9+
//try rows first
10+
intflips =0;
11+
for (inti =0;i <m;i++) {
12+
for (intleft =0,right =n -1;left <right;left++,right--) {
13+
if (grid[i][left] !=grid[i][right]) {
14+
flips++;
15+
}
16+
}
17+
}
18+
ans =Math.min(ans,flips);
19+
flips =0;
20+
//try columns now
21+
for (intj =0;j <n;j++) {
22+
for (inttop =0,bottom =m -1;top <bottom;top++,bottom--) {
23+
if (grid[top][j] !=grid[bottom][j]) {
24+
flips++;
25+
}
26+
}
27+
}
28+
ans =Math.min(flips,ans);
29+
returnans;
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp