Minimum operations to convert array A to B
Given two Arrays A[] and B[] of length N and M respectively. Find the minimum number of insertions and deletions on the array A[], required to make both the arrays identical.
Note: Array B[] is sorted and all its elements are distinct, operations can be performed at any index not necessarily at end.
- Time : O(nlogn)
- Space : O(min(n,m))
c++
1 | class Solution { //lis solution |
- Time : O(nm)
- Space : O(nm)
c++
1 | class Solution { // lcs solution |