I kept over thinking a solution to this problem until i saw that this video was 3 minutes long. Then I came up with a simple solution without even watching the video. I'm growing thanks to your videos💜
Thank you neetcode for all that you do, I wouldn't do dailies if it wasn't for your motivation. I know these vids don't get awfully many views but please keep it at it, appreciate ur explanations
I came up with my own solution, and it also beats 100%. But after seeing this code, I felt dumb because it was so easy, I unnecessarily complicated my approach. Here's my approach : class Solution: def isArraySpecial(self, nums: List[int]) -> bool: if len(nums)==1: return True if nums[0]%2==0: even=1 odd=0 elif nums[0]%2!=0: even=0 odd=1 for i in range(1,len(nums)): if nums[i]%2==0: even+=1 odd-=1 else: odd+=1 even-=1 if even==-1 or odd==-1: return False return True
If this was me a month ago, I would have thought about using a hash map just to sort the given keys (which they're not even given in this problem to my knowledge) and sort them into their corresponding values, without even thinking about how I should then implement a pointer arithmetic to check if the given values at their corresponding indices are even special or not, making the solution unclear and costly time and space wise :P
Man, i'm so disappointed of not getting interview or getting but getting rejections. I'm in San Francisco and most of the companies I am applying for ask me hard leetcode questions and they even want to make it optimized. It is insane. Also they say 2025 is ending of swe. Should i stop attempting on solving leetcode questions?
You know the problem is hard when video is 3 minutes long…
😂
Relatable 😂😢
first day of the month is always the best. can't wait for Feb 14th...
yes! 13 more to Go ...
😅
I kept over thinking a solution to this problem until i saw that this video was 3 minutes long.
Then I came up with a simple solution without even watching the video. I'm growing thanks to your videos💜
We can also check if (num[i] + num[i-1]) is odd. If it is even, then the two elements have to both be even or odd.
Not sure if this improves the TC though. Maybe a very minor improvement.
@@yhbarve Same time complexity.
Thank you neetcode for all that you do, I wouldn't do dailies if it wasn't for your motivation. I know these vids don't get awfully many views but please keep it at it, appreciate ur explanations
thanks chief
what i used is:
even + even = even
odd + odd = even
even + odd = odd
solved this problem first then came to this video and listened to it in french (i don't understand french)
I came up with my own solution, and it also beats 100%. But after seeing this code, I felt dumb because it was so easy, I unnecessarily complicated my approach.
Here's my approach :
class Solution:
def isArraySpecial(self, nums: List[int]) -> bool:
if len(nums)==1:
return True
if nums[0]%2==0:
even=1
odd=0
elif nums[0]%2!=0:
even=0
odd=1
for i in range(1,len(nums)):
if nums[i]%2==0:
even+=1
odd-=1
else:
odd+=1
even-=1
if even==-1 or odd==-1:
return False
return True
lost my 60 day streak to this one
nah man, what the hell
you can do timetravel for 70 credit and restore your streak. Not that it matters, just saying if you didn't know.
If this was me a month ago, I would have thought about using a hash map just to sort the given keys (which they're not even given in this problem to my knowledge) and sort them into their corresponding values, without even thinking about how I should then implement a pointer arithmetic to check if the given values at their corresponding indices are even special or not, making the solution unclear and costly time and space wise :P
oh hell naw
refreshing problem
Lets goo, coming here after failing an OA hihihi
i used (nums[i] ^ nums[i-1]) % 2 == 0 ) return false
Man, i'm so disappointed of not getting interview or getting but getting rejections. I'm in San Francisco and most of the companies I am applying for ask me hard leetcode questions and they even want to make it optimized. It is insane. Also they say 2025 is ending of swe. Should i stop attempting on solving leetcode questions?
"YES, YOU SHOULD STOP" - your competition
return all((a+b)%2 for a,b in pairwise(nums))