Bloomberg interview question

Some general interview questions such as differences between C++ and Java, knowledge about C++ like polymorphism. Also asked about the projects I've done before, but not pretty detailed. The algorithm questions were not hard. Things like find peak using binary search, intersection of array using hash table, right side view of tree using queue, etc. Still have no idea about the reason I failed.

Interview Answer

Anonymous

Jul 6, 2016

private static void printRightView(TreeNode root) { Queue<div>q = new LinkedList(); q.offer(root); int levelNodes = 0; while(!q.isEmpty()) { levelNodes = q.size(); while(levelNodes > 0) { TreeNode t = q.poll(); if(t.left != null) q.offer(t.left); if(t.right != null) q.offer(t.right); if(levelNodes == 1) System.out.print(t.key+" "); levelNodes--; } System.out.println(); } }</div>