20 lines
439 B
Go
20 lines
439 B
Go
// Package q1768 implements a solution for https://leetcode.com/problems/merge-strings-alternately/
|
|
package q1768
|
|
|
|
import "strings"
|
|
|
|
func mergeAlternately(word1 string, word2 string) string {
|
|
builder := strings.Builder{}
|
|
for i := range max(len(word1), len(word2)) {
|
|
if i < len(word1) {
|
|
builder.WriteByte(word1[i])
|
|
}
|
|
if i < len(word2) {
|
|
builder.WriteByte(word2[i])
|
|
}
|
|
}
|
|
|
|
return builder.String()
|
|
}
|
|
|
|
var _ = mergeAlternately
|