Skip to content

Commit 2475677

Browse files
committed
solved: 205. Isomorphic Strings
Signed-off-by: rajput-hemant <[email protected]>
1 parent e65746b commit 2475677

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package main
2+
3+
func isIsomorphic(s string, t string) bool {
4+
const max = 256
5+
6+
var (
7+
sMap [max]int
8+
tMap [max]int
9+
)
10+
11+
for i := 0; i < len(s); i++ {
12+
sIndex := s[i] - 'a'
13+
tIndex := t[i] - 'a'
14+
15+
if sMap[sIndex] != tMap[tIndex] {
16+
return false
17+
}
18+
19+
sMap[sIndex] = i + 1
20+
tMap[tIndex] = i + 1
21+
}
22+
23+
return true
24+
}

0 commit comments

Comments
 (0)