LeetCode 566. Reshape the Matrix Solution Explained - Java

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

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

  • @alibaba888
    @alibaba888 3 ปีที่แล้ว +1

    Going through the columns first made a lot of sense, thanks!

  • @rupaldesai7098
    @rupaldesai7098 5 ปีที่แล้ว +7

    Congratulations on your new job!

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว +1

      Thank you so much!

  • @satyamgupta6030
    @satyamgupta6030 ปีที่แล้ว

    thanks nick ur videos are helping me alot these day.

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

    much more easier than the solutions on the discussion forum 👍

  • @f3-faithfitnessfinance
    @f3-faithfitnessfinance 5 ปีที่แล้ว +6

    Yeah dude. .. don't stop doing these videos
    And congrats on your new job👍

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว

      thank you dude I appreciate it

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

    I forgot the column_num = 0 when column_num = c. Good stuff

  • @sarvarkhalimov111
    @sarvarkhalimov111 2 ปีที่แล้ว +3

    How do you come up with such idea like the 1st if statement check? what would you advise to do?

    • @MrSaurus
      @MrSaurus ปีที่แล้ว

      The program says that the new array needs to hold the exact same number of data as the original array, so that is where he came up with using that first if statement

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

    I feel that instead of "columns_num==c" this should be "column_num %c ==0". Do you also think the same?

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

    class Solution {
    public int[][] matrixReshape(int[][] mat, int r, int c) {

    if(r*c != mat.length*mat[0].length) return mat;
    int[][] new_mat = new int[r][c];

    int row = 0;
    int col = 0;

    for(int i=0;i

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

    class Solution:
    def matrixReshape(self, mat, r: int, c: int):
    rows=len(mat)
    columns=len(mat[0])
    if (rows*columns)!=(r*c):
    return mat
    empty_list=[]
    row_no=0
    column_no=0
    output = np.array([[0]*c]*r)
    for i in range(rows):
    for j in range(columns):
    output[row_no][column_no]=mat[i][j]
    column_no+=1
    if (column_no==c):
    column_no=0
    row_no+=1
    return output.tolist()

  • @sourin.majumdar
    @sourin.majumdar 2 ปีที่แล้ว

    Would the space complexity be O(r*c) ?

  • @shubhamtiwari6660
    @shubhamtiwari6660 5 ปีที่แล้ว +2

    All the best dude.

  • @JavaAidTutorials
    @JavaAidTutorials 5 ปีที่แล้ว +1

    Nice one bro..

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว

      what's with the dot dot bro..

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว

      i'm getting mixed signals here

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว +6

      i hate you i love you i hate that i love you

    • @JavaAidTutorials
      @JavaAidTutorials 5 ปีที่แล้ว

      @@NickWhite its typo 😀

    • @JavaAidTutorials
      @JavaAidTutorials 5 ปีที่แล้ว

      @@NickWhite I did not get this 🤔

  • @firecracker-i2h
    @firecracker-i2h 3 ปีที่แล้ว

    as programming channel you wont get much views but you will get more subscriber if u are a good programmer

  • @praveen3123
    @praveen3123 5 ปีที่แล้ว

    Bro. Can you please solve some graphs problems??

  • @f3-faithfitnessfinance
    @f3-faithfitnessfinance 5 ปีที่แล้ว +1

    Leetcode Problem 873 please!!

    • @NickWhite
      @NickWhite  5 ปีที่แล้ว +1

      I’ll check it out!

  • @BishalECE-uy5rn
    @BishalECE-uy5rn 2 ปีที่แล้ว +1

    What about the time complexity

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

      Probably O(rows * columns)

  • @chodingninjas7415
    @chodingninjas7415 5 ปีที่แล้ว

    do more problems please

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

    lol why the f couldnt i solve this i am tired