Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. let matrixSize = gets();
  2. matrixSize = matrixSize.split(" ");
  3. matrixSize = matrixSize.map(Number);
  4. //console.log(matrixSize);
  5. const n = matrixSize[0];
  6. const m = matrixSize[1];
  7. let myMatrix = [];
  8. for (let i = 0; i < n; i += 1) {
  9. let row = gets();
  10. row = row.split(" ");
  11. //row = row.map(String);
  12. //console.log(row);
  13. myMatrix.push(row);
  14. }
  15.  
  16. //console.log(myMatrix);
  17. let LastArray = [];
  18. //LastArray = [].concat(...myMatrix);
  19. LastArray = myMatrix;
  20. let sequence = 0;
  21. let longestSequence = 0;
  22.  
  23. for (let i = 0; i < n; i++) {
  24. for (let k = 0; k < m; k++) {
  25. if (sequence > longestSequence) {
  26. longestSequence = sequence;
  27. }
  28. sequence = 0;
  29. for (let j = 0; j < LastArray.length; j++) {
  30. for (let h = 0; h < LastArray.length; h++) {
  31. if (myMatrix[i][k] === LastArray[j][h]) {
  32. sequence += 1;
  33. }
  34. }
  35. }
  36. }
  37. }
  38. print(longestSequence);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement