Skip to content

Commit a087125

Browse files
add 2980
1 parent 0629e9f commit a087125

File tree

2 files changed

+22
-1
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src/main/java/com/fishercoder/solutions/thirdthousand

2 files changed

+22
-1
lines changed

Diff for: paginated_contents/algorithms/3rd_thousand/README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|------------------------------------------|----------------------------------------------------------------------
3-
| 2996 | [Smallest Missing Integer Greater Than Sequential Prefix Sum](https://leetcode.com/problems/smallest-missing-integer-greater-than-sequential-prefix-sum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2996.java) | | Easy |
3+
| 2996 | [Smallest Missing Integer Greater Than Sequential Prefix Sum](https://leetcode.com/problems/smallest-missing-integer-greater-than-sequential-prefix-sum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2996.java) | | Easy |
4+
| 2980 | [Check if Bitwise OR Has Trailing Zeros](https://leetcode.com/problems/check-if-bitwise-or-has-trailing-zeros/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2980.java) | | Easy | Bit Manipulation
45
| 2976 | [Minimum Cost to Convert String I](https://leetcode.com/problems/minimum-cost-to-convert-string-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2976.java) | | Medium | Graph, Shortest Path
56
| 2974 | [Minimum Number Game](https://leetcode.com/problems/minimum-number-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2974.java) | | Easy |
67
| 2970 | [Count the Number of Incremovable Subarrays I](https://leetcode.com/problems/count-the-number-of-incremovable-subarrays-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2970.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
public class _2980 {
4+
public static class Solution1 {
5+
/**
6+
* 1. bitwise OR can never unset a bit, so if the solution exists, there must be a pair of elements;
7+
* 2. as the rightmost bit must stay unset, it's essentially looking for a pair of two even numbers.
8+
*/
9+
public boolean hasTrailingZeros(int[] nums) {
10+
for (int i = 0; i < nums.length; i++) {
11+
for (int j = i + 1; j < nums.length; j++) {
12+
if (nums[i] % 2 == 0 && nums[j] % 2 == 0) {
13+
return true;
14+
}
15+
}
16+
}
17+
return false;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)