Created
December 15, 2022 23:14
-
-
Save abdulrahmanAlotaibi/b1838f3cb6626b53d799b88bc10f459e to your computer and use it in GitHub Desktop.
isPalindromic Algorithim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
func main(){ | |
fmt.Println("Is the the string the same if we reverse it ?") | |
fmt.Println(isPalindromic("AHA")) | |
fmt.Println(isPalindromic("Go")) | |
} | |
func isPalindromic(s string)bool{ | |
for i,j := 0, len(s) - 1 ; i < len(s) ; i,j = i+1, j-1 { | |
if s[i] != s[j]{ | |
return false | |
} | |
} | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment