Senior Backend Engineer | BitGo
Summary
I completed an online assessment and a Data Structures & Algorithms round for a Senior Backend Engineer role at BitGo, where I tackled graph, Fibonacci, and top K talkative person problems.
Full Experience
Online Assessment
Question 1: Find shorted path between given source and target. Input was in the string format. So we need to create a graph first and the do BFS
Question 2: Fibonacci Series. Given array return fibbonacci number greater or equal to sum of array elements.
Round 1 DSA
Question: Given a transcript of meeting, find top k most talkative person in the meeting. No input format was given, we need to decide this.
I could not derive the test cases, interviwer gave some test cases all of them passed. He mentioned you should be able to think of test cases (whihch is very much obvious).
My Solution (rate this code):
import java.util.*; import java.io.*; class Node { String personId; int freq; int length;Node(String pId, int length) { this.personId = pId; this.length = length; freq = 1; }
@Override public String toString() { return personId; } }
/** // key: personId, value: Node // Node: { // String personId, // int freq; // int length; // } */
class Main {
public static List<Node> topKPersons(String transScript, int k) { String[] entries = transScript.split("\|");
PriorityQueue<Node> pq = new PriorityQueue<>((a, b ) -> a.freq != b.freq ? b.freq -a.freq : b.length - a.length); Map<String, Node> map = new HashMap<>(); for(String entry: entries) { // System.out.print(entry); String[] pair = entry.split(":"); if(pair.length != 2) continue; String pId = pair[0]; String speech = pair[1]; if(!map.containsKey(pId)) { Node node = new Node(pId, speech.length()); map.put(pId, node); } else { Node node = map.get(pId); node.freq++; node.length += speech.length(); } } for(Map.Entry<String, Node> it : map.entrySet()) { // String pId = it.getValue(); Node node = it.getValue(); pq.add(node); // if(pq.size() < k) // pq.add(node); // else { // Node node = pq.remove(); // pq.add(node); // } } List<Node> res = new ArrayList<>(); for(int i=0 ; i<k && !pq.isEmpty(); i++) { res.add(pq.remove()); } return res;}
public static void main (String[] args) { String trasnScript = "person1:|person2:|person1:hello|person3:hello|person2:hello"; List<Node> res = topKPersons(trasnScript, 1); System.out.println(res); }
}
We left with 5 minutes after test cases and code analysis. I asked what was expectation how many problems were expected to solve, but he did not clarify this.
Interview Questions (3)
Find shorted path between given source and target. Input was in the string format. So we need to create a graph first and the do BFS
Fibonacci Series. Given array return fibbonacci number greater or equal to sum of array elements.
Given a transcript of meeting, find top k most talkative person in the meeting. No input format was given, we need to decide this.