File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
paginated_contents/algorithms/3rd_thousand
src/main/java/com/fishercoder/solutions/thirdthousand Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
| # | Title | Solutions | Video | Difficulty | Tag
2
2
|------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|------------------------------------------|----------------------------------------------------------------------
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
4
5
| 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
5
6
| 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 |
6
7
| 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 number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments