MCPcopy Create free account
hub / github.com/HuberTRoy/leetCode / translate_pattern

Method translate_pattern

String/FindAndReplacePattern.py:51–63  ·  view source on GitHub ↗
(word)

Source from the content-addressed store, hash-verified

49 """
50
51 def translate_pattern(word):
52 result = ['0']
53 current = '0'
54 patterns = {word[0]: '0'}
55 for i in word[1:]:
56 if patterns.get(i) is not None:
57 result.append(patterns.get(i))
58 else:
59 current = str(int(current)+1)
60 patterns[i] = current
61 result.append(current)
62
63 return ''.join(result)
64
65 x = translate_pattern(pattern)
66

Callers

nothing calls this directly

Calls 1

getMethod · 0.80

Tested by

no test coverage detected