Nooo!! You would not use a hash set because you can lookup the array in constant time by setting the index in the array corresponding to the ord of the letter.
2024-08-19 14:41:59
225
catlitter4 :
try O(1) runtime and O(1) memory 💀💀
2024-09-10 14:53:32
2
J :
you can convert the letter to an ascii number then set that position in the array to 1. then you don't need to do a search. you can just use the ascii number as the index and if 1 then return if 0 set
2024-08-29 22:21:28
1
Barkenflops Mcgee :
This makes no sense. Why linear search an array each time? Sure you don’t need a hash set but you can just use a fixed length array, one for each character.
2024-08-20 03:16:22
78
Justin DaCosta :
Ultra optimize by storing letters as bits in a uint32
2024-08-25 13:57:49
32
AutisticCracker :
Can u do a set?, basically same solution tho
2024-08-19 14:37:22
10
Son! I have the milk! :
Use a set what….
2024-08-19 18:39:25
1
huqbackup :
What's the source? That google asked this
2024-08-20 03:29:30
0
Zappydo :
Why not use bits in an integer? Should be fast, the integer is stored in a register in the CPU.
2024-08-25 18:35:27
1
Rachel :
There’s like a 3% chance I’ll ever need this for pentesting, but man I am in love with your platform. 10/10.
2024-08-26 17:54:49
0
罗曼 :
these as ascii chars are consecutive,just use array and indexes as lookup
2024-08-19 15:12:55
3
abeet71 :
Why wouldnt u use a hashset. Im j curious why it wouldnt be the same
2024-08-19 17:47:27
4
Th :
Great video
2024-09-29 16:54:02
0
George Marshall :
Shove it into a 32-bit, get the ascii and create an offset and shift into int
2024-09-16 21:20:08
0
SiePhi :
bit map? it would make the base code more complex but speed up lookup time
2024-08-28 05:27:20
0
Oliver :
You can use the ascii value as an index for the array giving you a real o(1) lookup time
2024-09-24 06:13:48
0
Fardarterfu :
Surely the overhead of initialising the map is lower than searching the seen letters each time?
2024-10-24 05:34:50
0
Leon Guerrero :
Hash map 😎
2024-10-20 01:29:02
0
Eco S :
I hate these interview questions because I can do the coding part no problem but these questions I don't really know what the right answer is
2024-08-25 09:59:58
0
Aware Nessy :
bitset? 🔥
2024-08-21 11:50:58
0
CooLaaa :
wouldn't it be more efficient if you for I in range(s.length()-1)
and compare s[i] with s[i+1] ?
2024-08-21 11:44:41
0
Joshua :
Bro I love your vids thanks for contributing to software education
2024-08-20 09:36:28
0
Bryan Enid :
You won’t use a hash set because then the duplicate will be gone. Now, you could just want to count with a HASHMAP the letters seen, and the lookup would be faster.
2024-11-06 13:45:38
0
Gorbatjorven :
Always use a hash set. The requirements will soon change to take more characters into account
2024-08-27 08:08:16
2
p :
the in operator is still O(n), so the answer is to do a lookup in a 26 len array and use the index as the number for constant look up time. It is not O(26) or O(1)
2024-08-21 05:21:14
0
To see more videos from user @greghogg5, please go to the Tikwm
homepage.