Skip to content

Instantly share code, notes, and snippets.

class Solution {
func fib(_ N: Int) -> Int {
return self.recursiveWay(N)
}
func recursiveWay(_ N: Int) -> Int {
if N == 0 { return 0 }
@wangdu1005
wangdu1005 / Is_Palindrome.swift
Created June 12, 2019 07:58
We divided the input by 10 for every iteration, so the time complexity is O(log10(n)) Space complexity : O(1).
class Solution {
func isPalindrome(_ x: Int) -> Bool {
return self.reverseWay(x)
}
// Recommanded
func reverseWay(_ x: Int) -> Bool {