@greghogg5: First Letter to Appear Twice - Leetcode 2351 #java #software #softwarejobs #softwareengineer #datastructures #leetcode #programming #javadeveloper #datastructuresandalgorithms #python #softwaredeveloper #code #FAANG #coding #javascript #javascriptdeveloper #codingisfun #codinginterview #js #html #css #sql

Greg Hogg
Greg Hogg
Open In TikTok:
Region: CA
Monday 19 August 2024 14:12:02 GMT
176739
7081
96
105

Music

Download

Comments

kbb1231w
kbb1231w :
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
moron5fan
catlitter4 :
try O(1) runtime and O(1) memory 💀💀
2024-09-10 14:53:32
2
josh.darn.it
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
barkenflopsmcgee
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
j_kosta_music
Justin DaCosta :
Ultra optimize by storing letters as bits in a uint32
2024-08-25 13:57:49
32
autisticcracker.ru
AutisticCracker :
Can u do a set?, basically same solution tho
2024-08-19 14:37:22
10
yourmomsspatula
Son! I have the milk! :
Use a set what….
2024-08-19 18:39:25
1
huqbackup
huqbackup :
What's the source? That google asked this
2024-08-20 03:29:30
0
zappydo
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
spoolbus6oh
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
romhulio
罗曼 :
these as ascii chars are consecutive,just use array and indexes as lookup
2024-08-19 15:12:55
3
abeet71
abeet71 :
Why wouldnt u use a hashset. Im j curious why it wouldnt be the same
2024-08-19 17:47:27
4
thhh383
Th :
Great video
2024-09-29 16:54:02
0
george.marshall
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
siebenphi
SiePhi :
bit map? it would make the base code more complex but speed up lookup time
2024-08-28 05:27:20
0
olli.gr
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
Fardarterfu :
Surely the overhead of initialising the map is lower than searching the seen letters each time?
2024-10-24 05:34:50
0
leonguerreromendoza
Leon Guerrero :
Hash map 😎
2024-10-20 01:29:02
0
eco1916
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
awareness1970
Aware Nessy :
bitset? 🔥
2024-08-21 11:50:58
0
elmajalelmaghnatisi
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
joshhenny
Joshua :
Bro I love your vids thanks for contributing to software education
2024-08-20 09:36:28
0
bryanenid
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
krengt
Gorbatjorven :
Always use a hash set. The requirements will soon change to take more characters into account
2024-08-27 08:08:16
2
itspxris
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.

Other Videos


About