Uber Interview Question

Revision en2, by Moksh_grover, 2020-08-12 11:24:15

Problem Statement

Given three strings p, q, r. Count the possible number of ways to create string r using string p and string q such that,the order of the selected characters in all the strings is preserved and atleast one characters from both the string is selected.

Constraint

  • Strings will have max length 100
  • They will consist of lowercase english alphabets.
  • Return the answer modulo 10^9+7

Sample Test Case

  • p :"ab"
  • q :"ba"
  • r :"aba"

Output : 2

Explanation

Two ways to form aba :
1. from p 'a' ,from q 'ba'
2. from p 'ab' ,from q 'a'

This problem was asked in recent coding rounds .Can somebody help me with the solution?

Tags #3d-dp, memoization

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Moksh_grover 2020-08-12 11:24:15 11 Tiny change: 'o form aba\n1. from ' -> 'o form aba: \n1. from '
en1 English Moksh_grover 2020-08-12 11:21:44 807 Initial revision (published)