I think my answer has no problem,but "Submission Result: Wrong Answer" was kidding me


  • 0
    W

    string convert(string s, int numRows) {

        if (s.size()<numRows||numRows==1) return s;
        string result = "";
        int lenth=s.size();
        for(int i=0;i<numRows;i++){
            if(i==0||i==numRows-1){
                for(int j=i;j<lenth;j=j+2*(numRows-1)) result.push_back(s[j]);
            }
            else{
                for(int j=i;j<lenth;j=j+2*(numRows-i-1)){
                    result.push_back(s[j]);
                    j=j+2*i;
                    result.push_back(s[j]);
                }
            }
        }
        return result;
    }
    

    Submission Result: Wrong AnswerMore Details

    Input:
    "ABC", 3
    Output:
    "ABC"
    Expected:
    "ABC"


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.