Documentation IndexFetch the complete documentation index at: /llms.txtUse this file to discover all available pages before exploring further.
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Tested Python solution for LeetCode 867 with 14 pytest cases. Generate a practice environment with lcpy.
lcpy gen -n 867 # by problem number lcpy gen -s transpose_matrix # by problem name
matrix
Input: matrix = [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]]
Input: matrix = [[1,2,3],[4,5,6]] Output: [[1,4],[2,5],[3,6]]
class Solution: # Time: O(m * n) # Space: O(m * n) def transpose(self, matrix: list[list[int]]) -> list[list[int]]: rows = len(matrix) cols = len(matrix[0]) return [[matrix[row][col] for row in range(rows)] for col in range(cols)]