To rotate 270 degree, select each column from right to left into a new list, append the list to output.
matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
]
output = []
h = len(matrix)
w = len(matrix[0])
for i in range(w - 1, -1, -1):
c = []
for j in range(h):
c.append(matrix[j][i])
output.append(c)
print(output)
const matrix = [
[ 1, 2, 3 ],
[ 4, 5, 6 ],
[ 7, 8, 9 ]
];
const output = [];
const h = matrix.length;
const w = matrix[0].length;
for (let i = w - 1; i >= 0 ; i--) {
let c = [];
for (let j = 0; j < h; j++) {
c.push(matrix[j][i]);
}
output.push(c);
}
console.log(output);