Coding Interview Questions
- 1of 1 vote
AnswersWrite a function to shuffle a deck of 52 cards. Explain how you would test that the deck was properly shuffled
- SReddy November 02, 2009| Report Duplicate | Flag | PURGE
Siemens Software Engineer in Test Coding - 0of 0 votes
AnswersWrite a function to determine whether the binary representation of a specified 32-bit integer is a palindrome. For example, the 32-bit integer 0xFCA8153F is a palindrome, but 0xFCA88ACF is not. Show how you would test this function.
- SReddy November 02, 2009| Report Duplicate | Flag | PURGE
Siemens Software Engineer in Test Coding - 0of 0 votes
AnswersGiven an integer, print the closest number to it that is a palindrome - eg, the number "1224" would return "1221".
- naive October 30, 2009| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Coding - 0of 0 votes
AnswersFor a given integer number, reverse the digits of the number.
- pavan October 13, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
AnswersWrite a program which takes a integer number and adds all the digit in the number. It should return a single digit in the end.cc
- pavan October 13, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
AnswersWrite an program to add and subtract two numbers, the numbers can be of any length you can chose of language.
- Roy October 09, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer in Test Coding - 0of 0 votes
AnswerDifference between final, finally and finalize in Java
- BAustin September 27, 2009| Report Duplicate | Flag | PURGE
Bazaarvoice Software Engineer / Developer Coding - 0of 0 votes
AnswersYour program will take as an input 'n' coordinates of type {(X1,Y1,Z1), (X2,Y2,Z2), (X3,Y3,Z3),...(Xn,Yn,Zn)} and from these 'n' coordinates print a list of 's' coordinates (where 's' is another input parameter less than 'n') which are closest to the origin (0,0,0) and a list of 't' coordinates (where 't' is another input parameter less than 'n') points closest to each other. Your solution should use an optimal strategy and minimal time / space complexity
- pirateMaster September 23, 2009| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Coding - 0of 0 votes
AnswersEach cell of an N x N grid is either a 0 or a 1. You are given two such N x N grids, the initial grid and the final grid. There is a button against each row and each column of the initial N x N grid. Pressing a row-button toggles the values of all the cells in that row, and pressing a column-button toggles the values of all the cells in that column. You are required to find the minimum number of button presses required to transform the grid from the initial configuration to the final configuration, and the buttons that must be pressed in order to make this transformation.
- pirateMaster September 23, 2009| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Coding - 0of 0 votes
AnswersLocate the node which is the m-th node from the end of a linked list. e.g. linked list has 100 nodes and m=5, it would be node 95.
- kichi September 20, 2009| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Coding - 0of 0 votes
AnswersWriting a C code to find the endianness of a computer.
- kichi September 20, 2009| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Coding - 0of 0 votes
AnswersWrite a function to transpose a NxN matrix. Do it in-place. e.g. m={{1,2,3},{4,5,6},{7,8,9}} ==> m={1,4,7},{2,5,8}{3,6,9}}. Function prototype is like this "transpose(dimension, pointer to 2-d array)".
- kich September 20, 2009| Report Duplicate | Flag | PURGE
Qualcomm Software Engineer / Developer Coding - 0of 0 votes
Answersassembly code to count 1st n numbers.
- Anonymous July 31, 2009| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Coding - 0of 0 votes
AnswersHow do you implement a queue with stack data structure?
- Anonymous May 30, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding Data Structures - 0of 0 votes
AnswersWrite a program (psuedocode is fine) to implement file diff utility
- Roberto May 29, 2009| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Algorithm Coding - 0of 0 votes
AnswersWrite a function which performs some task e.g. of adding 2 no. and return sum to the main function. now there is nothing wrong with the function syntax wise but the program crashes after the execution of return statement.
- sun May 03, 2009| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer Coding - 0of 0 votes
AnswersConvert a binary search tree to a circular sorted linked list. The highest valued node should point to the lowest valued node at each step.
- prolificcoder April 27, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ Coding Data Structures Linked Lists - 0of 0 votes
AnswersTest a function that sorts a linked list. You have two pointers head which is the original unsorted list and head1 which is said to be the sorted linked list. Return true if head1 did the sorting correctly and return false if not.
bool testlinkedlistsort(Node *head,Node *head1)
I got the solution correct but messed it up while writing it over the white board :|
- prolificcoder April 27, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C++ Coding Data Structures Debugging Testing Linked Lists - 0of 0 votes
Answersto print
*
*
**
**
***
***
****
****
*****
*****
- janardhan singamaneni April 20, 2009#include<stdio.h> void main() { int n,j,k,l,i; printf("enter the number"); scanf("%d",&n); for (i = 1; i <= n; i++) { for (j = 1; j <= 2; j++) { for (l = n; l > i; l--) { printf(" "); } for (k = 1; k <= i; k++) { printf("*"); } printf("\n"); } } getch(); }
| Report Duplicate | Flag | PURGE
Yahoo Software Engineer / Developer Coding - 0of 0 votes
AnswersCompute the square root of a function
- Anonymous April 17, 2009| Report Duplicate | Flag | PURGE
Facebook Software Engineer / Developer Coding - 0of 0 votes
Answersint getNthNonZeroElement(vector<int> & elements, int n) {
- Han April 09, 2009
vector<int>::iterator i;
int count;
for (i = elements.begin(); i < elements.end(); i++) {
if ((*i) != 0) {
if (count == n) {
return (*i);
}
count++;
}
}
return -1;
}
The above code should return the nth non-zero element. For example, given vector v = [0, 8, 6, 0, 9, 7,20], should return 9 if n pass-in is 3;
Question: optimizing it.
My answer:
int getNthNonZeroElement(vector<int> & elements, int n) {
vector<int>::iterator i;
for (i = elements.begin(); i < elements.end(); i++) {
n -= ((*i) != 0);
if (n == 0) return (*i);
}
return -1;
}
btw, the original question should init count = 0| Report Duplicate | Flag | PURGE
Google Software Engineer in Test Coding - 0of 0 votes
AnswersWrite a function to convert a number to Roman numeral.
- mp March 22, 2009| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a problem scenario, write a program to output the total cost of solving that scenario. Given you have to construct house ( Senario ). And given all the factors that go into making the house, write a program that takes all parameters and outputs the total cost.
- John March 15, 2009
- Remember to do input type checking.
- Remember to make it optimized.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 0of 0 votes
AnswersGiven a password in number : Write an algorithm to print all possible combinations of that password.
- John March 15, 2009
Hint:
- Try from to go from all possible combinations of lower bound to the valid upper bounds| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 0of 0 votes
AnswersFrom a given string, replace all instances of 'a' with 'one' and 'A' with 'ONE'.
- John March 15, 2009
Example Input:
" A boy is playing in a garden"
Example Output:
" ONE boy is playing in one garden"
-- Not that 'A' and 'a' are to be replaced only when they are single characters, not as part of another word.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 0of 0 votes
AnswersWrite a software to print triangle made of *s. Given the height and width of Triangles in terms of number of stars. like to output
- John March 15, 2009
*
* *
* * *
given you have to use 3 stars or the height is 3 stars.| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 0of 0 votes
AnswersCode a function to shuffle a pack of cards
- Richie March 13, 2009| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer Coding - 0of 0 votes
AnswersA company has decided to increase salary of all the employees. These employees are divided into 3 categaries: A B C. The people in C category gets N percentage increase.The people in B category gets 2*N percentage increase.The people in A category gets 3*N percentage increase. The minimum increase should be atleast 1% and no matter what the percent be the maximum increase should not increase $75000. Write a function which takes appropriate input and calculates the increase and updated salary. Print the increase for the employee and the return the updated salary.
- SHA.AN March 04, 2009| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding - 1of 1 vote
AnswersThere is a security keypad at the entrance of a building. It has 9 numbers 1 - 9 in a 3x3 matrix format.
- SHA.AN March 04, 2009
1 2 3
4 5 6
7 8 9
The security has decided to allow one digit error for a person but that digit should be horizontal or vertical. Example: for 5 the user is allowed to enter 2, 4, 6, 8 or for 4 the user is allowed to enter 1, 5, 7.
IF the security code to enter is 1478 and if the user enters 1178 he should be allowed.
Write a function to take security code from the user and print out if he should be allowed or not| Report Duplicate | Flag | PURGE
Epic Systems Software Engineer / Developer Coding