+ 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!!

10th Dec 2017, 8:46 AM
Abdul Sattar Mapara
3 ответов
10th Dec 2017, 4:34 PM
Käzî Mrîdùl Høssäîn
Käzî Mrîdùl Høssäîn - avatar
+ 3
https://code.sololearn.com/c5lZSWJW17TC/?ref=app
10th Dec 2017, 11:28 AM
yuri
+ 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
10th Dec 2017, 11:57 AM
Oma Falk
Oma Falk - avatar