Pergunta de entrevista da empresa Meta

The initial question (writing a function to calculate a square root) ended up being the most difficult because it threw me off. I knew there was a good iterative method for doing so, but could not recall Newton's method in the moment, and I sadly let this nagging thought get in the way of my ability to work through the problem. My failure to perform well on that question set a negative tone for the rest of the interview, since each interviewer after the first can see notes from the previous interviewers.

Respostas da entrevista

Sigiloso

4 de out. de 2012

"; $x = sqrt($a); print "The sqrt is $x"; if (!function_exists('sqrt')) { function sqrt ($a){ if ($a == 1 || $a == 0) { print "The sqrt of $a is $a "; } if ($a $prec) { $mid = ($start + $end)/2; $midsq = $mid*$mid; if ($midsq == $a) { return $mid; } else if ($midsq Its important to understand the problem and try to solve it by hand first. Once you have figured out your solution use appropriate alogrithm techniques. Most likely its one you know or something you've come across during your coursework. The interviewer usually looks for your approach most of the time than the final solution. I hope this helps.

4

Sigiloso

3 de set. de 2012

Interviewers at Facebook DO NOT share feedback with each other before the interview. Your experience in one interview will not affect the next one at all.

3

Sigiloso

25 de set. de 2012

my experience was different (or perhaps it was a test of honesty) In my face to face interview they asked me several questions that I had already answered in the phone interview. I told the guy that I had already answered these questions, and we moved on to a more open ended scenario discussion I eventually got the job, hopefully start in 3 weeks, wish me luck

2

Sigiloso

23 de fev. de 2015

import java.util.Scanner; public class SquareRoot { public static void main(String[] args) { final Scanner in = new Scanner(System.in); while (true) { System.out.println("Enter number : "); System.out.println("Sq.Root is : " + sqRoot(in.nextInt())); } } private static float sqRoot(int num) { float guess = num/2f; float prevGuess = num; while (prevGuess != guess) { System.out.println ("Sqroot for " + num + " is guess " + guess); float adjustment = 1 - guess*guess/num; prevGuess = guess; guess += adjustment; } return guess; } }

1

Sigiloso

10 de out. de 2012

The answer by rajan should have i initialised at 1.

Sigiloso

8 de nov. de 2012

function sqroot($number){ $squ = 0; $mod = 1; for($i = 0; $i $number){ $squ-=$mod; $mod/=10; } } return $squ; }

Sigiloso

22 de ago. de 2012

Do not get nervous. I think that they just wrote down the questions that were asked such that another interviewer would not ask the same question again.

Sigiloso

10 de out. de 2012

The answer by rajan should have i initialised at 1.

Sigiloso

27 de set. de 2012

For square root u dont want to remember newtons method. number = 9 N*N = number N = 9/N for(int i=0;i

1