+ 2
[đ»CHALLENGEđ„]Matrix(2D)-Based
A matrix consists of nĂn elements.Change the matrix such that all 1st diagonal elements have the value of 1st maximum in the matrix, all 2nd diagonal elements have 2nd maximum value in the matrix and so on(nth diagonal elements have value of nth maximum). assume that all entries in the matrix are unique. example:matrix: 1 3 2 4 7 9 5 6 15 (3Ă3) required matrix 7 9 15 9 7 9 15 9 7 1stmax=15 2nd=9... OPTIMIZE your algorithm. BEST OF LUCK!!
3 Answers
+ 3
https://code.sololearn.com/c5lZSWJW17TC/?ref=app
+ 3
@Abdul thanks for the challenge
some interisting problems inside.
The matrix is random from 3x3 to 9x9.
also numbers in matrix are random but different.
the formula for diagonals took me half an hour
anyhow here is my coding:
https://code.sololearn.com/cjmgUey0I7xf/?ref=app