Leetcode Note: Go - Generate a String With Characters That Have Odd Counts

Generate a String With Characters That Have Odd Counts - LeetCode
https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/

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

回答

Go | Time: O(n) / 0 ms / 100% | Space: O(1) / 2.2 MB / 100% - Generate a String With Characters That Have Odd Counts - LeetCode
https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/solutions/1548114/go-time-o-n-0-ms-100-space-o-1-2-2-mb-100/

func generateTheString(n int) string {
    return "b" + strings.Repeat(string('a' + n % 2), n - 1)
}