We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Append and Delete
Append and Delete
Sort by
recency
|
1448 Discussions
|
Please Login in order to post a comment
Step-by-step Solution in C++ :-
1.Find the common prefix length.
2.Calculate how many characters need to be deleted from s and added to reach t.
3.Check if k is enough to do that and whether the leftover operations can be used meaninglessly.
Java ::
public static String appendAndDelete(String s, String t, int k) { // Write your code here int n = s.length(); int m = t.length(); int i = 0; char[] a = s.toCharArray();
if i´m not mistaken these tests are wrong, please if i'm wrong help me to understand my mistake
Thing is, you need to use exactly k moves, no more, no less. Else, fail.
The test case 7 is wrong
s=aaaaaaaaaa t=aaaaa k=7
You only need 5 delete operations on s to convert t
But the test case expect "Yes"