`{"id":"b7e35a16-398d-477b-b0e6-c7b1dae57199","name":"Isomorphic Strings","description":"1. You are given two strings s1 and s2.\r\n2. You have to determine if they are isomorphic or not.\r\n3. Two strings are called isomorphic if -\r\n -> Every character of s1 can be mapped with characters of s2.\r\n -> A character of s1 can be mapped to only one character.\r\n -> All occurrences of a character must be replaced with another character while preserving the order of characters.\r\n\r\nNote -> Length of s1 is equal to the length of s2.","inputFormat":"Two strings s1 and s2","outputFormat":"true/false","constraints":"1 &lt;= length of strings &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string>\n#include <bits/stdc++.h>\nusing namespace std;\nbool isIsomorphic(string s, string t) {\n//write your code here\n}\n\n\n\n\nint main() {\n string str1, str2;\n getline(cin, str1);\n getline(cin, str2);\n int ans = isIsomorphic(str1, str2);\n if (ans == 1) {\n cout << \"true\";\n }\n else {\n cout << \"false\";\n }\n\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static boolean isIsomorphic(String s, String t) {\r\n\t\t// write your code here\r\n\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString A = scn.next();\r\n\t\tString B = scn.next();\r\n\t\tSystem.out.print(isIsomorphic(A, B));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"pepcoding\r\nsosherlok","sampleOutput":"false","questionVideo":"https://www.youtube.com/embed/6Qkail843d8?end=320","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"00e4a372-3dca-4e27-83f2-e321fdb305de","name":"Isomorphic Strings","slug":"isomorphic-strings","type":1}],"next":{"id":"344b90a0-c8a2-4f83-972a-ab019a560fbe","name":"Isomorphic Strings MCQ","type":0,"slug":"isomorphic-strings-mcq"},"prev":{"id":"7f0fe065-23b8-4d19-bc6f-3f0ead8128e8","name":"Group Shifted String","type":3,"slug":"group-shifted-string"}}}`

# Isomorphic Strings

1. You are given two strings s1 and s2. 2. You have to determine if they are isomorphic or not. 3. Two strings are called isomorphic if - -> Every character of s1 can be mapped with characters of s2. -> A character of s1 can be mapped to only one character. -> All occurrences of a character must be replaced with another character while preserving the order of characters. Note -> Length of s1 is equal to the length of s2.

`{"id":"b7e35a16-398d-477b-b0e6-c7b1dae57199","name":"Isomorphic Strings","description":"1. You are given two strings s1 and s2.\r\n2. You have to determine if they are isomorphic or not.\r\n3. Two strings are called isomorphic if -\r\n -> Every character of s1 can be mapped with characters of s2.\r\n -> A character of s1 can be mapped to only one character.\r\n -> All occurrences of a character must be replaced with another character while preserving the order of characters.\r\n\r\nNote -> Length of s1 is equal to the length of s2.","inputFormat":"Two strings s1 and s2","outputFormat":"true/false","constraints":"1 &lt;= length of strings &lt;= 1000","sampleCode":{"cpp":{"code":"#include<iostream>\n#include<string>\n#include <bits/stdc++.h>\nusing namespace std;\nbool isIsomorphic(string s, string t) {\n//write your code here\n}\n\n\n\n\nint main() {\n string str1, str2;\n getline(cin, str1);\n getline(cin, str2);\n int ans = isIsomorphic(str1, str2);\n if (ans == 1) {\n cout << \"true\";\n }\n else {\n cout << \"false\";\n }\n\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static boolean isIsomorphic(String s, String t) {\r\n\t\t// write your code here\r\n\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\tpublic static void main(String[] args) {\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tString A = scn.next();\r\n\t\tString B = scn.next();\r\n\t\tSystem.out.print(isIsomorphic(A, B));\r\n\t}\r\n\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"pepcoding\r\nsosherlok","sampleOutput":"false","questionVideo":"https://www.youtube.com/embed/6Qkail843d8?end=320","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"ec6515dc-6811-4c65-912f-0134b65df120","name":"HashMap and Heap For Intermediate","slug":"hashmap-and-heap-for-intermediate-10002","type":0},{"id":"00e4a372-3dca-4e27-83f2-e321fdb305de","name":"Isomorphic Strings","slug":"isomorphic-strings","type":1}],"next":{"id":"344b90a0-c8a2-4f83-972a-ab019a560fbe","name":"Isomorphic Strings MCQ","type":0,"slug":"isomorphic-strings-mcq"},"prev":{"id":"7f0fe065-23b8-4d19-bc6f-3f0ead8128e8","name":"Group Shifted String","type":3,"slug":"group-shifted-string"}}}`

Editor

# Isomorphic Strings

easy

1. You are given two strings s1 and s2. 2. You have to determine if they are isomorphic or not. 3. Two strings are called isomorphic if - -> Every character of s1 can be mapped with characters of s2. -> A character of s1 can be mapped to only one character. -> All occurrences of a character must be replaced with another character while preserving the order of characters. Note -> Length of s1 is equal to the length of s2.

## Constraints

1 <= length of strings <= 1000

## Format

### Input

Two strings s1 and s2

true/false

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}pepcoding sosherlok```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}false`

Question Video

Discussions

Show Discussion

Related Resources