Your question is Reverse String In Place and Matrix Rotation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Myntra's catalog and personalization systems frequently transform ordered data. Implement two related in-place operations: reverse a mutable character sequence without allocating another sequence, and rotate a matrix 90 degrees clockwise.
chars in place. The input is a list of single-character strings, representing a mutable string buffer.Implement reverse_and_rotate(chars, matrix), where chars is list[str] and matrix is a non-empty rectangular list[list[int]]. Return a dictionary with keys chars and matrix. The character list must be mutated in place. Square matrices must be mutated in place. For rectangular matrices, the returned matrix must contain the clockwise rotation.
Example 1
chars = ['m', 'y', 'n', 't', 'r', 'a'], matrix = [[1, 2], [3, 4]]{'chars': ['a', 'r', 't', 'n', 'y', 'm'], 'matrix': [[3, 1], [4, 2]]}Example 2
chars = ['a', 'b', 'c'], matrix = [[1, 2, 3], [4, 5, 6]]{'chars': ['c', 'b', 'a'], 'matrix': [[4, 1], [5, 2], [6, 3]]}def reverse_and_rotate(chars, matrix):