2017-05-17 06:43
浏览 203


I try to use golang deal with this problem 557. Reverse Words in a String III my code as below:

import "fmt"
import  ss "strings"

func reverseWords(s string) string {
    words := ss.Split(s," ");
    res := "";
    for i:=0; i < len(words);i++{
        curWord := ss.Split(words[i],"");
        for j:=len(curWord)-1; j >= 0;j--{
            res += curWord[j];
            res += " ";
    return res;

func main(){
    s := "Let's take LeetCode contest";

Everything is ok in my pc, it can pass compile at least.
However, when I submit in leetcode it tell me :

 Line 67: undefined: strings in strings.Trim 

I google this error but get nothing relevant info. As a beginner in golang, I need help. Everything will be appreciated.

2条回答 默认 最新

相关推荐 更多相似问题