Software Engineer / Developer Interview Questions
- 2of 2 votes
AnswersGenerate MAX_INT (Max signed int value) using bitwise operators. Should work in 32 and 64 bit processors
- bartcois January 28, 2014 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Bit Manipulation - 2of 2 votes
AnswersThe stepping number:
- Anon October 13, 2014 in United States
A number is called as a stepping number if the adjacent digits are having a difference of 1. For eg. 8,343,545 are stepping numbers. While 890, 098 are not. The difference between a ‘9’ and ‘0’ should not be considered as 1.
Given start number(s) and an end number(e) your function should list out all the stepping numbers in the range including both the numbers s & e.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Algorithm Data Structures Dynamic Programming Java Online Test - 2of 2 votes
Answers// cat, actor -> T // car, actor -> F bool anaStrStr (string needle, string haystack) { }
Write a function that takes 2 strings , search returns true if any anagram of string1(needle) is present in string2(haystack)
- juny February 19, 2014 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
Answerswe have given a char array like “a1b2c3″ we have to convert this array to array like this “abbccc” .This has to be done in place as we have given that array has just enough space to hold the expanded array.
- nishu9101 February 20, 2013 in India
example:
1)input: a1b1c1
output:abc
length of array will be shortened.
2)input: a2b2c2
output:aabbcc
length of array will be equal to given array.
3)input: a3b4
output:aaabbbb
length of array will be greater than given array.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
Answersyou have given 2n+1 numbers in which 2n numbers are repeated means every number is having duplicate value.find that non repeating number in constant space and o(n) time.i told him using XOR.
- time February 03, 2012 in India
then he gave me 2n+2 numbers in which 2n numbers are repeating like above now you have 2 different number.find both number in constant space and o(n) time.(f2f 4th round)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven an array of values, design and code an algorithm that returns whether there are two duplicates within k indices of each other? k indices and within plus or minus l (value) of each other? Do all, even the latter, in O(n) running time and O(k) space.
- fbrubacher May 19, 2013 in United States for Engineer| Report Duplicate | Flag | PURGE
Palantir Technology Software Engineer / Developer Algorithm - 2of 2 votes
AnswersU have a number, don't know how long it is, do not know how many digits, don't know when number ends, do not know which is the last number. There is a function to increment the number by 1, but function can take only stream of digits and not the complete number e.g if you have 878999 as a number, you could input this number into the function only as single digit e.g 8,7,8,9,9,9. The output should be the whole number incremented by 1 i.e 879000, remember only single digits you can send to function as input. You can use any data structure, but need to tell why you are using that particular data structure. No need to worry about Time complexity.
- algoram November 29, 2012 in United States for Site Reliability Engineering Team
Kindly, suggest how to approach this problem ?| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersImplement a queue in which push_rear(), pop_front() and get_min() are all constant time operations.
- abhishek January 01, 2011| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersSink Zero in Binary Tree. Swap zero value of a node with non-zero value of one of its descendants
- yuanbing January 18, 2014 in United States
so that no node with value zero could be parent of node with non-zero.| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 2of 2 votes
AnswersGiven nxn boolean matrix (0's and 1's) .
- thebiker925 September 11, 2013 in United States
Find out whether there exist a row i and column j such that
1) all elemets of row i are zero's and
2) all elements of column j are 1's and
3)(i,j)th entry of the matrix can be either 0 or 1
Find out such a i and j exist or not .
complexity :O(n)| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
Answers1.Substring Addition
- Stephie February 19, 2013 in United States
Write a program to add the substring
eg :say you have a list {1 7 6 3 5 8 9 } and user is entering a sum 16.Output should display (2-4) that is {7 6 3} cause 7+6+3=16.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer - 2of 2 votes
AnswersGiven a set of numbers [1-N] . Find the number of subsets such that the sum of numbers in the subset is a prime number.
- Anonymous November 21, 2011 in India| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 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 - 2of 2 votes
AnswersAssume I have a log file with list of people with their arrival and departure time at an event that happened in the past.
- Bevan March 02, 2013 in United States
My task is to find out the maximum number of people present at any time during the entire event? I am not given query time.
ai = Arrival time of person i
di = Departure time of person i
I have a list of pairs like (a1,d1), (a2,d2), (a3,d3).... (an,dn)... It's not in a database.
I apologize as I cannot edit my previous question. I think it had a incomplete description.
Please let me know if you guys still need clarification. Thanks| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 2of 2 votes
Answerssort an array of 0's and 1's in a most efficient way.
- mahi December 23, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Arrays - 2of 2 votes
AnswersGiven predicted stock prices for next n days for a stock e.g : 10, 30, 42, 15, 20, 50, 10, 25 find the maximum profit that can be made with a single buy-sell transaction. If no profit can be made return 0. In the example buying at 15 and selling at 50 gives maximum profit. Note that the two prices are neither minimum nor maximum in the array.
- Kiara October 27, 2015 in United States| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer - 2of 2 votes
AnswersTech Screening
- sonesh July 02, 2015 in United States
Question 1 : You will be given a stream of integers, and a integer k for window size, you will only receive the streams integers one by one. whenever you receive an integer, you have to return the maximum number among last k integers inclusive of current entry.
Interviewer was expecting O(N) solution for N asks.
Edits: Interviewer was expecting O(N) Time + O(1) avg case space complexity solution for N asks.
and integers are not given in a array, every time only one integer will be passed as input to your method.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm Arrays Data Structures - 2of 2 votes
Answershow to implement a queue using one integer. this should store value 0 to 9. example suppose queue has first value 2 then insert 4 then 6 so it should look like 246. first value should be popped as 2. then it should be 46. program should support 0 in all the levels also. example queue should handle like 01235 also, 0 as first value in queue. remember 0 just to use integer, nothing else as data storage.
- Justin January 13, 2010| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
Answers/**
- duskan February 22, 2014 in United States
* Returns a^b, as the standard mathematical exponentiation function
*/
public double pow(double a, int b) {}
Interviewer looking for log(n) solution, right on first attempt.| Report Duplicate | Flag | PURGE
Linkedin Software Engineer / Developer Algorithm - 2of 2 votes
Answersgiven y bytes and you can transfer only x bytes at once..give a mathematical expression having only + - / * which gives the number of iterations to copy y bytes. ( dont try giving modulo operator answers )
- rahulbmv October 25, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Algorithm - 2of 2 votes
AnswersCode a function that receives an array with duplicates and returns a new array keeping the original order of the elements but with the duplicates removed.
For example, if the input were@[ @"dog", @"cat", @"dog", @"fish" ]
the output would be
@[ @"dog", @"cat", @"fish" ]
Tell the complexity of the solution.
- diegum June 06, 2014 in United States for iOS| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Arrays - 2of 2 votes
AnswersWrite a function that takes a string and returns true if the entire string is a palindrome, otherwise return false. The function should be case-insensitive and ignore any whitespace or punctuation.
- Barry Fruitman March 20, 2013 in United States
For example, return true for:
"A man, a plan, a canal: Panama."| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven number N, Find the least number of perfect square number sum needed to get N.
- itsvks February 01, 2017 in Netherlands
Example :
n=5 (4+1) i.e. 2
n=7 (4+1+1+1) i.e. 4
n=12 (4+4+4) i.e 3
n=20 (16+4) i.e. 2| Report Duplicate | Flag | PURGE
Booking.com Software Engineer / Developer Algorithm - 2of 2 votes
AnswersWrite a Java code that take a string of parenthesis as input and return if the string is valid or not . The input will have '(' and ')' and also '*' and * serves as wild card and can be used in place of both '(' and ')' or it can be null.
- ryanray1512 October 16, 2017 in United States
For example,the String (*)(*)(** is a valid String.
Follow up: What if '[]' and '{}' are also in the string along with '()' and * can be used in place of any of them or can be considered as null?| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 2of 2 votes
AnswersYou are given an array, divide it into 2 equal halves such that the sum of those 2 halves are equal. (Imagine that such division is possible for the input array and array size is even)
- gulusworld1989 January 13, 2014 in United States for Android| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven a monotonically sorted 2D array, explain an algorithm to search for a given input element.
- maytas92@yahoo.com February 11, 2013 in United States
A monotonically sorted array is one in which each row and column has elements in ascending order.
E.g. [ 1 2 10; 4 6 11; 5 7 12;] and [1 2 5; 4 6 7; 10 12 13] are both monotonically sorted.| Report Duplicate | Flag | PURGE
IBM Software Engineer / Developer Algorithm - 2of 2 votes
Answersthere are numbers in between 0-9999999999 (10-digits) which are assigened someone (does not matter which number assigned who)
- srcnaks February 02, 2015 in -
Write two methods called "getNumber" and "requestNumber" as follows
Number getNumber();
boolean requestNumber(Number number);
getNumber method should find out a number that did not assigened than marks it as assiged and return that number.
requestNumber method checks the number is assigened or not. If it is assigened returns false, else marks it as assiged and return true.
design a data sturucture to keep those numbers and implement those methods| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Data Structures Hash Table - 2of 2 votes
AnswersGiven a function, take a number and the bit position and return true if that bit is set to 1 and false otherwise.
- An April 04, 2012 in United States
It took me a few minutes to think something like this, pasted code is after he corrected me on 2 silly mistakes.
bool ret_result(int number, int pos) {
int k=1;
for(int i=0;i<pos;i++) {
k=k<<1;
}
if(number&k==1) {
return true;
}
else {
return false;
}
}| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Bit Manipulation - 2of 2 votes
AnswersWrite a function which gives the length of the largest palindrome found within a string.
- grekogecko October 01, 2014 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Algorithm - 2of 2 votes
AnswersGiven two string S1 and S2. S1 contains from A-Z and S2 contains A-Z, * and ?
- darklight December 28, 2012 in India
Where * means any character 0 or any number of times
Where ? means any character 0 or 1 number of times
Write a program to determine whether S2 matches S1| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm