Zynga Games | SE1 | Bangalore | Feb 2021 | Reject
Anonymous User
1251

Current Company : Startup
YOE : 2.5 Yrs
Position Applied for : SE1
Date: February 2021

There was no OA, the HR connected with me on LinkedIn and scheduled interviews.

Round - 1 (1 hour)

  1. Deep dive into my past experience and discussion about design decisions made
  2. Some follow up questions like difference TCP and UDP, what are sockets?, what happens when you type www.google.com and also some question about DNS etc.
  3. Given a file with 2 million names return a file with unique names, implement this using without using java util library (meaning you can't use set)
  4. Implemented using a hashtable with linked list chaining for hash collison, ran some test cases and the interviewer seemed satified with solution.

Round - 2 (1.5 hour)

  1. Intoduction and asked about my past experiences and current projects.
  2. Implement auto complete system (he told me to consider this as library so that any external user can use it)
  3. Build an autocomplete system for words, app => apple, apply, apples, application, English dictionary available as text file
  4. Build relevance to your results - Personalized historical relevance
  5. Limit - 10 most relavant suggestions
  6. I proposed a Trie based solution but was not able to implement is completely. Please have a look at my code and suggest me where I went wrong (honestly I thought I did Ok).
import java.io.*;
import java.util.*;


class Trie {
    final TrieNode root;

    public Trie() {
        this.root = new TrieNode('#');
    }

    public int getRelevenceCountOfString(final String s) {
        TrieNode current = root;
        for (int i=0;i<s.length();i++) {
            if (current == null || current.next(s.charAt(i)) == null) {
                return 0;
            } else {
                current = current.next(s.charAt(i));
            }
        }
        return current.relevenceCount;
    }

    public void insert(final String s) {
        TrieNode current = root;
        for (int i=0;i<s.length();i++) {
            if (current.trieNodes[s.charAt(i) - 'a'] == null) {
                current.trieNodes[s.charAt(i) - 'a'] = new TrieNode(s.charAt(i));
            }
            current = current.next(s.charAt(i));
        }
        current.relevenceCount++;
    }

    public List<String> query(String s) {
        List<String> result = new ArrayList<>();

        TrieNode current = root;
        for (int i=0;i<s.length();i++) {
            if (current == null || current.next(s.charAt(i)) == null) {
                return result;
            } else {
                current = current.next(s.charAt(i));
            }
        }

        List<List<Character>> suffixes = new ArrayList<>();
        List<Character> suffix = new ArrayList<>();
        getSuffixes(current, suffixes, suffix);

//        System.out.println("Size of suff: " + suffixes.size());
//        for (String suff : suffixes) {
//            System.out.println("Suff: " + suff);
//            result.add(s + suff);
//        }

        return result;
    }

    private void getSuffixes(TrieNode trieNode, List<List<Character>> res, List<Character> r) {
        System.out.println("Inside getSuffixes for trieNode: " + trieNode.character);
        System.out.println("Res: " + res);
        System.out.println("r: " + r);
        TrieNode[] trieNodes = trieNode.trieNodes;
        if (isNoSuffix(trieNodes)) {
            res.add(r);
            r.remove(res.size() - 1);
            return;
        } else {
            for (TrieNode tN: trieNodes) {
                if (tN != null) {
                    r.add(tN.character);
                    getSuffixes(tN, res, r);
                }
            }
        }
    }

    private boolean isNoSuffix(TrieNode[] trieNodes) {
        for (TrieNode trieNode: trieNodes) {
            if (trieNode != null) {
                return false;
            }
        }
        return true;
    }

    public void updateRelevenceCount(final String s) {
        insert(s);
    }
}


class TrieNode {
    char character;
    int relevenceCount;
    final TrieNode[] trieNodes = new TrieNode[26];

    TrieNode(char c) {
        this.character = c;
    }

    public TrieNode next(final char c) {
        return trieNodes[c-'a'];
    }
}


class TrieTest {

    public static void main(String[] args) {
        Trie trie = new Trie();

        trie.insert("apple");
        trie.insert("apply");
        trie.insert("apples");
        trie.insert("application");

        List<String> res = trie.query("app");
        for (String r : res) {
            System.out.println(r);
        }
    }
}

Overall, the experience was good with HR and interviewers.

Comments (4)