DEV Community

Discussion on: Daily Coding Puzzles - Nov 4th - Nov 9th

Collapse
 
thejessleigh profile image
jess unrein

Go

func Last(w string) (result []string) {
    l := strings.Split(w, "")
    result = []string{l[0]}

    for _, item := range l[1:] {
        if val := result[0]; item > val {
            result = append([]string{item}, strings.Join(result, ""))
        } else {
            result = append(result, item)
        }
    }
    return
}