3330. Find the Original Typed String I
用來測試程式碼 highlight 的文章 ><。
Approach
紀錄每個連續的 substring 長度,把它加到答案中。但這樣會多算,因為每個可能多打的片段,都有算到”原本字串”的可能性,因此需要扣掉連續字元 substring 的數目減掉 1,此即為正確答案。
Complexity
$$O(n)$$
Code (C++)
1 | class Solution { |
用來測試程式碼 highlight 的文章 ><。
紀錄每個連續的 substring 長度,把它加到答案中。但這樣會多算,因為每個可能多打的片段,都有算到”原本字串”的可能性,因此需要扣掉連續字元 substring 的數目減掉 1,此即為正確答案。
$$O(n)$$
1 | class Solution { |
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
1 | $ hexo new "My New Post" |
More info: Writing
1 | $ hexo server |
More info: Server
1 | $ hexo generate |
More info: Generating
1 | $ hexo deploy |
More info: Deployment