In [1]:
Append and Delete
hackerrank
Key Idea
Note that the algorithm should delete all characters until reacing LCS(Longest Common Prefix).
And then, append some characters to make the target string.
There are some exceptions.
k
operation is large enough to make target string.
- residual operations can be used append and delete until making target string.
- Note that the number of residual operations should be even.
In [4]:
In [5]:
In [6]:
Time Complexity
$O(n)$
Report
easy
문제였지만, enumerate하는 과정에서 exception들을 잘 고려야했다.
exception들을 잘 처리하는 것도 중요한 문제이다.
Leave a comment