Leetcode Note: Go - Largest Odd Number in String

Largest Odd Number in String - LeetCode
https://leetcode.com/problems/largest-odd-number-in-string/

  • Go 言語で取り組んだメモ

回答

Go O(n) time O(1) memory one-liner | 0ms | 6.6MB - Largest Odd Number in String - LeetCode
https://leetcode.com/problems/largest-odd-number-in-string/solutions/1288630/go-o-n-time-o-1-memory-one-liner-0ms-6-6mb/

func largestOddNumber(num string) string {
    return strings.TrimRight(num, "02468")
}