Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let matrixSize = gets();
- matrixSize = matrixSize.split(" ");
- matrixSize = matrixSize.map(Number);
- //console.log(matrixSize);
- const n = matrixSize[0];
- const m = matrixSize[1];
- let myMatrix = [];
- for (let i = 0; i < n; i += 1) {
- let row = gets();
- row = row.split(" ");
- //row = row.map(String);
- //console.log(row);
- myMatrix.push(row);
- }
- //console.log(myMatrix);
- let LastArray = [];
- //LastArray = [].concat(...myMatrix);
- LastArray = myMatrix;
- let sequence = 0;
- let longestSequence = 0;
- for (let i = 0; i < n; i++) {
- for (let k = 0; k < m; k++) {
- if (sequence > longestSequence) {
- longestSequence = sequence;
- }
- sequence = 0;
- for (let j = 0; j < LastArray.length; j++) {
- for (let h = 0; h < LastArray.length; h++) {
- if (myMatrix[i][k] === LastArray[j][h]) {
- sequence += 1;
- }
- }
- }
- }
- }
- print(longestSequence);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement