79821080

Date: 2025-11-15 19:46:26
Score: 0.5
Natty:
Report link

I found the error. It is in the case of left-justifying the last line. My available spaces are getting to negative, and I'm getting stuck there until memory exhausts.

updated portion of the code:

                if(isLastLine){
                    for(String word: mapping.words){
                        sb.append(word);
                        currentWordCount++;
                        if(currentWordCount < wordcount){
                            sb.append(" ");
                        }
                      }
                      int remaining = availableSpaces - minSpaces;  
                      while(remaining > 0){
                        sb.append(" ");
                        remaining -= 1;
                      }
                }
Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: satya