Software Engineer / Developer Interview Questions
- 0of 0 votes
AnswersSort two sorted Linked Lists.
- amostech December 20, 2014 in United States
Write your own implementation of structs / classes you might need to use.
Try to come up with the best time and space complexity.
I ran out of time after merging the two lists in O(n) time and O(1) space, but I am guessing he wanted to expand the solution to implement a merge sort algorithm for an unsorted Linked List.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersAn efficient way to sort patient files in an array of just 3 types 'High-importance', 'Mid-importance', 'Low-importance' which are in an arbitrary order (unsorted).
- Ipalibo December 19, 2014 in United States
The output preference should start with the highest.
1. High-importance
2. Mid-importance
3. Low-importance
[high,low,low,med,high,low]
ps I was told to take advantage of the fact that they are just only 3 types.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Sorting - 2of 2 votes
Answersgiven a vector of integers, v[i] represent the stock price on day i. Now you may do at most K transactions. you must sell your stock before you buy it again and that means you can NOT have two stocks at the same time. write a program to find max profit you can get.
- rjrush December 17, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersA Matrix of 1s and 0s is given, all zeros are water and 1s are land, first find out the number of ponds in the array (Reverse of islands problem). If one change can convert 1s in to zero then find out minimum number of changes that we need to make so that there will be only one pond in matrix..
- manidam07 December 16, 2014 in India for ICE
Any algo how to make 1 pond ?| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer - 0of 0 votes
AnswersDescribe what’s incorrect about the following function and how you would fix the problems.typedef map< int, char *> List;void foo(){ List l; FILE *f = fopen("data.txt", "r"); if (f) { char line[100]; for (int i = 0; fgets(line, sizeof(line), f); ++i) { l[i] = new char[strlen(line)]; strcpy(l[i], line); } } for (List::const_iterator it = l.begin(); it != l.end(); ++it) { printf("%d: %s", it->first, it->second); }}
- prakashguy50 December 15, 2014 in India for SoftwareDevelopment| Report Duplicate | Flag | PURGE
ASAPInfosystemsPvtLtd Software Engineer / Developer Online Test - 0of 0 votes
AnswersThe function bar crashes when invoked. What is wrong and how would you fix the problem without changing anything in function bar?struct A { char *name; A() : name(NULL) { } ~A() { if (name) delete[] name; }};void bar(){ A x; x.name = new char[10]; strcpy(x.name, "John"); A y = x;}
- prakashguy50 December 15, 2014 in India for SoftwareDevelopment| Report Duplicate | Flag | PURGE
ASAPInfosystemsPvtLtd Software Engineer / Developer Online Test - 0of 0 votes
AnswersThe structure Info stores information of a person. Using a STL map, implement a collection of Info. The fields first and last must be used a unique, composite key. The list should be sorted by last, first in ascending order.typedef struct { string first, last; int age; string addr1, addr2;} Info;Also Using the map of Info from the question, output the list in reverse order. You may not define a new map or redefine the map you defined in the last question.
- prakashguy50 December 15, 2014 in India for SoftwareDevelopment| Report Duplicate | Flag | PURGE
ASAPInfosystemsPvtLtd Software Engineer / Developer Online Test - -1of 1 vote
AnswersThere is a list of rectangles and a list of points in a 2d space. Note that the edge of each rectangle are aligned to XY axis. question is how to find rectangles with point or points inside
- rjrush December 15, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 0of 0 votes
Answers//Given a method that takes in a positive non-zero number N, return from that method the total number of factors of N. //Start with O(n) solution and make it faster if we have time
- JSDUDE December 12, 2014 in United States| Report Duplicate | Flag | PURGE
F5 Networks Software Engineer / Developer Algorithm Math & Computation - 0of 2 votes
AnswersReverse last 5 nodes of linkedlist. Please let me know if there is any better way.
E.g.
Input: 1,2,3,4,5,6,7
Output: 1,2,7,6,5,4,3
- chirag272003 December 09, 2014 in United Statespackage com.acct; public class SinglyLinkedListReverseLast5 { public static void main(String[] args) { Node n7 = new Node(7, null); Node n6 = new Node(6, n7); Node n5 = new Node(5, n6); Node n4 = new Node(4, n5); Node n3 = new Node(3, n4); Node n2 = new Node(2, n3); Node n1 = new Node(1, n2); int numberOfNodestoReverse = 5; System.out.println(n1.toString()); reverse(getNthElement(n1, numberOfNodestoReverse+1)); System.out.println(n1.toString()); } public static Node getNthElement(Node head, int n) { Node f_ptr = head; Node s_ptr = head; for (; n > 0; n--) { f_ptr = f_ptr.next; } while (f_ptr != null) { f_ptr = f_ptr.next; s_ptr = s_ptr.next; } System.out.println(s_ptr.toString()); return s_ptr; } public static void reverse(Node head) { Node current = null; Node next; Node first = head; head = head.next; while (head != null) { next = head.next; head.next = current; current = head; head = next; } first.next = current; } } class Node { int value; Node next; Node(int value, Node next) { this.value = value; this.next = next; } public String toString() { String result = value + " "; if (next != null) { result += next.toString(); } return result; } }
| Report Duplicate | Flag | PURGE
Software Engineer / Developer Linked Lists - 1of 1 vote
AnswersSuppose that there is a database table, and four processes read the table at the same time. But, only one process is allowed to read the same row of the table at the same time. How do you enforce the exclusive-read on a row?
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Database - 1of 1 vote
AnswersWhat is Encapsulation? What is inheritance? When and Why should you use the inheritance?
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C++ - 0of 0 votes
AnswersWhat is the Abstract class? What is the difference between an abstract class and an interface? When should you use an abstract class instead of interface?
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C# - 0of 0 votes
AnswersSuppose that Amazon web site has two data tables: One is the customer table. The other is the order table. How do you find the customers who never order anything?
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer SQL - 1of 1 vote
Answersan bacteria grows at the speed that it will double its volume per minute. If you put it in a jar, it will fill the jar in one hour. how long will it take to fill a half of the jar?
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Brain Teasers - 1of 1 vote
AnswersA binary tree represent an organization hierarchy. The root node is the CEO and etc. design a algorithm to print the tree level by level.
- joeyk December 06, 2014 in United States for Supply Chain| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer Data Structures - 0of 0 votes
AnswersDescribe Class diagram of a Card Game like Poker. What classes to be used. How to deal and shuffle the cards in cards class
- Amazon December 05, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 3of 5 votes
AnswersGiven a set of busy time intervals of two people as in a calendar, find the free time intervals of both the people so as to arrange a new meeting
- Phoenix December 02, 2014 in United States
input: increasing sequence of pair of numbers
per1: (1,5) (10, 14) (19,20) (27,30)
per2: (3,5) (12,15) (18, 21) (23, 24)
ouput: (6,9) (16,17) (22,22) (25,26)| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 0of 0 votes
AnswersYou are given an array of non-negative integers (0, 1, 2 etc). The value in each element represents the number of hops you may take to the next destination. Write a function that determines when you start from the first element whether you will be able to reach the last element of the array.
- Anon80 December 02, 2014 in United States
if a value is 3, you can take either 0, 1, 2 or 3 hops.
For eg: for the array with elements 1, 2, 0, 1, 0, 1, any route you take from the first element, you will not be able to reach the last element.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 0of 0 votes
AnswersDesign Maps: You have set of [lat, long] for all famous locations. Given your position [lat, long] return all famous locations within r radius of your position.
- darklight November 27, 2014 in India| Report Duplicate | Flag | PURGE
Flipkart Software Engineer / Developer Data Structures - 1of 1 vote
AnswersGiven a number,print it in words.
- Pooja Karadgi November 26, 2014 in India
19621 -> One lakh ninety six thousand and twenty one.| Report Duplicate | Flag | PURGE
FactSet Research Systems, Inc Software Engineer / Developer C C++ - 2of 2 votes
AnswersGiven an array of type:-
- anupjunagadecat November 25, 2014 in India for 11
1. Increasing
2. Decreasing.
3. Increase-Decrease
4. Decrease-Increase
Find:- 1. Type of array in minimum steps ?
2. Maximum element from array in min steps?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 9of 9 votes
AnswersQuestion was "Given a pattern and a string input - find if the string follows the same pattern and return 0 or 1.
- David_Maxwell November 24, 2014 in United States
Examples:
1) Pattern : "abba", input: "redbluebluered" should return 1.
2) Pattern: "aaaa", input: "asdasdasdasd" should return 1.
3) Pattern: "aabb", input: "xyzabcxzyabc" should return 0.
I can think of a brute-force solution for this question where we add the character in the pattern and n length of the string to a hashmap and recurse over the pattern array and string. But is there anything more efficient? This was a pretty difficult question in my opinion.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersYou have 81 balls. 80 balls have the same weight. 1 ball is the lightest one. What would be the minimum possible way to find the lightest ball ?
- AlgoBaba November 23, 2014 in United States
(Use Dynamic Programming)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Dynamic Programming - 1of 1 vote
Answers
- Phoenix November 22, 2014 in United KingdomThere are multiple rooms in a floor. There are one or more fire exits. Each door can be designed with an option of pull or push. For fire safety, a door should be designed so as to open (push) towards the fire exit. Design a data structure to represent the floor and door design. A person could start from any room and moves towards fire exit. Write an algorithm to check if all the doors are designed to be pushed towards fire exit.
| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 1of 1 vote
AnswersThere is a string whose characters can only be either ‘a’, ‘b’ or ‘_’ (there can be only one ‘_’ in the string). At each step, we can modify the string as follows:
- Rahul Sharma November 21, 2014 in India
1. ‘_’ can be swapped with its adjacent character, example “a_ba” can be changed to either “_aba” or “ab_a”.
2. Two characters adjacent to ‘_’ (both on the same side of ‘_’) can be reversed along with the ‘_’ if both characters are different, example, “aa_ba” can be changed to “aaab_” but not to “_aaba” because both characters are ‘a’.
You are given two strings, the initial state and the final state (lengths will be same), you have to output the minimum number of steps required to change the string in initial state to the string in the final state.
example:
input: a_b ab_
output: 1
input: abaa_a b_aaaa
output: 4
reason for example 2:- abaa_a -> aba_aa -> ab_aaa -> _baaaa -> b_aaaa| Report Duplicate | Flag | PURGE
Directi Software Engineer / Developer Algorithm - 3of 3 votes
AnswersWrite a program to find pattern.
- pritishshah.it November 20, 2014 in United States
0: 1
1: 11
2: 21
3: 1211
4: 111221
5: 312211
Iterate over the previous number, and find count for same number number. Append that count before number.
e.g.,
public String pattern(int input){}
If input = 4, function should return 111221.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 4of 4 votes
AnswersGiven a string S, you are allowed to convert it to a palindrome by adding 0 or more characters in front of it.
- xyz_coder November 20, 2014 in United States
Find the length of the shortest palindrome that you can create from S by applying the above transformation.| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer - 3of 3 votes
AnswersLet's say there is a double square number X, which can be expressed as the sum of two perfect squares, for example, 10 is double square because 10 = 3^2 + 1^2
- baudday November 17, 2014 in United States for Emerging Markets
Determine the number of ways which it can be written as the sum of two squares| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm