Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Math/PowerOfFour.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/**
* Question Link: https://leetcode.com/problems/power-of-four/
* Primary idea: Use log properties to solve the problem
* Time Complexity: O(1), Space Complexity: O(1)
*
*/

class PowerOfFour {
func isPowerOfFour(_ num: Int) -> Bool {
return (log(Double(num))/log(4.0)).truncatingRemainder(dividingBy: 1) == 0
}
}