TOEPLITZ MATRIX | LEETCODE # 766 | PYTHON SOLUTION

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ต.ค. 2024

ความคิดเห็น • 9

  • @MattK-ez5ti
    @MattK-ez5ti 6 หลายเดือนก่อน +3

    could you please explain how to do the follow up questions?

    • @pavananand7327
      @pavananand7327 6 หลายเดือนก่อน

      Did you get the answer to this?

  • @Ankit-hs9nb
    @Ankit-hs9nb 2 ปีที่แล้ว +12

    I tried this:
    class Solution:
    def isToeplitzMatrix(self, matrix: List[List[int]]) -> bool:


    for row in range(len(matrix)-1):
    for col in range(len(matrix[0])-1):
    if matrix[row][col] != matrix[row+1][col+1]:
    return False
    return True

    • @yehsunkang5150
      @yehsunkang5150 11 หลายเดือนก่อน +1

      Great insight! Simple and readable..

  • @SatinderSingh71
    @SatinderSingh71 11 หลายเดือนก่อน

    The solution tab shows a much more concise solution where we just iterate thru the entire grid all at once (4 lines of code).

    • @pieter5466
      @pieter5466 9 หลายเดือนก่อน

      Noticed also. However, this uses a highly generalizable pattern in case you don't quickly see that "trick" (repeatedly traversing a section of a data structure.)

  • @sanooosai
    @sanooosai หลายเดือนก่อน

    thank you sir

  • @khoaanh7375
    @khoaanh7375 2 ปีที่แล้ว

    nice

    • @crackfaang
      @crackfaang  2 ปีที่แล้ว

      No problem, thanks for watching