>>> abbr("daBcd", "ABC") True >>> abbr("dBcd", "ABC") False
(a: str, b: str)
| 13 | |
| 14 | |
| 15 | def abbr(a: str, b: str) -> bool: |
| 16 | """ |
| 17 | >>> abbr("daBcd", "ABC") |
| 18 | True |
| 19 | >>> abbr("dBcd", "ABC") |
| 20 | False |
| 21 | """ |
| 22 | n = len(a) |
| 23 | m = len(b) |
| 24 | dp = [[False for _ in range(m + 1)] for _ in range(n + 1)] |
| 25 | dp[0][0] = True |
| 26 | for i in range(n): |
| 27 | for j in range(m + 1): |
| 28 | if dp[i][j]: |
| 29 | if j < m and a[i].upper() == b[j]: |
| 30 | dp[i + 1][j + 1] = True |
| 31 | if a[i].islower(): |
| 32 | dp[i + 1][j] = True |
| 33 | return dp[n][m] |
| 34 | |
| 35 | |
| 36 | if __name__ == "__main__": |
nothing calls this directly
no outgoing calls
no test coverage detected