Leetcode Weekly Contest 339 | Convert an Array Into a 2D Array With Conditions

preview_player
Показать описание
Leetcode Weekly Contest 339 | Convert an Array Into a 2D Array With Conditions | 2 April 2023

Leetcode question no: 2610
difficulty: medium
optimized approach beats 70% of the test cases

Like, share and subscribe

daily leetcode challenge,
daily leetcode questions,
daily leetcode problem,
leetcode daily today,
leetcode daily problem today,
leetcode daily challenge,
leetcode daily practise,
leetcode solutions,
letcode python,
leetcode hard problems,
leetcode easy problems,
leetcode medium problems,
leetcode for begineers,
leetcode python problems,
leetcode python,
leetcode python solutions,
leetcode python hard,
leetcode python medium,
leetcode python easy,
leetcode python english,
leetcode python solutions in english

#leetcode #leet_preparation_tips #leetcodesolution #coding #interview
#CodingInterview #NovemberLeetCodingChallenge #Google #Amazon #programming #march #codinglife #meta #faang #maang
Рекомендации по теме
Комментарии
Автор

class Solution:
def findMatrix(self, nums: List[int]) -> List[List[int]]:
freq={}
for i in nums:
if(i in freq):
freq[i]+=1
else:
freq[i]=1
#print(freq)
n=len(nums)
ans=[]
while(freq):
#print('freq', freq)

#print('ans', ans)
for i in ans[-1]:
freq[i]-=1
if(freq[i]<=0):
freq.pop(i)
return ans

darshankumar
join shbcf.ru