Check if One String Swap Can Make Strings Equal - Leetcode 1790 - Python

  Рет қаралды 6,469

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 21
@Math-is-fun.627
@Math-is-fun.627 6 күн бұрын
I love you Neetcode!!❤❤😂😂
@codewithven9391
@codewithven9391 6 күн бұрын
another way: def areAlmostEqual(self, s1: str, s2: str) -> bool: count, j = 0, 0 for i in range(len(s1)): if s1[i] != s2[i]: count += 1 if count == 1: j = i elif (count == 2 and s1[i] != s2[j] or s2[i] != s1[j]) or count > 2: return False return count != 1
@smartdragon2504
@smartdragon2504 5 күн бұрын
this is similar to what i did , noice
@setkaung729
@setkaung729 5 күн бұрын
similar to mine,great
@araneuskyuro
@araneuskyuro 4 күн бұрын
Quick question, instead of checking len(indexes) == 0 would it not be better to return True initially itself on If s1 == s2: return True ? The iteration over the entire string feels a bit pointless in that case
@rhugvedbhojane4387
@rhugvedbhojane4387 5 күн бұрын
I watch so much neetcode that my solutions are getting similar to his
@Douglascaina
@Douglascaina 5 күн бұрын
great solution!
@Sammie_
@Sammie_ 5 күн бұрын
feelsgood to beat neetcode by having slightly better memory usage while being on 100%.
@Deadmanstrolln
@Deadmanstrolln 5 күн бұрын
I really hate that they call this "string" swapping. At least for languages I'm familiar with, you're swapping chars of a string. Swapping strings makes it sound like there is some substring (of any length) that can be swapped with another substring (of any length) to make the 2 original strings equal
@Nishanth_S
@Nishanth_S 5 күн бұрын
+1
@dialgos7574
@dialgos7574 5 күн бұрын
That would be a really interesting and probably challenging exercise
@araneuskyuro
@araneuskyuro 4 күн бұрын
Lisan Al Gaib, I am sure this will be a daily problem soon
@jeehar1
@jeehar1 6 күн бұрын
Nice sol man
@sandeepsalwan2911
@sandeepsalwan2911 5 күн бұрын
🔥
@alizu3803
@alizu3803 5 күн бұрын
did the brute force in 40s things are going good
@UltiRequiem
@UltiRequiem 5 күн бұрын
I have not seen the video. My udea: Check for the diff, the diff must be exactly two.
@cordrust
@cordrust 5 күн бұрын
they need to be the same different characters
@Tahsan14710
@Tahsan14710 5 күн бұрын
test case 'aa' 'bb' has exactly two, but It can't be same by swapping.
@abdalla4425
@abdalla4425 5 күн бұрын
easy -> 50% acceptance rating >.< lmao we got baited
@zangdaarrmortpartout
@zangdaarrmortpartout 6 күн бұрын
maybe the easiest problem I've seen on lt so far
@vickykumar-vp7ux
@vickykumar-vp7ux 6 күн бұрын
First
How I Approach a New Leetcode Problem (live problem solving)
25:31
All Rust string types explained
22:13
Let's Get Rusty
Рет қаралды 201 М.
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Try this prank with your friends 😂 @karina-kola
00:18
Andrey Grechka
Рет қаралды 9 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 212 М.
C can do this too and it's faster than Python
2:09:48
Tsoding Daily
Рет қаралды 18 М.
Count Number of Bad Pairs - Leetcode 2364 - Python
12:02
NeetCodeIO
Рет қаралды 8 М.
Decode String - Leetcode 394 - Python
16:26
NeetCode
Рет қаралды 100 М.
AI Is Making You An Illiterate Programmer
27:22
ThePrimeTime
Рет қаралды 331 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
What if all the world's biggest problems have the same solution?
24:52
LeetCode was HARD until I Learned these 15 Patterns
13:00
Ashish Pratap Singh
Рет қаралды 817 М.