Pergunta de entrevista da empresa Meta

Balance parenthesis by removal, generate fibonacci.

Respostas da entrevista

Sigiloso

12 de jul. de 2017

Remove extra parenthesis with O(N) space and time complexity. Give a good solution to fibonacci that isn't the super complicated one that would take 45 minutes to draft.

Sigiloso

24 de ago. de 2017

Fibonacci in O(n) time O(1) space: public int fibonacci(int n) { if (n == 1) return 1 int prev = 0, cur = 1; for(int i = 2; i <= n; i++} { int tmp = prev; prev = cur; cur = prev + cur; } return cur; }

Sigiloso

24 de ago. de 2017

Balance Parenthesis public static String balanceParenthesis(String s) { StringBuilder str = new StringBuilder(s); int left = 0; for(int i = 0; i 0) { left--; } else { str.deleteCharAt(i--); } } } int right = 0; for(int i = str.length() - 1; i >= 0; i--) { if(str.charAt(i) == ')') { right++; } else if(str.charAt(i) == '('){ if(right > 0) right--; else { str.deleteCharAt(i); } } } return str.toString(); }

Sigiloso

19 de jan. de 2018

Hi can you specify some question that we asked during the on site interview ? What was asked to code in the demo?