2610. Convert an Array Into a 2D Array With Conditions | Hash Table | Arrays

preview_player
Показать описание
In this video, I'll talk about how to solve Leetcode 2610. Convert an Array Into a 2D Array With Conditions

Let's Connect:

About Me:
I am Aryan Mittal - A Software Engineer in Goldman Sachs, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)

✨ Timelines✨
0:00 - Problem Explanation
2:16 - Intuition
3:26 - Dry Run with Example
7:44 - Code & Complexity Explanation

✨ Hashtags ✨
#programming #Interviews #leetcode #faang #maang #datastructures #algorithms
Рекомендации по теме
Комментарии
Автор

Actually, this can be solved Without using extra space, with 0(mn) time.
m: no of rows
n : len (nums)
As the condition in the question stated that values of the array will be in the range of 1 to len(nums)
Treat them as positions and modify the given array.
Step1 : Modify the given array by adding len(nums) by treating the values as the positions
Step2: Iterate over the modified array and check if anything is greater than len(nums), if yes, then
add pos+1 to the row and decrement len(nums) to its value
Step3: Continue step1 untill max(nums) <len(nums)

visase
welcome to shbcf.ru