Flipkart Interview Question for Software Engineer / Developers


Country: India
Interview Type: In-Person




Comment hidden because of low score. Click to expand.
0
of 0 vote

This is from a programming contest/website.

- Anonymous March 19, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Can you post the link?

- hulk March 20, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

haha, I choose Perl to implement this:

$exp = q(^ab..*abc$);
$test = q(abyxxxxabc);

print "$exp, $test, " . evaluate($exp, $test)."\n";

sub evaluate{
	my $Exp = shift;
	my $testCase = shift;

	return "false" if ($testCase !~ /^[a-z]+[a-z]$/);	# contain only character in [a-z]?

	if ($testCase =~ $Exp){
		return "true";
	}
	else{
		return "false";
	}
};

- ninhnnsoc March 21, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Sorry I forgot to mention in my question description we are not allowed to use any regex.

- hulk March 21, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

^ and $ can be neglected removed as string without same also mean the same thing. Here is a dyanamic approach to the problem

bool isMatch(const char *s, const char *p) {
        int n=strlen(s), m=strlen(p), i, j, chars=0;
    
        //check if pattern have less that equal to character then string
        for(i=0; p[i]!='\0'; ++i) if(p[i]!='*' && n<++chars) return false;
        
        vector<bool> dp(n+2,false);
        // dp[n] is true fo first time, 
        // i.e end of string charater is true to enable correct match for last pattern character
        // At any time dp[i] == 1 mean we have match from i to n index
        for(i=m-1, dp[n]=true; i>=0; --i){
            if(p[i]=='*'){
                while(i>0 && p[i]==p[i-1]) --i; //skip multiple *
                for(j=n; j>=0 && !dp[j]; --j);
                for(; j>=0; --j) dp[j]=true;
            }else{
                for(j=0; j<n+1; ++j)
                    dp[j]=(p[i]==s[j] || p[i]=='?') ? dp[j+1] : false;
            }
        }
        return dp[0];
    }

- jitendra.theta June 20, 2014 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More