Pregunta de entrevista de Meta

Isomorphic trees

Respuestas de entrevistas

Anónimo

9 may 2013

(print a tree, level by level) public static void printTree(Tree t) { int treeDepth = findDepth(t); for (int i = 0; i 0) { printLevel(t.left, level-1); printLevel(t.right, level-1); } }

Anónimo

9 may 2013

(profit maximization) partition prices into non-decreasing sequences; buy at start of sequence of each sequence and sell at end; can be done iteratively by peeking ahead to next day's closing price

Anónimo

9 may 2013

(a^3 + b^3 = c^3 + d^3) public static void a3b3c3d3() { Hashtable> h = new Hashtable>(); for (int a = 0; a prev = h.get(lhs); if (null == prev) prev = new ArrayList(); for (String s : prev) { System.out.println(a + " " + b + " = " + s); } prev.add(a + " " + b); h.put(lhs, prev); } } }