GeeksforGeeks » Interview Questions

Microsoft Interview Question for Software Engineer/Developer (Fresher) about Strings

(6 posts)

Tags:

  1. mani
    guest
    Posted 1 year ago #

    Your are given two strings A and B. Output true if all the character in string A are present in String B. The solution should be optimal in time and space.
    For egs..
    A="ppppppppppaaaaaaaaaa"
    B="pa"
    Output = true

    problem is that u cant check each character of a with entire b tht is not optimal.

  2. lost
    guest
    Posted 1 year ago #

    split string A, and put each char into a set to remove the duplicated chars, and then check whether the chars in B is contained in the set. By doing this, we can get the answer in O(m+n).

  3. ashish
    guest
    Posted 1 year ago #

    make a hash table or array of 256 element
    a[256];
    for(int i=0;*(s1+i);i++){
    a[*(s1+i)]++;
    }
    for(j=0;*(s2+j);j++){
    if(*(s2+j))
    printf("no");
    }
    printf("yes");
    }

  4. 10098
    guest
    Posted 1 year ago #

    quicksort the string A and for each char in B do binary search

  5. manjusha chava
    Member
    Posted 1 year ago #

    For the the question
    our are given two strings A and B. Output true if all the character in string A are present in String B. The solution should be optimal in time and space.

    V can first remove all the duplicates from the string A and then check if those characters are present in B

  6. Aditya
    guest
    Posted 1 year ago #

    Quick sort both the strings in O(nlogn). Remove the duplicate in O(n) in both the strings.
    Then compare the element of both the strings(already sorted) like we do for merging.


Reply

You must log in to post.

RSS feed for this topic