hii ๐ i am trying to get diagonal elements of a 2d array with 1d indexing and was able to get the top-left to bottom-right of the array using the r * colNum + c, but i am having trouble with getting the formula for the top-right to bottom-left diagonal.
i've tried r * (colNum - 1 - c) but it did not work:
16 2 3 13 5 11 10 8 9 7 6 12 4 14 15 1
the formula gives me 16 3 3 16
anyone knows what the correct formula for the top-right -> bottom-left diagonal is?
thank you in advance!๐