What are isomorphic strings
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character may map to itself.
Given "egg", "add", return true.
Given "foo", "bar", return false.
Given "paper", "title", return true.
You may assume both s and t have the same length.
For two strings s and t, determine whether they are isomorphic.
If the letters in s can be replaced by those in t, then the two strings are said to be isomorphic.
All letters displayed must be replaced by other letters in their original order. Two letters are different to substitute for the same letter, but one letter can substitute for itself.
returns "egg", "add" and returns true.
returns "foo", "bar" and returns faalse.
specifies "paper" and "title" and returns true.
You can assume that the lengths of s and t are the same.
The meaning of this question is to replace the original string letter, the letter that appears multiple times, and the letter that replaces it must appear multiple times and appear in the original position.
Speaking of letters, I still think about judging by counting numbers. Iterate through the string to record the number of times each letter occurred. Since it is not said that these are all lowercase letters, the capacity of the number of records array should be larger because the two strings are the same length. So it is enough to drive in a loop.
After recording, run through the string again and assess whether the letters are identical in the corresponding positions in the two strings.
However, there is another problem: a test case of "abba" and "abab" occurred while sending. In this case, the number of letters is displayed the same, but the position is slightly different. To solve this problem, you need to create two more array records. The sum of the sequence numbers of the positions where the corresponding letters appear in the two character strings, only the sum of the positions where the corresponding letters appear is the same, they can be completely isomorphic.
Collection: https: //github.com/Cloudox/LeetCode-Record
Show author home page
- How were Stalin and Hitler alike
- What are some famous Malayalam folklore
- Which SAP module is required
- Could Trump's actions cause a war?
- What is gold separator
- What material of utensils should be used
- How do I become someone's close friend
- Things are always more important than people
- What does interim dividend mean?
- What does drama mean to you
- Is there an independent marketplace for homeowner insurance
- What do you buy monthly
- What are the effects of hate speech
- What is a good laser engraving machine
- The Washington Post is a credible website
- What do Croatians think of Montenegro?
- Do animals make sense for me?
- What are the reasons for the success of Fiverrs
- What are the different types of bridge scales
- Can a Malay boy marry a Marathi girl?
- How are churches founded in Japan
- Could the 737 Max program be canceled
- Why do I have double vision
- What is international politics