Intern Interview Questions
- 1of 1 vote
AnswersGiven an array of integers when the difference between every two neighbored elements is either -1 or +1 or 0.
- maya November 24, 2014 in United States
Write an efficient search algorithm to find a given number of x in the array.| Report Duplicate | Flag | PURGE
Microsoft Intern - 2of 2 votes
AnswersYou have a set of N objects. Each of these objects have certain properties associated with them. A property is represented by a (key, value) pair. For example, assume you have the following two objects.
- Rahul Sharma November 23, 2014 in India
Tower:
{
(height, 100), (weight, 50),
(xposition, 25), (yposition, 36)
}
Tree:
{
(area, 100), (noofleaves, 500),
(height, 25), (yposition, 36)
}
Each object you have, will have at most 4 properties. An object will have at least 1 property. Note, from the two objects above, that it is not necessary for key in the properties to be same for all the objects. Also, it is not necessary for the key to be different.
Now, given N such objects, you wish to answer M queries. Each query is represented by a set of properties (again, at most 4 properties, and at least 1 property). The answer for the query is the number of objects in the set, that have all the given properties. Two properties are considered equal iff both the key and the value match.
For example, if you have the above two objects, then the answer for the following queries is
Query:
{ (height, 100), (yposition, 36) }
Answer:
1 // matches Tower, but not Tree
Query:
{ (yposition, 36) }
Answer:
2 // matches both Tower and Tree
Query:
{ (height, 100), (noofleaves, 500) }
Answer:
0 // neither Tower, not Tree satisfy both properties
Input
The first line of input contains N and M. This is followed by the description of the N objects. The description of the i-th object will start by a number k, which is the number of properties associated with the object. The next k lines contain two space separated strings - the property key and the property value. Note that the property value is not necessarily an integer (although this is so for the example above).
This is followed by the description of M queries. The format of a query will be exactly same to that of the objects. Check the Sample Input for clarification.
One test file will contain only one test case. A single test case may contain several queries.
Output
Print M lines. Each line must be the answer of the respective query.
Constraints
1 ≤ N ≤ 10000
1 ≤ M ≤ 100000
1 ≤ k ≤ 4
Sample Input
2 3
4
height 100a
weight 50b
xposition 25a
yposition 36b
4
area 100a
noofleaves 500
height 25
yposition 36b
3
weight 80
xposition 25a
yposition 36b
1
yposition 36b
2
xposition 25a
yposition 36b
Sample Output
0
2
1| Report Duplicate | Flag | PURGE
Directi Intern Algorithm - 0of 0 votes
AnswersYou are given a rectangular grid with 2 rows and N columns. The top row is labeled 1 and the bottom row is labeled 2. The columns are labeled from 1 to N in increasing order. Each cell in the grid contains a single character.
- Rahul Sharma November 23, 2014 in India
Consider a hamiltonian walk in this grid. Meaning, pick a starting cell, say (i,j), and consider a path that starts from (i,j) and goes through every cell in the grid exactly once. Note that you can only walk to adjacent cells, or cells that you share a common edge with. There may be several such paths. Let us concatenate the characters in the order in which the cells are visited during a walk. The string formed can be called the string for the walk.
Among all the possible walks, and their respective strings, find out the lexicographically smallest string. We know that the length of the strings are all the same - to be precise, 2N. Thus, the lexicographically smallest string is simply the alphabetically smallest string if you compare the characters from left to right.
Input
The first line of input contains a number T, the number of test cases. Then follow T test cases. Each test case contains 3 lines. The first line contains the number N, the number of columns in the grid. It is well known of course that the grid contains 2 rows. The next two lines contain the description of the grid in the form of two strings; the string of N characters in row 1 from left to right and the string of N characters in row 2 from left to right, respectively. Each character will be a lowercase engish letter.
Output
Output a single line for each test case. The line must contain a string with 2N characters. This string should be the lexicographically smallest string for some hamiltonian walk in the grid.
Constraints
1 = T = 100
1 = N = 10
Sample Input
2
3
abc
def
10
ababaaabab
bababababa
Sample Output
abcfed
aaababababababababab
Explanation
In the first test the possible strings are { abcfed, adebcf, adefcb, badefc, bcfeda, cbadef, cfedab, cfebad, dabcfe, dabefc, defcba, edabcf, efcbad, fedabc, fcbade, fcbeda }. The smallest string is abcfed.| Report Duplicate | Flag | PURGE
Directi Intern Coding - 1of 3 votes
Answers== Question ==
- zhaolixi1991 October 30, 2014 in United States
Given a list of TestResult, where each result contains a test score, a student ID and a date, figure out the students' final scores. A final score is the average of a student's top 5 scores.
Here is a sample of the list of TestResult:
50 JACK 5/14/2013
89 ALICE 3/25/2012
70 BOBBY 12/7/2010
60 JACK 8/9/2013
99 MIKE 9/11/2011
100 JOHN 7/4/2011
38 JACK 1/28/2014
46 JACK 11/15/2012
<... more ...>
struct TestResult {
score,
student_id,
date,
}| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm - 4of 4 votes
AnswersQuestion: Two players A and B are playing a game. Pots of gold, each with
- kiran.sanni October 28, 2014 in United States
varying number of coins are placed in a single line. The rules of the game are:
1) Players play turn by turn.
2) On each turn a player can pick a pot of gold from either end of the line. He
gets all the gold in that pot. The next pot of gold on that end is now available
for picking.
What is the maximum number of gold can the first player get ?| Report Duplicate | Flag | PURGE
Google Intern Algorithm - -3of 3 votes
Answersa left grow binary tree. Describe as below. (Transform from A to B)
- kiran.sanni October 28, 2014 in United States
A: B:
1 1
/ \ /
2 3 2 - 3
/ \ /
4 5 4 - 5
/ \ /
6 7 6 - 7
a left grow binary tree. Describe as below. (Transform from A to B)
A: B:
1 1
/ \ /
2 3 2 - 3
/ \ /
4 5 4 - 5
/ \ /
6 7 6 - 7| Report Duplicate | Flag | PURGE
Google Intern Algorithm - 1of 1 vote
AnswersWrite a method that takes an int as input and outputs an int with the digits of the input in reverse, i.e. 12345 -> 54321.
- emailjunk94 September 23, 2014 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Math & Computation Intern - 0of 0 votes
AnswersGiven a sorted array of 0’s and 1’s. Find out the no. of 0’s in it. Write recursive, iterative versions of the code.
- Saurabh2816 August 17, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Intern Arrays - 1of 1 vote
AnswersGiven a n-ary tree, Convert it into an array and return it. Construct the same n-ary tree from that array again.
- Saurabh2816 August 15, 2014 in India| Report Duplicate | Flag | PURGE
Amazon Intern C# - 0of 0 votes
AnswersWrite test cases for testing browser extension (chrome in particular)
- JG July 18, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Testing - 0of 0 votes
AnswerWhat tests would you write for testing chrome browser extension?
- JG July 18, 2014 in United States for QA| Report Duplicate | Flag | PURGE
Intern Testing - 1of 3 votes
AnswersGive efficient implementation of the following problem.
- sigkill July 08, 2014 in India
An item consist of different keys say k1, k2, k3. User can insert any number of items in database, search for item using any key, delete it using any key and iterate through all the items in sorted order using any key. Give the most efficient way such that it supports insertion, search based on a key, iteration and deletion.| Report Duplicate | Flag | PURGE
Google Intern Algorithm - 4of 4 votes
AnswersWe have 25 horses and we need to find top 5 fastest horses irrespective of order, in a race only 5 horse can run. how many min races required to know top 5 horses...out of top 5 ordering not matter...u not need to tell which is fastest which is at second position.....
- Kavita June 03, 2014 in India| Report Duplicate | Flag | PURGE
Samsung Intern - 0of 0 votes
AnswersGiven two strings, write an efficient algorithm (in Java) to compare the two of them. Your algorithm should handle all cases
- varunumesh77 March 28, 2014 in United States| Report Duplicate | Flag | PURGE
VMWare Inc Intern - 4of 4 votes
AnswersYou are given a large set of integers, which are not sorted. Figure out a method to retrieve the largest 1000 elements, in O(n) run time
- varunumesh77 March 12, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Intern Algorithm Data Structures - 0of 0 votes
AnswersStooge sort implementation using Iteration?
- LOC February 28, 2014 in United States| Report Duplicate | Flag | PURGE
Intern Algorithm - 0of 0 votes
AnswersGiven a string, return the string with the words reversed
- Bryan.S.Lam February 26, 2014 in United States for Quality Engineer Intern
"I am good" -> "good am I"
List test cases and if you were crunched on time and only had time to test one test case, which would you pick| Report Duplicate | Flag | PURGE
Salesforce Intern Algorithm - 1of 1 vote
AnswersConstruct an iterator of iterator
- varunumesh77 February 26, 2014 in United States
Here is the below question format:
// E next();
// Boolean hasNext();
// input: Iterator<Iterator<E>>
// output: Iterator<E>
// [[1], [2, 3]] => [1, 2, 3]| Report Duplicate | Flag | PURGE
Amazon Intern Java - -4of 4 votes
Answerswhy do you choose Amazon?
- jztestemail February 20, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Intern - 0of 0 votes
Answersif you are given 2 arrays
- chugh.rachita February 15, 2014 in India
one has n elements and another has n+2 elements
and the elements in the array are same except the 2 elements
find those two extra elements..
give the optimal solution.| Report Duplicate | Flag | PURGE
Intern Arrays - 0of 0 votes
AnswersGiven a set of numbers, find those numbers that occur odd number of times. I used the hash table approach where I insert the count (no. of times occurred as of now) of the current number whose hash I am making. Time complexity: O(n). Space complexity: O(n).
- sush February 05, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Intern - 1of 1 vote
AnswersSuppose you are a project manager and you're certain your project is going to be late. What actions should you take?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Experience - 0of 0 votes
AnswerWhat are the most important things to a software development project?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Experience - 1of 1 vote
AnswersWhat is integration testing?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Testing - 1of 1 vote
AnswerWhat types of security testing do you know? do you know SQL injections?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Testing - -2of 2 votes
AnswersGive us an example of meeting a deadline that you are particularly proud of
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Questions YOU should ask! - -3of 3 votes
AnswersWhat is your greatest failiure?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Questions YOU should ask! - -8of 8 votes
AnswersDo you know any C#?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern C# - -6of 8 votes
AnswersAre you familiar with .NET?
- barrysingh1108@googlemail.com February 01, 2014 in UK| Report Duplicate | Flag | PURGE
Sage Software Intern Front End Web Development