Covert 1D Array Into 2D Array - Leetcode 2022 - Python

preview_player
Показать описание


0:00 - Read the problem
0:30 - Drawing Explanation
3:38 - Coding Explanation

leetcode 2022

#neetcode #leetcode #python
Рекомендации по теме
Комментарии
Автор

Listen man, I need these videos more than oxygen. Please don't leave too much

ttlbyyi
Автор

bro please dont stop doing the daily challenge videos

mohamed
Автор

Hey Navi, there aren't many good explanations for LeetCode problems that are as understandable as yours. Please don't stop—you're helping a lot of people out there!

hemanth
Автор

Thanks for the solution. Another approach would be to create a m * n matrix with default values and then loop through the matrix and fill it with the elements of original, this way you can avoid the calculations of start, end.

res = [ [ 0 for _ in range(n) ] for _ in range(m) ]
i = 0
for r in range(m):
for c in range(n):
res[r][c] = original[i]
i += 1
return res

DJSTEVE
Автор

welcome back... and thanks for the vid

prajwals
Автор

Saw this video and got my reason to get out of bed 😂

anirudhbhat
Автор

Please don't stop making videos for daily problems, espacially for hard ones, there are not much good explainations other than yours

pushkarsaini
Автор

Hey neetcode please don’t skip daily solutions for hard problems, not many good solutions out there

abhimanyuambastha
Автор

The day I realised for some problems your solution is better most of the time than leetcode’s own editorials, it has become mandatory to look at your solution after i solve it with my approach.without that i feel uneasy.

My humble request, don’t stop the daily videos!!!

chinmay
Автор

Why the time complexity is O(n*m) and space complexity is O(n)? I think that it should be O(m) for time complexity and O(1) for space complexity (if we ignore res. array).

SUN_HAO_LUN
Автор

It ain't much in terms of time complexity, but it's honest work.
return [original[i:i+n] for i in range(0, len(original), n)] if len(original) == n * m else []

Provehitum
Автор

My man for few days dodging hard and medium problems

varun
Автор

Where were you man from last few days?

viveksoni
Автор

I DID THIS:

return np.array(original, (-1, n)) if m*n == len(original) else return [ ]

MohitSoni-ze
Автор

last two weeks was so frustrated because of daily questions are hard and also u didnt explain the que

mohammedsuhail.s
Автор

I literally just solved this problem🤣
FYI-This is today's daily problem

samuelsolomon
Автор

it does seem like your avoiding hard problems

pastori