Rearrange Array Elements by Sign - Leetcode 2149 - Python

  Рет қаралды 8,582

NeetCodeIO

NeetCodeIO

Күн бұрын

🚀 neetcode.io/ - A better way to prepare for Coding Interviews
🧑‍💼 LinkedIn: / navdeep-singh-3aaa14161
🐦 Twitter: / neetcode1
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
Problem Link: leetcode.com/problems/rearran...
0:00 - Read the problem
0:24 - Drawing Explanation 1
4:06 - Coding Explanation 1
6:13 - Drawing Explanation 2
8:50 - Coding Explanation 2
leetcode 2149
#neetcode #leetcode #python

Пікірлер: 19
@achan3073
@achan3073 2 ай бұрын
you can use a two pointer technique to find the next positive and negative number in the array. Then add the positive and negative number to the result array before moving the pointers again. No extra memory
@10zDelek
@10zDelek 4 ай бұрын
What I did instead of the pointer is that reverse the positive and negative array then pop each element to a res array as an input. (Like a stack)
@avidfan3407
@avidfan3407 4 ай бұрын
Simple but smart
@JAson-ps2ug
@JAson-ps2ug 4 ай бұрын
damn i spent a lot of time thinking of in-place solution and come here, is there a inplace algorithm?
@luminica_
@luminica_ 4 ай бұрын
Of course you can do it in place but it won't be O(n) TC. Don't swap but actually move the element.
@aaroldaaroldson708
@aaroldaaroldson708 4 ай бұрын
same
@Munchen888
@Munchen888 4 ай бұрын
Or also we can use hashtable [0] * len(nums) and we should fill by appropriate values
@Munchen888
@Munchen888 4 ай бұрын
With list comprehension we can make two lists and then use a zip function 😊
@satwiktatikonda764
@satwiktatikonda764 4 ай бұрын
as we dont consider output space we can say this as constant space solution
@swapnilmishra2829
@swapnilmishra2829 4 ай бұрын
hi, man i am getting good at coding now but the problem is my resume is not getting shortlisted at any good companies since I'm not from a tier 1 college, would be great if u made a video or post about it. What good will all the skills do when i don't have the chance to perform
@Aditya_qwertyu
@Aditya_qwertyu 4 ай бұрын
same difficulty
@richardsimon395
@richardsimon395 4 ай бұрын
I solved this on the first attempt, however runtime: beats 5%, memory: beats 90%. Hm, there might be a trick here using a bit more memory :D
@xavier7769
@xavier7769 4 ай бұрын
whats good bro
@quocanhhbui8271
@quocanhhbui8271 4 ай бұрын
Hi Neetcode any chance u could do 3009 pls?
@sanis85
@sanis85 4 ай бұрын
just do for num in nums :) no need for k i hate to be that guy but i fail to see why this is a medium problem.. many people critique the wording of the question as it suggests this should be done in place..whereas in fact its not the case as the editorial also creates a new array.. what is your thoughts on the difficulty label and the constant war in the comment sections... oh this should be easy ... bla bla ... and then someone comes and freaks out why discourage ppl if they cannot solve the problem and its labelled easy... i think it is important to have accurate labels as it is supposed to give an accurate measure of my knowledge... i think it is really misleading if medium problems are in fact easy cos it can create a false sense of knowledge... but also re labeling like straight forward dynamic programming questions from hard to medium is also neccessary as it show that the industry has evolved to a point where solving these problems is a must now and dont fall into the expert knowledge category cheers
@pastori2672
@pastori2672 4 ай бұрын
theres no difference its just personal prefrence
@leeroymlg4692
@leeroymlg4692 4 ай бұрын
it's not that deep bro. take it with a grain of salt
@sankalpchordia5245
@sankalpchordia5245 4 ай бұрын
Neet solution
@pastori2672
@pastori2672 4 ай бұрын
what are these comments
Subarray Product Less Than K - Leetcode 713 - Python
10:26
NeetCodeIO
Рет қаралды 12 М.
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
Василиса наняла личного массажиста 😂 #shorts
00:22
Денис Кукояка
Рет қаралды 9 МЛН
I’m just a kid 🥹🥰 LeoNata family #shorts
00:12
LeoNata Family
Рет қаралды 19 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 609 М.
Rotate Array - Leetcode 189 - Python
8:59
NeetCode
Рет қаралды 128 М.
Greatest Common Divisor Traversal - Leetcode 2709 - Python
24:30
Maximum Profit in Job Scheduling - Leetcode 1235 - Python
14:45
NeetCodeIO
Рет қаралды 28 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 261 М.
Meeting Rooms III - Leetcode 2402 - Python
16:16
NeetCodeIO
Рет қаралды 18 М.
K-th Symbol in Grammar - Leetcode 779 - Python
10:19
NeetCodeIO
Рет қаралды 12 М.
Insert Delete GetRandom O(1) - Leetcode 380 - Python
13:27
NeetCode
Рет қаралды 40 М.