I accounted for negative values as inputs

I accounted for negative values but since, in the Question is not specifically mention, what to do in case of negative value. I simply skipped it. can you please mention in the question , what needed to print for negative value.

@sushant4573,

n will never be negative.

In the given pattern if row number is n (>1), total character is n. First and last character is n-1 and rest are 0.

Always first Try to first print pattern by ignoring the value to be printed then accommodate your value in that pattern.

No some testcases failed , for which suggestion popped up as “have you covered negative values”?

Dang! You couldn’t score a perfect 100 because you failed one or more testcases. This means that your program didn’t account for all input cases (did you account for negative numbers, for example?).

simply whats the output for -5?. is it just 0

@sushant4573,

https://ide.codingblocks.com/s/222664 Corrected code.

You don’t need to use hasNext with PrintWriter pw.