Skip to content

Commit deffcd9

Browse files
authored
Add Solution 2: concise Java implementation for 504. Base 7
1 parent b91312c commit deffcd9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

solution/0500-0599/0504.Base 7/README_EN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,25 @@ impl Solution {
166166

167167
<!-- tabs:end -->
168168

169+
### Solution 2: Concise Implementation (Integer.toString)
170+
171+
We can directly use Java’s built-in base conversion method.
172+
Time complexity: $O(\log_7 n)$, space complexity: $O(1)$.
173+
174+
<!-- tabs:start -->
175+
176+
#### Java
177+
178+
```java
179+
class Solution {
180+
public String convertToBase7(int num) {
181+
return Integer.toString(num, 7);
182+
}
183+
}
184+
```
185+
186+
<!-- tabs:end -->
187+
169188
<!-- solution:end -->
170189

171190
<!-- problem:end -->

0 commit comments

Comments
 (0)