Engineering Interview Questions in Chicago, IL | Glassdoor

# Engineering Interview Questions in Chicago, IL

2,295

Engineering interview questions shared by candidates

## Top Interview Questions

Sort: RelevancePopular Date

### Applications Security Engineer at Bank of America was asked...

Oct 16, 2014
 I was asked about XSS, SQL Injection, Tools I have used for pen testing. 1 AnswerCross-site scripting (XSS) is a type of computer security vulnerability typically found in Web applications. XSS enables attackers to inject client-side script into Web pages viewed by other users. A cross-site scripting vulnerability may be used by attackers to bypass access controls such as the same origin policy. - SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).

### Software Engineer II at Orbitz Worldwide was asked...

Dec 11, 2010
 How can you solve n^m efficiently only using +, -, *, /.4 AnswersThis is one solution that doesn't deal with negative exponents exp(n, m) { if (m == 0) return 1 if (m == 1) return n exp = exp(n, m / 2) if ( isOdd(m) ) exp = exp * n return exp }int f(int n, int m) { if(m==0) return 1; if(m==1) return n; n=n*f(n,(m-1)); return n; }There is no need to solve it recursively. it is pretty simple int calculateExp(int n, int m) { exp = n for (i = 1; i <= m; i++) { exp = exp*n } return exp; }Show More ResponsesDisadvantage of recursion is the large amount of space on the stack for a large m in this case.

Dec 5, 2012
 "Reverse" of the problem if finding k-th smallest element in a tree: I had to find k-th largest.4 AnswersKeep a global or reference counter increase it every time you encounter a tree node. Return when the counter == k.do an in-order traversal which gives you a sorted list. the rest is obvious.do an in-order traversal which gives you a sorted list. the rest is obvious.Show More ResponsesThe tree data structure is red herring, it does not help in any way to find the kth element The solution to this problem is called partial sorting and can achieve O(n) - number of nodes time complexity

Oct 25, 2011
 If you have a ransom letter and magazines, can you construct the ransom letter from the words in the magazine.3 AnswersYou can create a binary search tree like red black with all the words in the magazine. this will take o(n) (o(1) amortized * n words). now we need to search k times the magazine so in total O(n) +O(klogn) Another option is to hash with chaining (linked lists)all the words in the magazine, this will take o(1) for each insert and then lookup will take o(1) amortized as well (but w.c o(n) fir every word) so total o(n) and w.c O(k*n) if we will use hash wit open addressing that means we will not have multiple values in the same cell. if we'll define tha size of the hash as m then our load factor is n/m the bigger m the less time for insert and lookup, an in the total o(n * (1/(1-n/m))).Find out the character set of the letter. If the character set is ASCII then create an integer array of size 256 and use characters as index/ 1. Scan through the ransom letter and increment the count of occurrences for each character at that index. 2. Then pick up each magazine and scan through the magazine, here at each character decrement the character count in the array created above. 3. Scan through the count array and when it reaches zero. return true or else false.1) Create a trie by reading the words from the magazines. If size is an issue, use DAWG 2) Search if every word exists in the trie. If not, return false. Otherwise return true.

### Software Engineer at PEAK6 Investments was asked...

May 15, 2011
 Find the height of a binary tree3 AnswersClass Node { int data; Node left; Node right; } public static int heightOfTree(Node node) { if(node!=null) { return (heightOfTree(node.left)+1+heightOfTree(node.right)); } }The above post gives too big of an answer except in trees that are technically Linked Lists. Replace the return line with the following to *actually* get the height of a tree: return 1 + max(heightOfTree(node.left), heightOfTree(node.right)); Also, the above function could possibly terminate without returning anything. Add an else condition that returns 0 as the base case./** Returns the max root-to-leaf depth of the tree. Uses a recursive helper that recurs down to find the max depth. */ public int maxDepth() { return(maxDepth(root)); } private int maxDepth(Node node) { if (node==null) { return(0); } else { int lDepth = maxDepth(node.left); int rDepth = maxDepth(node.right); // use the larger + 1 return(Math.max(lDepth, rDepth) + 1); } }

### Software Engineer Internship at Orbitz Worldwide was asked...

Mar 18, 2011
 What is the angle between hour hand and minute hand at 3.15?2 AnswersLets deal with the hour hand first. In 60 minutes (1 hour) the hand travels 5 minutes on the clock face, so in 1 minute it travels 0.0833 minutes on the clock face (5/60). At 3'0clock the hour hand was exactly at 3. After 15 minutes it has moved 0.0833*15 = 1.25 minutes on the clock face. At 3.15 the minute hand is exactly at 3, so the difference between the hour and minute hand is 1.25 minutes. So now we just convert 1.25 minutes into degrees to get the angle between the two hands. We do that with the following logic - in 60 minutes the minute hand turns 360 degrees, so in 1 minute the hand turns 360/60 = 6 degrees, so in 1.25 minutes the hand turns 6*1.25 = 7.5 degrees. This is the angle between the two hands at 3.15http://en.wikipedia.org/wiki/Clock_angle_problem

### Software Engineer/Consultant at Slalom was asked...

Dec 11, 2012
 Given an array of numbers, print out Fiz if the number is divisible by 3, Buzz if divisible by 5 and FizzBuzz if divisible by both. Print the number if it is not divisible by either.2 Answerspublic static void fizzBuzz(int number) { if(number % 3 != 0 && number % 5 != 0) { System.out.print(number); } else { if(number % 3 == 0) { System.out.print("Fizz"); } if(number % 5 == 0) { System.out.print("Buzz"); } } System.out.println(); }Try this. public static void FizzBuzz(int[] array) { String output; for ( int x : array ) { output = ""; if ( x % 3 == 0 ) output = "Fizz"; if ( x % 5 == 0 ) output += "Buzz"; System.out.println(( output.length() > 0 ) ? output : x); } }

Sep 14, 2014
 How would you copy a custom object like a "Node" from a search tree in Objective C?3 AnswersThis question tests your depth in the use of NSObject. You cannot call copy on an NSObject directly, so your object must implement the NSCopying protocol if you would like a copy. In order to conform to the NSCopying protocol, your object must respond to the selector "copyWithZone:". In that method you must copy any NSObject instance variables, as well as primitive data types from your object. Example: @interface Node : NSObject - (id)copyWithZone:(NSZone *)zone { id copy = [[[self class] alloc] init]; if (copy) { [copy setRootNode:[[self.rootNode copyWithZone:zone]]; [copy setLeftNode:[[self.leftNode copyWithZone:zone]]; [copy setRightNode:[[self.rightNode copyWithZone:zone]]; } return copy; } Now you can do something like: Node *newNode = [myNode copyWithZone:zone]; Reference: http://bit.ly/copyingNSObjectstestI'd discuss tradeoffs of deep copying (suggested by interview candidate above) versus a regular copy: - (id)copyWithZone:(NSZone *)zone { Node *copy = [[[self class] allocWithZone:zone] init]; if (!copy) { return nil; } copy.parent = self.parent; copy.left = self.left; copy.right = self.right; return copy; } This approach is more flexible if I want to create a second instance pointing to the same nodes. Additionally, all pointers can be copied on demand. A proper solution, covering existence of both mutable and immutable counterparts, is here: https://gist.github.com/zats/c075815e1fa24b001fb2