Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

171
Vistas
rotate matrix 90 degree in clockwise not working properly

here after transpose the matrix i want to reverse the row to get the rotation of matrix but until transpose its working after that its not give proper output

import React from "react";
export default function DropDown() {
let matrix = [
    [ 1, 2, 3, 4 ],
    [ 1, 0, 3, 4 ],
    [ 1, 2, 3, 4 ],
    [ 1, 2, 3, 4 ],
  ];
  for(let i=0;i<4;i++)
  {
    for(let j=0;j<i;j++)
    {let t;
      if(i!=j)
       t=matrix[i][j];
      matrix[i][j]=matrix[j][i];
      matrix[j][i]=t;
    }
  }
  for(let i=0;i<4;i++)
  {
    for(let j=0;j<4/2;j++)
    {let t;
      if(i!=j)
       t=matrix[i][j];
      matrix[i][j]=matrix[i][4-j-1];
      matrix[i][4-j-1]=t;
    }
  }
  return (
   <>
    {matrix.map(i=><div>{i}</div>)}
   </>
);
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I hope you question is about matrix-traspose

const arr = [
   [1, 1, 1],
   [2, 2, 2],
   [3, 3, 3],
];
const transpose = arr => {
   for (let i = 0; i < arr.length; i++) {
      for (let j = 0; j < i; j++) {
         const tmp = arr[i][j];
         arr[i][j] = arr[j][i];
         arr[j][i] = tmp;
      };
   }
}
transpose(arr);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda