Dashboard Temp Share Shortlinks Frames API

HTMLify

LeetCode - Check If Digits Are Equal in String After Operations I - Go
Views: 357 | Author: abh
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
func hasSameDigits(s string) bool {
    for ;len(s)!=2; {
        var t string
        for i:=0; i<len(s)-1; i++ {
            _s := (int(s[i]-48) + int(s[i+1]-48)) % 10
            t += string(rune(_s+48))
        }
        s = t
    }
    return s[0] == s[1]
}