Transpose Matrix - Leetcode 867 - Python

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • 🚀 neetcode.io/ - A better way to prepare for Coding Interviews
    🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
    🥷 Discord: / discord
    🐦 Twitter: / neetcode1
    🐮 Support the channel: / neetcode
    ⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
    💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
    Problem Link: leetcode.com/problems/transpo...
    0:00 - Read the problem
    0:30 - Drawing Explanation
    3:57 - Coding Explanation
    leetcode 867
    #neetcode #leetcode #python

Komentáře • 7

  • @kartheyansivalingam7927
    @kartheyansivalingam7927 Před 7 měsíci +16

    There's also a nice Pythonic one liner to transpose any matrix: list(zip(*matrix))

  • @SurenKhorenyan
    @SurenKhorenyan Před 7 měsíci +1

    Also you could do inner list comprehension:
    class Solution:
    def transpose(self, matrix: List[List[int]]) -> List[List[int]]:
    return [
    [row[i] for row in matrix]
    for i in range(len(matrix[0]))
    ]

  • @krateskim4169
    @krateskim4169 Před 7 měsíci

    Awesome

  • @CS_n00b
    @CS_n00b Před 7 měsíci

    Can you do an explanation of LC 310 pls

  • @user-mh4lq5ce6u
    @user-mh4lq5ce6u Před 7 měsíci +10

    I was asked this question in second year of my uni and I was among the only 3 people who solved it that time .... seeing it in Easy section makes me wonder how bad are my uni students....

    • @cakesama9770
      @cakesama9770 Před 7 měsíci +5

      the easy label is based of the accepted amounts of leetcode not the average population

    • @chrischika7026
      @chrischika7026 Před 7 měsíci

      really proof? i thought the company chose the diffculty@@cakesama9770