We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
At first, I created the matrix for the first quadrant and used a lot of lines to print it in order and reverse order. But later, I saw that the AI's code was much more concise. That's when I realized the pattern: the value of each element is n - d, where d is the minimum distance from the element to the matrix boundary.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Printing Pattern Using Loops
You are viewing a single comment's thread. Return to all comments →
At first, I created the matrix for the first quadrant and used a lot of lines to print it in order and reverse order. But later, I saw that the AI's code was much more concise. That's when I realized the pattern: the value of each element is n - d, where d is the minimum distance from the element to the matrix boundary.