Skip to content

Commit 27cec2f

Browse files
author
Partho Biswas
committed
1153. String Transforms Into Another String
1 parent 84554cd commit 27cec2f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ BFS, DFS, Dijkstra, Union Find, Kruskal, Prim's, Minimum Spanning Tree, Topologi
426426
|17| **[785. Is Graph Bipartite?](https://tinyurl.com/wvwqw2j)** | [Python](https://tinyurl.com/wu6rdaw/785_Is_Graph_Bipartite.py)| **[codinginterviewclass.com](https://tinyurl.com/s4qseoz)**, **[Official](https://tinyurl.com/rynbqly)** | Medium | **Important, Learned new things. Undirected Graph** |
427427
|18| **[133. Clone Graph](https://tinyurl.com/y42nwqz8)** | [Python](https://tinyurl.com/wu6rdaw/133_Clone_Graph.py)| **[codinginterviewclass.com](https://tinyurl.com/tnca94n)**, **[Official](https://tinyurl.com/usxjk49)** | Medium | **Important, Learned new things. Undirected Graph** |
428428
|19| **[332. Reconstruct Itinerary](https://tinyurl.com/gn2mv3k)** | [Python](https://tinyurl.com/wu6rdaw/332_Reconstruct_Itinerary.py)| [Vid 1](https://tinyurl.com/w47evd9), [Vid 2](https://tinyurl.com/uvop34p), [Art 1](https://tinyurl.com/tsy24pl), [Art 2](https://tinyurl.com/srazxo3), [Art 3](https://tinyurl.com/wluob5j), **[Art 4](https://tinyurl.com/y4s9crf6)** | Medium | **Important, Learned new things. Directed Graph. Eulerian path and top Sort** |
429+
|20| **[1153. String Transforms Into Another String](https://tinyurl.com/sv9hpo8)** | [Python](https://tinyurl.com/wu6rdaw/1153_String_Transforms_Into_Another_String.py)| **[Vid 1](https://tinyurl.com/ty2ga7d)**, [Vid 2](https://tinyurl.com/vxr9zxp), [Art 1](https://tinyurl.com/rklzgkk), [Art 2](https://tinyurl.com/seb6vqq), [Art 3](https://tinyurl.com/vfjwn5h), [Art 4](https://tinyurl.com/w62hpq2), [Art 5](https://tinyurl.com/tteucry), [Art 6](https://tinyurl.com/uvctnvz) | Extremely Hard | **TODO: Check again. Very Important and tricky, Learned new things. Digraph.** |
429430

430431

431432
</p>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Source: https://tinyurl.com/tvppgc4
2+
3+
class Solution(object):
4+
def canConvert(self, str1, str2):
5+
"""
6+
:type str1: str
7+
:type str2: str
8+
:rtype: bool
9+
"""
10+
if str1 == str2:
11+
return True
12+
m = {}
13+
for i in range(len(str1)):
14+
if str1[i] not in m:
15+
m[str1[i]] = str2[i]
16+
elif m[str1[i]] != str2[i]:
17+
return False
18+
return len(set(str2)) < 26

0 commit comments

Comments
 (0)