Skip to content

Commit ee6eed6

Browse files
edit 326
1 parent cba27f1 commit ee6eed6

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ Your ideas/fixes/algorithms are more than welcome!
266266
|329|[Longest Increasing Path in a Matrix](https://leetcode.com/problems/longest-increasing-path-in-a-matrix/)|[Solution](../master/src/main/java/com/fishercoder/solutions/LongestIncreasingPathInAMatrix.java)| O(?)|O(?) | Hard|
267267
|328|[Odd Even Linked List](https://leetcode.com/problems/odd-even-linked-list/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_328.java)| O(n)|O(1) | Medium| Linked List
268268
|327|[Count of Range Sum](https://leetcode.com/problems/count-of-range-sum/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_327.java)| O(?)|O(?) | Hard|
269+
|326|[Power of Three](https://leetcode.com/problems/power-of-three/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_326.java)| O(1)|O(1) | Easy| Math
269270
|325|[Maximum Size Subarray Sum Equals k](https://leetcode.com/problems/maximum-size-subarray-sum-equals-k/)|[Solution] | O(n)|O(n) | Medium| HashMap
270271
|324|[Wiggle Sort II](https://leetcode.com/problems/wiggle-sort-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_324.java)| O(n)|O(n) | Medium| Sort
271272
|323|[Number of Connected Components in an Undirected Graph](https://leetcode.com/problems/number-of-connected-components-in-an-undirected-graph/)|[Solution](../master/src/main/java/com/fishercoder/solutions/NumberOfConnectedComponentsInAnUndirectedGraph.java)| O(?)|O(?)| Medium|

src/main/java/com/fishercoder/solutions/PowerOfThree.java renamed to src/main/java/com/fishercoder/solutions/_326.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
package com.fishercoder.solutions;
2-
/**326. Power of Three QuestionEditorial Solution My Submissions
3-
Total Accepted: 57555
4-
Total Submissions: 151383
5-
Difficulty: Easy
2+
3+
/**326. Power of Three
4+
*
65
Given an integer, write a function to determine if it is a power of three.
76
87
Follow up:
98
Could you do it without using any loop / recursion?
10-
119
*/
1210

13-
public class PowerOfThree {
11+
public class _326 {
1412
//then I turned to the Editorial solution, it's pretty elegant to use base conversion which can be easily extended to any radix k
1513
//Idea: for a number in base 10, if it's power of 10, then it must be in this format: 10, 100, 1000... with a leading one and all trailing zeros
1614
//similarly, if a number is power of 3, then in its base 3 format, it must be in this format as well: 10, 100, 1000, 1000...
@@ -35,7 +33,7 @@ public boolean isPowerOfThree(int n) {
3533
}
3634

3735
public static void main(String...strings){
38-
PowerOfThree test = new PowerOfThree();
36+
_326 test = new _326();
3937
System.out.println(test.isPowerOfThree(12));
4038

4139
//find the max integer that is power of 3

0 commit comments

Comments
 (0)