MCPcopy Create free account
hub / github.com/subbarayudu-j/TheAlgorithms-Python / abbr

Function abbr

dynamic_programming/abbreviation.py:15–27  ·  view source on GitHub ↗
(a, b)

Source from the content-addressed store, hash-verified

13
14
15def abbr(a, b):
16 n = len(a)
17 m = len(b)
18 dp = [[False for _ in range(m + 1)] for _ in range(n + 1)]
19 dp[0][0] = True
20 for i in range(n):
21 for j in range(m + 1):
22 if dp[i][j]:
23 if j < m and a[i].upper() == b[j]:
24 dp[i + 1][j + 1] = True
25 if a[i].islower():
26 dp[i + 1][j] = True
27 return dp[n][m]
28
29
30if __name__ == "__main__":

Callers 1

abbreviation.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected