All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g0001_0100.s0009_palindrome_number.solution.go Maven / Gradle / Ivy

There is a newer version: 1.8
Show newest version
package s0009_palindrome_number

// #Easy #Math #Udemy_Integers #2024_03_07_Time_0_ms_(100.00%)_Space_4.3_MB_(99.46%)

func isPalindrome(x int) bool {
	if x < 10 {
		return x >= 0
	}
	if x%10 == 0 {
		return false
	}
	a, b := x, 0
	for a > b {
		a, b = a/10, b*10+a%10
	}
	return a == b || a == b/10
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy