Questions d'entretiens - Softwareentwickler | Glassdoor.ca

# Questions d'entretiens - Softwareentwickler

9,296

Questions d'entretien de softwareentwickler partagées par les candidats

## Le top des questions d'entretien

Trier: PertinencePopulaires Date

### Cette question a été posée à un(e) Software Engineer chez Facebook :

3 nov. 2012
 implement sqrt without using math libray9 réponsese^((ln(x))/2)I think exp and ln still require a Math library. How about using Newton's method to find the root of f(x) = x^2 - a, where x is the solution (the sought square root) and where a is the number for which you want to find the square root?I would have implemented either Taylor or MacLaurin series, centered at an integer number that is closest to the number that you want to find the square root for, such that the square root of this integer is clean. So if you wanted to find the square root of 8.5, I would centre the series at 9 (sqrt(9) = 3), then compute the series at that point. I'd probably choose between 8 and 10 terms, as that is what is used in any scientific calculator.Afficher plus de réponsesActually, to add to that, I wouldn't be able to include 8 - 10 terms, as that would rely on the square root operation itself.... so I'd have to rely on a linear approximation.This is the way to go. Fast inverse square root as used in Quake III. float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the fuck? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }For detailed explanation of the algorithm, see http://en.wikipedia.org/wiki/Fast_inverse_square_rootI wouldn't know about this algorithm, but I can think of a (definitely slower than this one) bisection algorithm to find the root of x^2 = number.Often what they are looking for is a programming data structures oriented solution. Such as using binary search to find sq root etc.poop

12 sept. 2012

### Cette question a été posée à un(e) Intermediate Software Developer chez The PEER Group :

19 mars 2009
 Your on a farm, and your in a field with horses and you have a fence that you have to repair. But you left your hammer back at the house, what do you do? Remember the fence is broken and you cannot leave it alone otherwise the horses will escape.7 réponsesRide one horse back to the house to get your hammer and use rope to temporarily secure the fence. or Tie one horse to the fence and go back to the house and get your hammer.Take a belt, if you have one, and tie the fence until you go home for the hammer.Why do you need a hammer to fix the fence? Maybe that assumption needs to be questioned. How is this for an assumption? Since its a farm, chances are the fence is made up of 5-6 ft. long wood pieces; which can be maneuvered into poles by hand. So, I would fix the fence and be on my way.Afficher plus de réponsesGrab a rock and use it as a hammer. IMO a hammer is the easiest tool possible to replace.If there's absolutely no way to repair the fence without the hammer (can't use your shoe), and you have no assistant, bring the horse(s) with you to the house. Or send them into the barn -- pretty much all horses have a shelter for inclement weather, after all. Or scare all the horses to the far end of the pasture, then tie your shirt to the broken fence piece so it waves in the wind and spooks the horses away. Then go get the hammer. But frankly, if the fence is broken, how come the horses didn't escape before you got there to notice it was busted?Why assume the horses will want to leave? Horses are herd animals. Secure the stallion or lead mare, the rest will stay with them. How did it get broken while the horses were there, anyway? Are any of them injured? Do you have a bigger problem than some loose rails? Who left the horses in a pasture with a broken fence? If it was you, how will you CYA? If it was a coworker, how will you handle it? If it was the farmer's pretty daughter... nevermind.Or maybe just call someone to send over the hammer because the question does not say that I do not have a phone.

### Cette question a été posée à un(e) Senior Software Engineer chez Amazon :

16 août 2012
 Write a function that divides one number by another, without using the division operator, and make it better than O(n).7 réponsesThis can be done in a recursive function, the following code is in Python. # get result of a/b without using a "divide" operator def div(a,b): if a < b: return 0 else: return div(a-b, b)+1 This is how human being do the division naturally, however, the running time of this is O(n/m), where n is the size of a, and m is the size of b, which means, O(n/m) is guaranteed to be less than O(n), when m is larger than 1. -MaximThe answer above is still O(n). We can use binary search and find the answer in the interval [1,a] and use multiplication operator.Totally agree with Vasil. Other option: Long Division Algorithm. O(log n) anyway.Afficher plus de réponseswhy not just a * b^(-1) :-)// Write a function that divides one number by another, without using the division operator, // Assume that x%y = 0 // O(log n) (function() { 'use strict'; var divide = function(x, y) { var xLength = (x + '').length; var i = 0; var result = 0; var xAry = ('' + x).split(); var xStart = ''; for (i = 1; i = y) { xStart -= y; result = parseInt(result, 10) + 1; } } } return result; }; console.log(divide(1000, 4)); })();Use logarithms? O(1) log(x/y) = log(x) - log(y) = log(answer) answer = 10 ^ log(answer)Convert the number to divide into the base of the number that you are dividing with and then shift the 'bits' to the right by 1 then convert back to decimal

19 déc. 2013

### Cette question a été posée à un(e) Software Engineer chez Morgan Stanley :

28 févr. 2012
 A few questions on basic command-line syntax in Unix shells: 1. How would you log output and error messages from a command to a file? 2. How would you run the same command on every file in a directory? 3. How would you find the PID of a named process (say if you wanted to kill it)?6 réponses1. command >file 2>&1 2. cd dir; for i in *; do command; done 3. ps | grep processname or ps -C processname#3 I disagree, more like ps aux |awk '\$0 ~ /ProcessName/ && \$0 !~ /awk/ {print \$2}' If you want the PID#3 To find the PID: pgrep -xAfficher plus de réponses#3 - to find the PID Or simply use: pidofOpps!! there is typo; it should be: pidof1. ./sample.sh &> output.txt :- to capture output and error message suppose sample.sh have below script: #!/bin/bash cat file1 cp file2 file3 lets assume there's no file2 exists in the current directory, returns an error message 2. from any current directory run the below line by line. for i in `find -maxdepth 1 -type f` do cat \$i >> output.txt done in for loop i stores all the files (type f means normal file type) in a current directory (maxdepth 1), suppose you want to consider all subdirectory files remove this part. then redirecting all the files to output.txt 3. ps -ef | grep -i "*process name* ps displays running processes, -e utility here displays all the processing shell processes without ignoring any process, f gives the full text/all info of processes. if you are not sure on the exact process name give * as above by giving part of the process name that you can remember

27 janv. 2014

### Cette question a été posée à un(e) Software Engineer chez Zenefits :

21 mars 2015
 Given a Binary Search Tree with integers at every node and an integer k, write code that decides whether or not there exists two nodes a and b such that a+b=k6 réponsesSomething like this? (Untested) private class Node { public boolean ContainsSum(int k) { return ContainsSum_(k, new ArrayList()); } protected boolean ContainsSum_(int k, ArrayList vals) { for (int i : vals) { if (i + m_val == k) return true; } vals.add(m_val); return (m_right != null && m_right.ContainsSum_(k, vals)) || (m_left != null && m_left.ContainsSum_(k, vals)); } private int m_val; private Node m_left; private Node m_right; }can you please list some more questionsPretty good solution listed aboveAfficher plus de réponsesThe solution mentioned above is O(n^2), because for every node, it is comparing value with all the nodes in Vals array. We can do better than this because we have BST, which is in sorted order. (For unsorted Binary tree, we should have sorted first in O(nlogn) and then searched O(nlogn). O(nlogn) solution - Traverse the BST with DFS (O(n)). For each node of value 'a' search for node of value "b = k - a". Searching in BST would be O(logn). Thus the solution becomes O(nlogn)HashMap tracker = new HashMap(); public SumPair parseTree(Node node, int sum) { if (node == null) { return null; } SumPair pair = parseTree(node.left, sum); if (pair == null) { pair = parseTree(node.right, sum); } if (pair == null) { if (tracker.containsKey(node.data)) { pair = new SumPair(node, tracker.get(node.data)); } else { tracker.put(sum - node.data, node); } } return pair; }With a node reference to left,right and parent, it can be done in O(n) Start at deep left with 2 node references at lowest node, value L. move one reference in DFS way until it find a node R >= K-L. if equal then we have a L and R then move the first reference to the next value in DFS, until node L > K-R repeat until last node is reached and L + R > K lot of micro-optimization possible (skip a whole node by going direct to parent when the parent is still lower than what we looking for)

### Cette question a été posée à un(e) Front End Developer chez IBM :

10 avr. 2019
 1. To add an HTTP request to the search engine, then log a result depending on the# of pages and requirements. 2. Use DP to implement a Knapsack-like problem. Restrictions on time complexity. 3. Implement a to-do list's delete method on website.5 réponsesDid u get rejected or just not receive an offer yet?To X: Get rejectedDid they request to do a background screening on you before rejecting?Afficher plus de réponsesNoThanks for replying, it seems they requested to do a background check on me currently

### Cette question a été posée à un(e) Software Developer chez The Stars Group :

13 juin 2014
 Very very hard, they ask you to do a poker project for 8 hours and give no feedback after and ask you to leave5 réponsesWell...I did the project and got onsite 1 day later. Got offer right after the onsite.....it got to be your code really really not good.....80k salary +20k bonusBtw I declined the 100k offerSo it's not 100k + 20k bonus :) Well, to go for full day interview several times they have to attract you with something. I bet you feel great... It's definitely cheating... Honestly, I wouldn't waste my time with such interviews even if they promise you 150K + bonus. It's unprofessional :)Afficher plus de réponsesI got the job and love it. Again,maybe you did not do as well as you thought.Code test was really fun. I enjoyed it, as it makes you think hard. The interview was real grilling. I managed to answer half of the questions. Got the job. Now I am the one grilling people on interviews. If you are weak - go work for a bank or something.
110 de 9,296 Questions d'entretien d'embauche