From 1f2626d9616cd8fc6fb9fc6c0a6b5cd815a6b183 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Wed, 23 Aug 2023 10:17:07 +0800 Subject: [PATCH 1/3] feat: add solutions to lc problem: No.1611 --- .../README.md | 49 +++++++++++++++++++ .../README_EN.md | 49 +++++++++++++++++++ 2 files changed, 98 insertions(+) diff --git a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md index 098ff4c4d7d1e..d4b875b712a74 100644 --- a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md +++ b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md @@ -91,6 +91,14 @@ class Solution: return ans ``` +```python +class Solution: + def minimumOneBitOperations(self, n: int) -> int: + if n == 0: + return 0 + return n ^ self.minimumOneBitOperations(n >> 1) +``` + ### **Go** @@ -107,6 +115,17 @@ class Solution { } ``` +```java +class Solution { + public int minimumOneBitOperations(int n) { + if (n == 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); + } +} +``` + ### **C++** ```cpp @@ -122,6 +141,18 @@ public: }; ``` +```cpp +class Solution { +public: + int minimumOneBitOperations(int n) { + if (n == 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); + } +}; +``` + ### **Go** ```go @@ -133,6 +164,15 @@ func minimumOneBitOperations(n int) (ans int) { } ``` +```go +func minimumOneBitOperations(n int) int { + if n == 0 { + return 0 + } + return n ^ minimumOneBitOperations(n>>1) +} +``` + ### **TypeScript** ```ts @@ -145,6 +185,15 @@ function minimumOneBitOperations(n: number): number { } ``` +```ts +function minimumOneBitOperations(n: number): number { + if (n === 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); +} +``` + ### **...** ``` diff --git a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md index f11e4e0869cf3..350504f0333c8 100644 --- a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md +++ b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md @@ -59,6 +59,14 @@ class Solution: return ans ``` +```python +class Solution: + def minimumOneBitOperations(self, n: int) -> int: + if n == 0: + return 0 + return n ^ self.minimumOneBitOperations(n >> 1) +``` + ### **Java** ```java @@ -73,6 +81,17 @@ class Solution { } ``` +```java +class Solution { + public int minimumOneBitOperations(int n) { + if (n == 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); + } +} +``` + ### **C++** ```cpp @@ -88,6 +107,18 @@ public: }; ``` +```cpp +class Solution { +public: + int minimumOneBitOperations(int n) { + if (n == 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); + } +}; +``` + ### **Go** ```go @@ -99,6 +130,15 @@ func minimumOneBitOperations(n int) (ans int) { } ``` +```go +func minimumOneBitOperations(n int) int { + if n == 0 { + return 0 + } + return n ^ minimumOneBitOperations(n>>1) +} +``` + ### **TypeScript** ```ts @@ -111,6 +151,15 @@ function minimumOneBitOperations(n: number): number { } ``` +```ts +function minimumOneBitOperations(n: number): number { + if (n === 0) { + return 0; + } + return n ^ minimumOneBitOperations(n >> 1); +} +``` + ### **...** ``` From 6bdb791c266b5693cc6829e842ce0bcea10b4238 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Wed, 23 Aug 2023 10:24:37 +0800 Subject: [PATCH 2/3] fix: format py --- .../README.md | 2 +- .../README_EN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md index d4b875b712a74..6b3db2da3d761 100644 --- a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md +++ b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md @@ -95,7 +95,7 @@ class Solution: class Solution: def minimumOneBitOperations(self, n: int) -> int: if n == 0: - return 0 + return 0 return n ^ self.minimumOneBitOperations(n >> 1) ``` diff --git a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md index 350504f0333c8..92212f9ee7614 100644 --- a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md +++ b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README_EN.md @@ -63,7 +63,7 @@ class Solution: class Solution: def minimumOneBitOperations(self, n: int) -> int: if n == 0: - return 0 + return 0 return n ^ self.minimumOneBitOperations(n >> 1) ``` From aee80e662c4ba85f137cc98c1330a42ac00c94f6 Mon Sep 17 00:00:00 2001 From: thinkasany <480968828@qq.com> Date: Wed, 23 Aug 2023 10:28:50 +0800 Subject: [PATCH 3/3] fix: md title --- .../README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md index 6b3db2da3d761..f239083ea8625 100644 --- a/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md +++ b/solution/1600-1699/1611.Minimum One Bit Operations to Make Integers Zero/README.md @@ -99,7 +99,7 @@ class Solution: return n ^ self.minimumOneBitOperations(n >> 1) ``` -### **Go** +### **Java**