Last active
May 13, 2020 15:28
-
-
Save cypher-nullbyte/22b418b8a33ce755fff48619203596fa to your computer and use it in GitHub Desktop.
Vpropel VIT | POD | 12/05/2020 | Can they Marry | 11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<string> | |
using namespace std; | |
int main() | |
{ | |
bool check=true; | |
string A,B; | |
cin>>A>>B; | |
for(int i=0;i<A.size();i++) | |
{ | |
string temp=A; | |
for(int j=i+1;j<A.size();j++) | |
{ | |
temp[i]=A[j]; | |
temp[j]=A[i]; | |
if(temp==B) | |
{ | |
check=false; | |
cout<<"Yes"; | |
return 0; | |
} | |
temp=A; | |
} | |
} | |
if(check==true) | |
cout<<"No"; | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Can they Marry | |
Two strings A and B can marry each other if and only if we can swap any two letters in A so that the result equals B | |
Example:- | |
A=”ab”, B=”ba” | |
Yes, As when you swap a and b in A you will get “ba” which is B | |
A=”aa”, B=”aa” | |
Yes, As when you swap a and a in A you will result in “aa” which is B | |
A=”ab”,B=”ab” | |
No, As swapping here does not result in B | |
Input format:- | |
String A | |
String B | |
Output format:- | |
Yes or No |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 19BLC1055 SUNIL KUMAR GV | |
2 19BCE1497 V.V.VAISHNAVI | |
3 19BCE1717 MAKESH SRINIVASAN | |
4 19BCE1492 P.K. AMUDHINI | |
5 19BDS0055 RUSHABH BHAGWANDAS KELA | |
6 19BCE1310 SHAUNAK SUNIL DESHPANDE | |
7 19BAI1151 PRANAV BALAJI | |
8 19BEC1212 SUJITH K P | |
9 19BEC1172 JANAPAREDDY VENKATA HAMITH NAR | |
10 19BDS0078 ANIRUDH MISHRA | |
11 19BCI0016 CHIRANJEET SINGH | |
12 19BCE2642 GUNJAN RAJ TIWARI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment