Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,955 views

For proper oa or interview experiences list of all top tech companies visit :

https://oa.desiqna.in

https://interview.desiqna.in

in Online Assessments by Expert (46,090 points)
edited by | 1,955 views

3 Answers

0 like 0 dislike
Best answer

Images of ques

imageimageimage

 

by Expert (46,090 points)
selected by
0 like 0 dislike
```cpp
ll helper(string a, string b){
  ll ind = 0, ind1 = 0;
  for(int i = 0; i < a.size(); i++){
    if(b[ind] == a[i]) ind++;
  }
  return (int)(b.size()) - ind;
}

void solve() {
  string a, b;
  cin >> a >> b;
  cout << helper(a, b) << endl;
}```
by (140 points)
0 like 0 dislike
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String searchword = s.next();
        String targetword = s.next();
        int res = mininsertions(searchword,targetword);
        System.out.println(res);
    }
    public static int mininsertions(String searchword,String targetword){
        int n = searchword.length(), m = targetword.length();
        int i=0,j=0;
        //Loop to check how many characters of targetword matches with searchword.

        //Number of Characters that don't match are the actual number of insertions needed at searchWord.
        while(i<n && j<m){
            if(searchword.charAt(i)==targetword.charAt(j))
                ++j;
            ++i;
        }
        
        return m - j;
    }
}
by Expert (500 points)
edited by