Work in HR? Unlock Free Profile

Microsoft Software Development Engineer In Test (SDET) Interview Question

"Given a string, find whether it has any permutation of another string. Need to be efficient"
Tags: technical
Add Tags [?]

Part of a Software Development Engineer In Test (SDET) Interview Review - one of 3,411 Microsoft Interview Reviews

Answers & Comments

of 0

isnt it enough if we find out whether the characters in the second string is present in the first?
(also the number of times each character appears).?

- Anonymous on Feb 27, 2013
of 0

The characters need to be consecutive. For example, if the second string is "abc", we need to find out whether the first string has one of the following: "abc" , "acb" , "bac" , "bca" , "cab" or "cba"

- Anonymous on Feb 27, 2013

This post has been removed. Please see our Community Guidelines or Terms of Service for more information.

of 1

public boolean test(String main, String sub){
        char[] a = main.toCharArray();
        char[] b = sub.toCharArray();
        char[] c = sub.toCharArray();

        for(int i = 0; i<a.length-b.length+1; i++){
            int k=i;
            for(int j=0; j<b.length; j++){
                c[j] = a[k++];
                return true;
        return false;

- Rachana Koneru on Mar 07, 2013

To comment on this question, Sign In with Facebook or Sign Up

Tags are like keywords, helping to categorise interview questions that have something in common.