You are viewing a single comment's thread. Return to all comments →
TS Solution -- optimal time complexity but not optimised:
function appendAndDelete(s: string, t: string, k: number): string { // Write your code here
for(let i = 0; i < Math.max(s.length, t.length); i++) { if(s[i] != t[i]) { let numCharsToDelete:number = s.length - i let numCharsToRebuild:number = t.length - i let minActionsToZeroAndBack:number = (s.length - numCharsToDelete) * 2 k -= numCharsToDelete + numCharsToRebuild if (k >= 0 && (k % 2 === 0 || minActionsToZeroAndBack <= k )) { return "Yes" } else { return "No" } } } return "Yes"
}
Seems like cookies are disabled on this browser, please enable them to open this website
Append and Delete
You are viewing a single comment's thread. Return to all comments →
TS Solution -- optimal time complexity but not optimised:
function appendAndDelete(s: string, t: string, k: number): string { // Write your code here
}