Tuesday, September 4, 2018

Leetcode 867. Transpose matrix - pass 29/36 test cases

Sept. 4, 2018

Introduction


It is time for me to look into the analysis of the algorithm. The mindset to simplify the problem is so important in the algorithm called transpose matrix. I did submit 5 times, but the code only 29/36 test cases.

I played against the online judge, and ran into a few times with bugs.

My solution is time consuming but also not correct. The failed test case:
input:  [[1, 2, 3], [4, 5, 6]]
output: [[1, 4], [2, 5], [0, ]]
Expected: [[1, 4], [2, 5], [3, 6]]

My practice


Here is my code. I like to document my practice, remind myself to think carefully before I start to write the code.



No comments:

Post a Comment