Runtime Error


  • 0
    V
    class Solution {
    public:
        string convert(string s, int numRows) {
            string result;
            string lines[numRows];
            int i = -1;
            int len = s.length();
            while(i < len){
                for(int j = 0; j < numRows; j++){
                    lines[j] += s[++i];
                }
                for(int k = 1; k < numRows; k += 2){
                    lines[k] += s[++i];
                }
            }
            for(int j = 0; j<numRows; j++)
                result += lines[j];
            
            return result;
        }
    };
    

    Hi i am getting runtime error on this code and i am not able to understand what is the issue. I ran it on my system and an online ide and it gives correct answer. Please help


Log in to reply
 

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