package
0.0.0-20241220224003-b7cf03a90b2b
Repository: https://github.com/szhou12/leetcode-go.git
Documentation: pkg.go.dev
# README
2976. Minimum Cost to Convert String I
Solution idea
Floyd-Warshall Algorithm
- 破题:
original[]
,changed[]
,cost[]
三者想象成有向图。通过 Floyd-Warshall 算法,求出任意两点之间的最短路径,即可得到答案。 - 注:我的解法使用 Floyd 算法模版的Variation。与参考答案 (标准模版) 稍微不同。
Time complexity = $O(n^3)$