Intern Interview Questions
0of 0 votes"Write test cases for reversing words of string ". For eg. "This is nice" is input string and output is "nice is This".
I gave him -
" "
"Hello"
"bye! Mr. X Y. Kumar"
But he didn't seem satisfied.
Can u plz tell what general guidelines should I follow for writing efficient test cases.
What more test cases should I have written for this question ?
0of 0 votesDesign class structure for a building, floors and space. The space can be an apartment, a store or an office. Include any properties, fields and methods you think would be interesting to have.
0of 0 voteshow to solve this ((3000000!)/(30!)^100000)%(any prime no.) in C++
0of 0 votesGiven 3 engineers, devise a way for them to figure out the average of their salaries without sharing their individual salaries with one another.
-2of 2 votesIn a 5*4 matrix what is the most optimal way of traversal and compare the time complexity for different solution ?
2of 2 votesWrite a function which returns kth element from the tail in a linked list.
0of 0 votesImplement Iterator class with peek() functionality in Java.
0of 0 votesthere is a log file which contains info in below format:
timestamp : customer-id : page-id
repeat customers are customers who return to the amazon site(any page) after at least a day.
write a code to print all the repeat customers
2of 2 votesWrite a function that finds out if any two numbers within that array add up to a target.
bool addsUp(Array<int> input, int target);
0of 0 voteswap to find the longest arithmetic sequence in given array... return number of element in seriese...
simple test case..
sizeofarray=4
array element
3 4 5 8
output
3
sample test case
size of array =10
array element..
-1 1 3 7 11 15 19 20 21 22
output
5
0of 0 voteswaf for a linked listed ..
shift all digit to first then consonant then vowel ..
such that list contain only one time one digit , consonant , vowel ..
List *(List *head);
input :
2->a->5->a->2->b->o->n->5->n.
output..
2->5->b->n->a->o..
0of 0 voteswap to take one rotate a square matrix anticlock wise by 90 degree and add a particuler number after rotation to each prime column.
function prototype should be..
void rotate(int a[][],int size, int keytobeadded);...
sample test case....
input
size=3
keytobeadded=5;
square matrix :
1 2 3
4 5 6
7 8 9
output should be
3 11 9
2 10 8
1 9 7...........
-3of 3 voteswrite a function that print TRUE if (){}[] are balanced in expression .. otherwise return FALSE.
[{()}] currect.. priority of [ >}>)..........it should be preserved
....................................................................................
void check(char *a)
{
struct s
{
char ch;
s*next;
};
s *st=NULL;
s*node=NULL;
if(a=='\0')
{
cout<<"TRUE";
return ;
}
else
{
while(a[0]!='\0')
{
{
node=(s*)malloc(sizeof(s));
char c=a[0];
switch(c)
{
case '[':
if(st==NULL)
{
node->ch=c;
node->next=NULL;
st=node;
a++;
}
else
{
if(st->ch=='('||st->ch=='{')
{
cout<<"FALSE";
return ;
}
else
{
node->ch=c;
node->next=st;
st=node;
a++;
}
}
break;
case '{':
if(st==NULL)
{
node->ch=c;
node->next=NULL;
st=node;
a++;
}
else
{
if(st->ch=='(')
{
cout<<"FALSE";
return ;
}
else
{
node->ch=c;
node->next=st;
st=node;
a++;
}
}
break;
case '(':
if(st==NULL)
{
node->ch=c;
node->next=NULL;
st=node;
a++;
}
else
{
node->ch=c;
node->next=st;
st=node;
a++;
}
break;
case ')':
if(st==NULL||st->ch=='{'||st->ch=='[')
{
cout<<"FALSE";
return ;
}
else
{
if(st->ch=='(')
{
s *newnode=st;
st=st->next;
free(newnode);
a++;
}
}
break;
case '}':
if(st==NULL||st->ch=='('||st->ch=='[')
{
cout<<"FALSE";
return ;
}
else
{
if(st->ch=='{')
{
s *newnode=st;
st=st->next;
free(newnode);
a++;
}
}
break;
case ']':
if(st==NULL||st->ch=='{'||st->ch=='(')
{
cout<<"FALSE";
return ;
}
else
{
if(st->ch=='[')
{
s *newnode=st;
st=st->next;
free(newnode);
a++;
}
}
break;
default :
a++;
if(a[0]=='\0')
{
cout<<"TRUE";
return ;
}
break;
}
}
}
if(st==NULL&&a[0]=='\0')
{
cout<<"TRUE";
return ;
}
if(st!=NULL)
{
cout<<"\nFALSE";
return ;
}
}
}
0of 0 voteswrite a funtion to shift all vowel in first and all consonant in last . Order of all vowel and consonant should should preserved .
1of 1 voteYou are given the task of creating the address book application for a smart phone. There are some
of the top level features you must implement.
1.There will be 1000+ phone book entries and user must get very quick response.
2.On default screen it shows the names of all people in alphabetical ascending order.
3.Using the search option, user can search and it will show only those names starting
with those characters which are typed in the search box.
You are supposed to compare two different data structures and list down the pros and cons of each
and finally recommend the best suited data structure.
1of 1 voteHighly coupled code is code where the dependencies between classes are dense, lots of things
depend on other things. This kind of program is hard to understand, tough to maintain, and tends
to be fragile, breaking easily when things change.
Simplistically, we can say that class A is statically coupled to class B if the compiler needs the
definition of B in order to compile class A. Moreover dependencies among them are transitive.
That is if A depends on B and B depends on C, then A also depends on C
Create a program logic/pseudo code which can print the "expanded dependency tree" given a set
of input per class dependencies. Make sure that there are no duplicates in the output
Input
A -> B,C
B->C,E
C->G
D->A,F
E->F
F->H
Output
A depends on B C E F G H
B depends on C E F G H
C depends on G
D depends on A B C E F G H
E depends on F H
F depends on H
0of 0 votesGiven a number, print its corresponding string representation. Example: I/P: 523, O/P: Five hundred and twenty three, I/P: 501, O/P: Five hundred and one, I/P: 11, O/P: eleven
0of 0 votesIf there is a million data in file(assume integers).
The memory is enough to hold all the data.
After loading all the data into data structure , we need to insert 500 new integers after the 10000th element.
What Data structure to use and how to use?
1of 1 voteWrite a program to sort an array of strings so that all anagrams are next to each other
ex
input {god, dog, abc, cab, man}
output {abc, cab, dog, god, man}
0of 0 votesWhat should be the output of the following code.
class Test {
public int i=0;
@Override
public int hashCode() {
return i;
}
}
Class a{
psvm(){
HashMap <Test, String> hm = new HashMap();
Test t1 = new Test();
hm.put(t1,”success”);
sysout(hm.get(t1)); //print success
t1.i = 10;
sysout(hm.get(t1)); //NULL
}
}
-1of 3 votesGiven an 2D array of characters. Find words in the array (either vertical or horizontal). a character cannot be part of 2 words. Maximize the number of characters used. Hint: 1D variant can be solved by Dynamic programming in linear time.
0of 0 votesImplement print function given an integer without using the built-in print function
0of 0 voteshow to find lowest common ancestor of a binary tree
??
not BST
0of 2 votesGiven an infinite sequence of integers which are repeated many times. WAP to print "beep" if an integer appears ODDth time else print "no beep".
example: input: a[] = { 1,4,2,4,3,2,4}
output: beep, beep, beep, no beep, beep, no beep, beep
Space complexity - O(1)
0of 0 votesGiven a multidimensional array with only 0s and 1s, reverse the array! I guess what he meant was flip 0s to 1s and vice versa! The array could be of any dimension ex:4X4X4X4....
(I dint get this q's so asked for another!)
0of 0 votes1. Write a program for returning all pairs that map to a value...Discuss different implementations.
0of 0 votes1. Write a program to return a max BST within a given B-tree
0of 0 votes1. Write an program to check for anagrams. Discuss different implementation. like using extra space and without using extra space.
0of 0 votes1. What is a Hash Map..? Describe its two implementation.
2. Difference between Arraylist and linkedlist in JAVA.
3. Discuss issues in implementing HashMaps...collisions mainly...and how to fix them.
4. What is run-time polymorphism in JAVA..explain with example.
0of 0 votesA solution takes 8 hours to do n independent jobs. What will you do to improvise?
Follow up: Improvise on a single processor
Follow up: If N task work uses shared memory
