diff --git a/paginated_contents/algorithms/4th_thousand/README.md b/paginated_contents/algorithms/4th_thousand/README.md index c6032dcbc3..d232646f7f 100644 --- a/paginated_contents/algorithms/4th_thousand/README.md +++ b/paginated_contents/algorithms/4th_thousand/README.md @@ -1,5 +1,6 @@ | # | Title | Solutions | Video | Difficulty | Tag |------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|---------------------------------------------------------------------- +| 3370 | [Smallest Number With All Set Bits](https://leetcode.com/problems/smallest-number-with-all-set-bits/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3370.java) | | Easy | | 3364 | [Minimum Positive Sum Subarray](https://leetcode.com/problems/minimum-positive-sum-subarray/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3364.java) | | Easy | | 3360 | [Stone Removal Game](https://leetcode.com/problems/stone-removal-game/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3360.java) | | Easy | | 3354 | [Make Array Elements Equal to Zero](https://leetcode.com/problems/make-array-elements-equal-to-zero/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3354.java) | | Easy | diff --git a/src/main/java/com/fishercoder/solutions/fourththousand/_3370.java b/src/main/java/com/fishercoder/solutions/fourththousand/_3370.java new file mode 100644 index 0000000000..6e00f12a9a --- /dev/null +++ b/src/main/java/com/fishercoder/solutions/fourththousand/_3370.java @@ -0,0 +1,23 @@ +package com.fishercoder.solutions.fourththousand; + +public class _3370 { + public static class Solution1 { + public int smallestNumber(int n) { + for (int num = n; ; num++) { + if (allSetBits(num)) { + return num; + } + } + } + + private boolean allSetBits(int num) { + String binaryStr = Integer.toBinaryString(num); + for (char c : binaryStr.toCharArray()) { + if (c != '1') { + return false; + } + } + return true; + } + } +}