If the input is sorted then you’re using O(n) space which is unnecessary, as you could use two pointers and a single pass
2024-10-16 16:26:07
35
Vincent 🇺🇸 :
Your audio only plays on the left EarPod on headphones.
2024-10-18 03:51:30
25
Max :
It is Visa… this is about as hard as it gets for them. If you can string Hello World together without getting mixed up you can blow away most of their interviewers.
2024-10-17 06:21:23
35
махем :
hashmaps.
2024-10-18 23:01:42
0
Bigger Moose :
if input is sorted, just have a counter checking if there are more than 2 occurrences in a row
2024-10-22 04:13:10
0
Joshua Koudys :
nice time to use expressions over statements.
return all(v <= 2 for v in Counter(nums).values())
0ms one-liner
2024-12-02 17:52:03
2
user2538017214964 :
Can you do 416 ? Seems similar but I can’t figure it out
2024-10-21 04:37:00
0
Jim Halpert314 :
You also need to make sure the number of elements is even.
2024-12-20 12:52:43
0
Brandyn :
At my Amazon code interview i did something like this and thought it was hella unoptimized. I cooked apparently
2024-10-17 19:55:06
1
A2AxPhoenix :
Hashmaps simple as
2024-10-22 07:50:28
0
Nick :
might be much faster on larger inputs to check if the count is >2 after processing each element, so we can return early
2024-10-18 00:36:26
0
gavkoCZ :
instead of a dict, just make a counter that restets for on a different number. Safes a lot of memory and hashing overhead
2024-11-03 09:16:51
0
JC_Barrios_81 :
Thanks!!?
2024-10-16 15:27:34
1
Ruth :
I didn't why your explanation always stick in my minds.
Anyway 🙏🙏🙏🙏🙏
2024-10-16 21:14:27
0
Functor :
Although the question has a simple answer, some people might jump straight to an array solution without thinking a little more and seeing the frequency solution.
2024-10-17 08:07:44
1
mattraxxer :
Something went wrong with the sound
2024-10-16 15:30:00
4
Greg Hogg :
Master data structures and algorithms for FREE at AlgoMap.io :)
2024-10-16 15:28:16
0
Chillsz :
when in doubt use hashmaps
2024-10-17 04:16:13
1
To see more videos from user @greghogg5, please go to the Tikwm
homepage.