Flipkart Interview Question for Software Engineer / Developers

Country: India
Interview Type: In-Person

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

Build separate suffix trees for author, name and publisher.
Insert all the suffixes of all the authors in the first suffix tree. Do the same for name and publisher. Here suffix trees are useful because:

* Suffix trees facilitate partial string matching.
* We can match the pattern in O(p) time, where p is the length of the pattern.
* They take linear extra space.

Partial string matching can be done as explained below.
Every substring of a given string is a prefix of one of its suffix. So we search the given query string starting from the root and match until the input is exhausted. Suppose we reach a node n. Then go to every leaf from node n and add that string to the list of suggestions.

There exists an online linear time construction algorithm for suffix trees, known as Ukkonen's algorithm

- EOF October 26, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 votes

when this interview was happened?
Is it for SDE-I position?

- sri October 28, 2013 | Flag
Comment hidden because of low score. Click to expand.
of 0 vote

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class test5BookSearch {

public static void main (String[] args){
HashMap<Integer, String> BookDetail = new HashMap<Integer, String>();
HashMap<Integer, String> BookDetail2 = new HashMap<Integer, String>();
BookDetail.put(1, "JavaFlavours,JohnnyDepp,Oreilly,2005,51.66,620");
BookDetail.put(2, "Programming with java,Clara,Pearson,2006,95.25,350");
BookDetail.put(3, "Let Us java,Sami Shaio,Apress,2009,68.99,562");
BookDetail.put(4, "Oracle Certified java,Orca Starbuck,Oracle,2011,102.52,105");
BookDetail.put(5, "Java 7 Essentials,John wiley,Sybex,2012,98.00,56");
List<String> details = new ArrayList<String>();
for(int i =0;i<BookDetail.size() ; i++){
String Value = BookDetail.get(i+1);
String[] Values = Value.split(",", -1);
for(int j=0;j<3 ;j++ ){

String search = "a";
for(int k =0; k<details.size() ;k++ ){
String getValue = details.get(k);
int index = details.indexOf(getValue);
index = index/3 ;
String Line ="" ;
Line = BookDetail2.get(index + 1);
if(Line != null){
String[] LineValues = Line.split(",",-1);
System.out.println("\nName :" +LineValues[0]);
System.out.println("Author :" +LineValues[1]);
System.out.println("Publisher :" +LineValues[2]);
System.out.println("Year :" +LineValues[3]);
System.out.println("Price :" +LineValues[4]);
System.out.println("Inventory :" +LineValues[5]);
BookDetail2.remove(index + 1);


Can change the "search" string or can pass it as argument too.

- RF October 29, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
of 0 vote

#Python, and works great
def field_indexer(index, field, string, book_id):
        field_index = index[field]
        index[field] = {}
        field_index = index[field]
    for token in string.split():
        token = token.strip().lower()
            field_index[token] = set()
    return index

def search_field(index, field, query):
    field_index = index[field]
    matched_ids = set()
    for token in query.split():
        token = token.strip().lower()
            matched_ids = matched_ids | field_index[token]
            #lets do partial search if there is no whole word
            for key in field_index.keys():
                if token in key:
                    matched_ids = matched_ids | field_index[key]
    return matched_ids

catalog = list()
catalog.append({"name": "Politics in your pants",
                "author": "Rahul Gandhi",
                "publisher": "Congress"})

index = dict()
book_id = 0

#indexing done hre
for book in catalog:
    for field, value in book.iteritems():
        index = field_indexer(index, field, value, book_id)
    book_id += 1

#query here
for id in search_field(index, field="author", query="Rahul G"):
    print catalog[id]

- Anonymous January 30, 2014 | Flag Reply

Add a Comment

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


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


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