INVERTED Mirrored RIGHT ANGLE TRIANGLE PATTERN

Let us see another famous interview pattern – Inverted Mirrored Right Angle Triangle Pattern.

public class Tech4Humans {

	public static void main(String[] args) {

		// length of triangle
		int size = 5;

		for (int i = 0; i < size; i++) {
			for (int j = 0; j < i; j++) {
				System.out.print(" ");
			}
			for (int k = 0; k < (size - i); k++) {
				System.out.print("*");
			}
			System.out.println();
		}

	}

}
*****
 ****
  ***
   **
    *

Writing above code’s logic correctly during interviews or exams will create a good impression. To understand above code’s logic easily visit RIGHT WAY TO DEBUG CODE USING PEN AND PAPER.

Leave a Comment