1790. Check if One String Swap Can Make Strings Equal | leetcode daily challenge | shashcode | dsa

  Рет қаралды 1,647

shashCode

shashCode

Күн бұрын

WhatsApp community:
chat.whatsapp....
Problem Link:
leetcode.com/p...
Problem Statement:
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not necessarily different) and swap the characters at these indices.
Return true if it is possible to make both strings equal by performing at most one string swap on exactly one of the strings. Otherwise, return false.
Solution Link:
github.com/Tiw...
Custom Comparator:
• Lecture 12 How to Comp...
Lambda Expression:
• L-1 Mind blowing Java ...
Dynamic Programming:
• Dynamic Programming in...
Graph Playlist:
• Graph Data Structure S...
Java Plus DSA Placement Course Playlist:
• Java and DSA Course Pl...
Java Plus DSA Sheet:
docs.google.co...
Notes:
github.com/Tiw...
Telegram Link:
shashwattiwari...
Ultimate Recursion Series Playlist:
• Recursion and Backtrac...
Instagram Handle: (@shashwat_tiwari_st)
shashwattiwari...
Samsung Interview Experience:
• I cracked Samsung | SR...
Company Tags:
Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung
Timestamp:
0:00 - Introduction

Пікірлер: 9
@shashwat_tiwari_st
@shashwat_tiwari_st 6 күн бұрын
like target for this video is 170. Please do like if you have understood the explanation as well as the code 😊
@rithviksharma9594
@rithviksharma9594 5 күн бұрын
After seeing your video I can see that I could have simplified my solution a bit more. Love your videos btw, I always visit your channel when I struggle with leetcode or if I want to learn more :) class Solution { public boolean areAlmostEqual(String s1, String s2) { if (s1.equals(s2)) { return true; } if (s1.length() != s2.length()) { return false; } int notSameCount= 0; int[] freqList = new int[26]; Arrays.fill(freqList, 0); for (int i=0; i 2) { return false; } freqList[charOne - 'a']++; freqList[charTwo - 'a']--; } for (int n : freqList){ if (n != 0){ return false; } } return true; } }
@PiyushSharma-we8yd
@PiyushSharma-we8yd 6 күн бұрын
welcome back sir🤩
@abhirajxyz7944
@abhirajxyz7944 5 күн бұрын
class Solution: def areAlmostEqual(self, s1: str, s2: str) -> bool: count = 0 mismatch = [] for i in range(len(s1)): if s1[i] != s2[i]: count += 1 mismatch.append(i) if count >=3 : return False if count == 1: return False elif count == 2: if s1[mismatch[0]] == s2[mismatch[1]] and s1[mismatch[1]] == s2[mismatch[0]]: return True else : return False return True
@rahulpandit8935
@rahulpandit8935 6 күн бұрын
I have used 3 approach but i failed during submission after spending so much time by my own i came here and got my mistake Thank you sir 😊
@shashwat_tiwari_st
@shashwat_tiwari_st 6 күн бұрын
Sometimes those little mistakes are the hardest to find! 😅
@zaffarzeshan1308
@zaffarzeshan1308 6 күн бұрын
class Solution { public boolean areAlmostEqual(String s1, String s2) { int cnt=0; int i=0; int j=0; int k=0; while(k2) return false; else { if(cnt==1) i=k; else j=k; } } k++; } return (s1.charAt(i)==s2.charAt(j) && s1.charAt(j)==s2.charAt(i)) ; } }
@nishantrathore5031
@nishantrathore5031 6 күн бұрын
Sir aapko aisi intuition kaise aa jaati hai ?
@shashwat_tiwari_st
@shashwat_tiwari_st 6 күн бұрын
I already explained in video, take multiple examples, it will start clicking.
Кровавый лидер #сталин #китай #мао
00:55
Послезавтра
Рет қаралды 3,5 МЛН
Cute dog Won Squid Game 😱💸 #dog # funny #cartoon
00:33
Wooffey
Рет қаралды 21 МЛН
CMA Exam Fail?   How to Bounce Back & Pass Next Attempt 💪
14:28
THE RAPID LEARNER - BY CA. DIVYANSHU BANZAL
Рет қаралды 36
Check if One String Swap Can Make Strings Equal | Leetcode 1790
10:12
I am not sorry for switching to C
11:34
Sheafification of G
Рет қаралды 245 М.