Software development engineer Interview Questions in Boston, MA | Glassdoor

Software development engineer Interview Questions in Boston, MA

123

software development engineer interview questions shared by candidates

Top Interview Questions

Sort: RelevancePopular Date

Software Development Engineer at Amazon was asked...

Jan 29, 2012
 Given a binary tree with the usual left and right pointers on each node, and additionally a parent pointer, make an algorithm to discover the closest ancestor to 2 nodes on the tree.7 AnswersTime complexity is : O(max height of binary tree) public void findCommonAncestor(Node current,int a,int b){ if(current.getKey() a && current.getKey()>b){ findCommonAncestor(current.getLeft(), a, b); }else{ System.out.println(" least common ancestor is "+current.getKey()); } }analog76, your solution is not complete.@clusterfudge, what do you mean by incomplete? Can you be more precise?. Common ancestor - first encounter of node value between a and b. Otherwise either you go left or right node.Show More ResponsesAs far as I concern it is a binary tree not binary SEARCH tree.thanks @naipton. 1) Find matching node for the first value in the tree. If the node found create a set contains all its parents till the root. 2) Use postorder traversal for recording all the ancestor. 3) P1 is parent, P2 is grand parent and P3 is ggparent and continue till root. V1={P1,P2,P3,P4,....root} 4) Similary find all the parent of second value V2={P1,P2,P3,.root}. 5) traverse both set and first matching element in both sets is lowest common ancestor.Find height of node 1 as h1 and height of node 2 as h2 by travelling to the root. Time O(2 lg N). If h1 > h2, then move node1 by h1 - h2 and vice versa. THen, use two pointers to move one parent at a time until parent nodes are same. Complexity - O( 3 lg N)Assuming each node has a unique ID (its memory address, for example), you can solve this in O( 2 lg N ) where N is the number of nodes in the tree. findCommonAncestor(Node x, Node y): 1. Initialize a hashmap, call it `parentsMap`. 2. Starting from x, visit all its parents up to and including the tree root, and for each parent `p`, set parentsMap[p.id] = true 3. Starting from y, begin to visit its parents and for each parent `p`, check parentsMap[p.id]. If true, return p.id. Else, continue visiting parents until `p` is null, at which point we return null.

Software Development Engineer (Computer Vision) at Amazon was asked...

Nov 22, 2012
 How would you code up a custom rectangle detector?5 AnswersI suggested something about matching intersecting hough lines.Hi... Could you plz explain what is a custom rectangle detector...I hav my interview with Amazon on monday ... plz helpBy a custom rectangle detector I mean how would you write your own function to detect rectangles. Your input would be the pixel data and your outputs would be something like the x,y locations of the rectangles.Show More ResponsesFirst of all, hough transformation can be used. just parametrize the representation for rectangle, but the parameter space is 4D. Second, line detection, followed by checking corner degree. In practice, I would use opencv's coutour fitting function to fit for quadrilateral, then check the angle. This works quite well.I would scan the image with a basic edge detection mask. Then I would scan to count the number of lines, keeping track of end points in pairs. Cases such as curves would also be found in this step and returned as not a rectangle. An analysis of basic trig with the points could then be performed in order to determine if the points form a rectangle. Once a rectangle is confirmed then you could use those points to display on the image the recognized rectangle. Or do whatever the reason for finding the rectangle was.

Software Development Engineer at Amazon was asked...

Jan 29, 2012
 Given the word "HEAD" and the word "TAIL," write code and/or describe using computer science algorithms how you would transform from the word HEAD to the word TAIL. Each change must be by only one letter, you cannot change the letter in a given position twice, and each new word must be a valid word.3 Answershttp://stackoverflow.com/questions/2205540/algorithm-to-transform-one-word-to-another-through-valid-wordsCool - Construct a graph. Each node has a word of four letters. Adjacent nodes are all words with one letter different from this node. So, HEAD node has neighbors, READ, BEAD, DEAD, etc. DEAD's neighbors are DEED, DEAN, etc. Once the graph is constructed, problem is one of computing path from HEAD to tail.//use a hash set for a fast check if a word is already in the dictionary static HashSet Dictionary = new HashSet(); //dictionary used to find the parent in every node in the graph and to avoid traversing an already traversed node static Dictionary parents = new Dictionary(); public static List FindPath(List input, string start, string end) { char[] allcharacters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; foreach (string s in input) Dictionary.Add(s); List currentFrontier = new List(); List nextFrontier = new List(); currentFrontier.Add(start); while (currentFrontier.Count > 0) { foreach (string s in currentFrontier) { for (int i = 0; i ExtractPath(string start,string end) { List path = new List(); string current = end; path.Add(end); while (current != start) { current = parents[current]; path.Add(current); } path.Reverse(); return path; }

Software Development Engineer at Microsoft was asked...

Mar 6, 2014
 A disc is spinning on a spindle - you don't know which way. You are given a set of pins - describe how you would use them to determine which way the disc is spinning.4 AnswersDrop the pin on the disc, the disc is spinning in the direction the pin fly's out.Yes drop the pin onto the disc n see where the pin move..Drop pin by non sharp side and see how it moves.Show More ResponsesHold a pin with it sharp end just touching the disc (assuming it is inside a box and there is only one opening). You will be able to feel the direction of motion of the disc.

Software Development Engineer Intern at Amazon was asked...

Apr 1, 2014
 write a function that takes in an int and returns a string that would be how one would say that number (ex: 123 -> one hundred twenty three; 50019 -> five thousand nineteen).3 Answersimport java.util.Scanner; import java.util.HashMap; /** * * @author Chepa */ public class prog2 { static HashMap h1 = new HashMap(); static HashMap h2 = new HashMap(); public static void main(String[] args){ Scanner s = new Scanner(System.in); System.out.println("Enter number "); int n = s.nextInt(); h1.put(1, "One"); h1.put(2, "Two"); h1.put(3, "Three"); h1.put(4, "Four"); h1.put(5, "Five"); h1.put(6, "Six"); h1.put(7, "Seven"); h1.put(8, "Eight"); h1.put(9, "Nine"); h1.put(10, "Ten"); h1.put(11, "Eleven"); h1.put(12, "Twelve"); h1.put(13, "Thirteen"); h1.put(14, "Fourteen"); h1.put(15, "Fifteen"); h1.put(16, "Sixteen"); h1.put(17, "Seventeen"); h1.put(18, "Eighteen"); h1.put(19, "Nineteen"); h2.put(2, "Twenty"); h2.put(3, "Thirty"); h2.put(4, "Fourty"); h2.put(5, "Fifty"); h2.put(6, "Sixty"); h2.put(7, "Seventy"); h2.put(8, "Eighty"); h2.put(9, "Ninety"); String output = getStringRepresentation(n); System.out.println("Output: " + output); } public static String getStringRepresentation(int n){ StringBuilder sb = new StringBuilder(); String temp; int x = n / 1000000; if(x > 0){ temp = getStringFor3Digits(x); sb.append(temp).append(" Million"); } n = n % 1000000; x = n / 1000; if (x > 0){ System.out.println("For thousand x = " + x); temp = getStringFor3Digits(x); sb.append(" ").append(temp).append(" Thousand"); } n = n % 1000; if(n > 0){ temp = getStringFor3Digits(n); sb.append(" ").append(temp); } return sb.toString(); } public static String getStringFor3Digits(int n){ StringBuilder sb = new StringBuilder(); int x = n / 100; if(x > 0){ System.out.println("In hundred x = " + x + " " + h1.get(x)); sb.append(h1.get(x)).append(" Hundred"); } n = n % 100; if (n 0){ sb.append(" ").append(h2.get(x)); } n = n % 10; if(n > 0) sb.append(" ").append(h1.get(n)); } return sb.toString(); } }def numberReader(x): words = "" numbers = { 0: "", 1: "One ", 2: "Two ", 3: "Three ", 4: "Four ", 5: "Five ", 6: "Six ", 7: "Seven ", 8: "Eight ", 9: "Nine ", 10: "Ten ", 11: "Eleven ", 12: "Twelve ", 13: "Thirteen ", 14: "Fourteen ", 15: "Fifteen ", 16: "Sixteen ", 17: "Seventeen ", 18: "Eighteen ", 19: "Nineteen ", 20: "Twenty ", 30: "Thirty ", 40: "Forty ", 50: "Fifty ", 60: "Sixty ", 70: "Seventy ", 80: "Eighty ", 90: "Ninty " } ln = len(str(x)) strx = str(x) if x 20 and x = 4 and ln 6 and ln 9 and ln <= 12: words += numberReader(int(strx[:ln-9])) + "Billion " + numberReader(int(strx[-9:])) return words.capitalize()I think you didn't take in consideration the fact that an int can be a negative number. For example in python sript len(str(abs(x))) would give you the result you wanted. Cause minus would give higher length.

Software Development Engineer at Microsoft was asked...

Aug 13, 2013
 Given a sentence input : helloworld output: HelloWorld YOu should make use of a dictionary available with you. Capitalize the dictionary words in the sentence4 Answerspublic String capitalizeFirstChar(String str) { String s = " "; String[] newString = str.split(" "); for(int i = 0; i < newString.length; i++) { String ssttrr = newString[i]; String firstChar = ssttrr.substring(0, 1).toUpperCase(); s = s + firstChar + ssttrr.substring(1)+" "; } return s; } Test: Input: hello afful how are you doing today? Output: Hello Afful How Are You Doing Today? I welcome any improvements..if any. Let keep learningwhere are you using Dictionary?I don't think Afful is right, the question doesn't include the space at all, so you cannot assume there are spaces and use the split function. Since you have the dictionary, I think the point is to find the head node in the dictionary and capitalize it.Show More Responses One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

Mar 28, 2017
 I was told a coding question. Q: Given a list of words for example : cat,bat,rat.... and given a query which has a special character '.' which can be represented as any alphabet between 'a-z'. Write a function which gives true as output if the the query is in the list of words. Example: List of words: cat,bat,rat,cct,cut Query 1: c.t Output 1 : true Query 2: c.. output 2 : true5 AnswersSeems like a pretty straight forward version of regex matching... This can be done in linear time IMO. 1. Loop through words array 1.a Get the word and compare it with the query... If '.' then continue 1.b If any character does not match, return else add it to the result list Complexity: O(mn) m being the # of characters in the query (or word) and n being the number of words... Is there any better/optimized way? This seems like a brute force...oh man, thats LC # 211Show More Responses One or more comments have been removed. Please see our Community Guidelines or Terms of Service for more information.

Senior Software Development Engineer In Test at Akamai was asked...

Nov 6, 2014
 Presented with scenarios, and ask to offer solutions. Mostly interested in your approach, not the solution.1 AnswerCould you throw light on some of the areas on which you were interviewed (on site)? What all prep should be done prior to the onsite interview? Thank you.

Quality Assurance Engineer, Software Development at Coventor was asked...

Apr 8, 2015
 Same as previous reviewers. Knew I wasn't going to get the job based on that.1 AnswerAnswered everything very well. Had a nice discussion and went overtime.

Software Development Engineer at Vertica was asked...

Oct 28, 2019
 To design a system in c++/java which reads data files and outputs some analytical questions. it was an offline coding round and the ask was to make it faster and scalable.1 Answerjust improved the for-loop logics and wrote in the doc that other optimizations like parallel, distributed arch, etc.
110 of 123 Interview Questions