Code written difference

FOR THE FOLLOWING OUTPUT :
*
**




I HAVE WRITTEN THIS CODE

public static void pattern1(int n,int row,int col) {
if(row>n) {
return;
}

for(int i=1;i<=col;i++) {
	System.out.print("*");
}
System.out.println();
pattern1(n,row+1,col+1);

}

IS THIS CODE CORRECT, AS THE CODE SOLUTION SHOWN IN VIDEO IS A LITTLE CONFUSING.

yes this is right
only you are printing one extra empty row at start
remove that by adding

    if(row!=0){
            System.out.println();
    }

if this solves your doubt please mark it as resolved :slight_smile: