I think there is no new-line at the end.
Here is C++ solution:
stringpattern(intnumber){stringpat="";// there is no new-line at the end so loop end is number-1for(inti=1;i<=number-1;i++){for(intj=0;j<i;j++)pat+=to_string(i);// add the string version of numberpat+="\n";// add a new-line after adding the numbers each time }// add the case of number at the end with no new-linefor(inti=0;i<number;i++)pat+=to_string(number);returnpat;}
I think there is no new-line at the end.
Here is C++ solution:
Python one liner :