Pergunta de entrevista da empresa Uber

Search a target number in a Rotated Sorted Array.

Respostas da entrevista

Sigiloso

4 de abr. de 2016

public int search(int[] nums, int target) { int start = 0; int end = nums.length - 1; while (start = nums[start]) { end = mid - 1; } else { start = mid + 1; } } else { //5 6 7 1 2 3 4, 6 if (target > nums[mid] && target <= nums[end]) { start = mid + 1; } else { // end = mid - 1; } } } return -1; }

1

Sigiloso

27 de out. de 2015

Binary search

Sigiloso

10 de dez. de 2015

I would like to slap your interviewer for asking this question in an interview: "How do you calculate PI, if I just give you a calculator." Definitely he/she don't know what is "problem solving" in software engineering. Btw, I work for Amazon.

Sigiloso

10 de fev. de 2016

To answer the Pi question- I will first turn the calculator on, press 22, then press '/', then 7, then '='. Then I will test for edge cases where calculator's buttons may not have been pressed properly. -_-

1