Reverse string

Report a typo

Here's Reverse a String, one of the classic tasks of computer science. You get a string and need to output the reversed version. Try to solve it using a Stack structure.

Note that the Stack struct is already declared and set up to store rune values for this task.

Don't think about how to read the input and return an answer, focus on the task. If you are stuck, welcome to the HINT section.

  1. Tip: Push characters one by one;
  2. Tip: Pop it, until the error.

Sample Input 1:

golang

Sample Output 1:

gnalog
Write a program in Go
package main

import (
"fmt"
"errors"
)

func main() {
var input string
// the Stack struct is hidden but already declared
var solver Stack

fmt.Scan(&input)

for _, char := range input {
?
}

for {
?
if ? {
break
}

fmt.Print(string(char))
}

fmt.Println()
}
___

Create a free account to access the full topic