Veveo Interview Questions:
Telephonic :
sizeof operator implementation \Sol :
#include <iostream>
#define mysizeof(type) (size_t)((type*)0+1)
using namespace std;
int main() {
cout<<mysizeof(double);
return 0;
}
1. Inorder Successor
2. char *p = malloc(1024);
p = p-2;
*p = 2;
How will you detect memory corruption.
3. Hash table,modulo,bucketing
4. char *p = malloc(1024)
char *q =p+512;
for(int i=0;i<1024;i++)
p[i] = i;
free(q);
for(int i=0;i<1024;i++)
printf("%c",p[i]);
What will be output.
5. 25 horses puzzle
6. Dot on forehead puzzle
7. strcat implementation
8. structure padding and alignment
9. Code mymalloc() and myfree()
Toppr.com Interview Questions :
1. Find local minima in an array
2. Train arrival and departure time is given
how many minimum number of platform will be required (Segment tree solution n log n)
3. Mobile number pad is given. you can move only like a chess Knight
print all different 10 digit numbers.
1616161616
http://stackoverflow.com/questions/2893470/generate-10-digit-number-using-a-phone-keypad
Ans: http://ideone.com/BplzQo
Pressplay Interview Questions:
1. 25 horses puzzle
2. Coin on the table puzzle
3. {cat,dog,acte}
number of occurrences of all words cat : 2,dog : 1,acte : 1
C/C++ interview questions
KLA Tencor Interview Questions:
1. Deep copy vs Shallow copy
2. What happens when an object is created using new operator.
3. How to restrict object to be created on heap
4. Singleton class
5. What will you write in class if we have given you char *x;(Rule of three)
Symantec Interview Questions:
1. Methods distinguished only by return type can be overloaded or not?
2. Inside static method can we use this pointer?
3. Why we need static method (When we need only one copy of method)
4. Difference between dangling pointer and NULL
5. Why we need pure virtual functions ()
6. What is Zombie process
()
CouponDunia.com Interview Questions :
1. Online test
a.Given a string of characters, convert it to its shortest possible representation. To shorten a string, you can replace the continuous occurrences of a character with the count of those occurrences for ex: [count]@[character]. Make sure that you shorten the string only if needed.
Sample Input:
Sample Output:
aaaazzzzSample Output:
4@a4@z
Sample Input:
Sample Output:
aaaawwaaaaappppSample Output:
4@aww5@a4@p
Based on the programming language you have selected, you will see a function stub. You only have to complete the function. The rest of the program is already written behind the scenes
string condenseString(string str) {
string temp;int j=0;
for(int i=0;i<str.size();i++)
{
int count = 1;
while(str[i]==str[i+1] && (i+1) < str.size())
{
count++;
i++;
}
if(count>3)
{
temp.push_back(count+'0');
temp.push_back('@');
temp.push_back(str[i]);
}
else
{
while(count>0)
{
temp.push_back(str[i]);
count--;
}
}
}
return temp;
}
b.A petrol pump buys and sells petrol at the daily standard price declared by the state government. Suppose we are given an array of n integers representing the standard prices of petrol per litre for n consecutive days. Write a function to determine the price and day at which the petrol pump must buy and then sell petrol in order to make a profit and maximize it.
Sample Input:
70 72 73 78 79 74 77
Sample Output:
1 70
5 79
where, in the output, row 1 shows that you buy on day 1 at Rs.70 (numbers separated by a single space) and row 2 shows that you sell on day 5 at Rs.79 (numbers separated by a single space).
Assume that none of the test cases will have ambiguous answers and that we will never make a loss. You must always buy at some price and sell at some price.
#include <iostream>
#include<vector>
using namespace std;
/*
* Complete the function below.
*/
void calculateProfit(vector < int > prices) {
//int buy=prices[prices.size()-1],sell=0,day2=prices.size()-1,day1=0;
int day2=prices.size()-1,day1=0;
//cout<<"day2"<<day2<<"day1"<<day1<<endl;
for(int i= prices.size()-1;i>=0;i--)
{
if(prices[i]>prices[day2] && day2 > day1)
{
day2 = i;
}
else
{
if(prices[i]<prices[day1] && i<day2 )
{
day1 = i;
}
}
}
cout<<day1+1<<" "<<prices[day1]<<endl;
cout<<day2+1<<" "<<prices[day2]<<endl;
}
int main() {
int _prices_size;
cin >> _prices_size;
//cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');
vector<int> _prices;
int _prices_item;
for(int _prices_i=0; _prices_i<_prices_size; _prices_i++) {
cin >> _prices_item;
_prices.push_back(_prices_item);
}
calculateProfit(_prices);
return 0;
}
C.
You are given a list of words a baby can speak. There is a recorder that can convert the baby's speech to text, but it cannot recognize pauses, so it does not put spaces in between the words.
Write a program that can convert the baby's recorded speech into words spoken by the baby (existing in the baby dictionary). Every part of the text is actually a word, so if the program outputs one word and the rest as garbled text, it won't be correct. Every test case will have only one correct answer (assume your test case wont contain any phrase that can have more than one correct answer)
Input Variables
1) baby_words = array containing the words the baby can speak.
2) garbled_text = text given by the recorder that converted speech to text
2) garbled_text = text given by the recorder that converted speech to text
Sample Input
garbled_text =
baby_words =
gagagoogoobaby_words =
[gag goo gaga]
Sample output :
gaga goo goo
The following outputs are wrong:
1) gag
2) gag goo
3) gag a goo goo
2) gag goo
3) gag a goo goo
The output must be formatted in the following manner:
Each word must be on the same line and separated by a single space. (The example above has the correct format)
/*
* Complete the function below.
*/
void findBabyWords(vector < string > baby_words, string garbled_text) {
}
Sol:
using namespace std;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define MOD 1000000007
set<string>myset;
bool main_test(string st,int start,vector<string>&vec)
{
string x;
if(start >= st.size()-1)
return true;
for(int i = start ; i < st.size() ; i++)
{
x.PB(st[i]);
if(myset.find(x)!=myset.end())
{
vector<string >ans;
//cout<<x<<" ";
bool bt = main_test(st,i+1,ans);
//cout<<bt<<" "<<start<<endl;
if(bt)
{
vec.PB(x);
for(int i =0 ; i < ans.size(); i++)
vec.PB(ans[i]);
return true;
}
}
}
return false;
}
void findBabyWords(vector < string > baby_words, string garbled_text) {
for(int i =0 ;i < baby_words.size(); i++)
{
cout<<baby_words[i]<<endl;
myset.insert(baby_words[i]);
}
vector<string>answer;
bool bt = main_test(garbled_text,0,
answer);
for(int i =0 ; i< answer.size() ;i++)
{
cout<<answer[i]<<" ";
}
cout<<endl;
}
Sol:
using namespace std;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define MOD 1000000007
set<string>myset;
bool main_test(string st,int start,vector<string>&vec)
{
string x;
if(start >= st.size()-1)
return true;
for(int i = start ; i < st.size() ; i++)
{
x.PB(st[i]);
if(myset.find(x)!=myset.end())
{
vector<string >ans;
//cout<<x<<" ";
bool bt = main_test(st,i+1,ans);
//cout<<bt<<" "<<start<<endl;
if(bt)
{
vec.PB(x);
for(int i =0 ; i < ans.size(); i++)
vec.PB(ans[i]);
return true;
}
}
}
return false;
}
void findBabyWords(vector < string > baby_words, string garbled_text) {
for(int i =0 ;i < baby_words.size(); i++)
{
cout<<baby_words[i]<<endl;
myset.insert(baby_words[i]);
}
vector<string>answer;
bool bt = main_test(garbled_text,0,
for(int i =0 ; i< answer.size() ;i++)
{
cout<<answer[i]<<" ";
}
cout<<endl;
}
Hi Bhupendra,
ReplyDeleteA really interesting, clear and easily readable Veveo Interview Questions article of interesting and different perspectives. I will clap. So much is so well covered here.
Using C Prog, Dev a prog that will play a number guessing game. The prog should allow users to enter their 3 numbers (between 0-9). You must store teh 3 numbers in a 1D array.
Your prog should use functions. The prog should display a simple menu to the user and each option in teh menu will be implemented by calling a separate function. You must use pointer notation to access array elements-NOT subscripts.
1. Enter 3 selected numbers
2. Display the contents of the 1D array containing the numbers you entered.
3. Compare your chosen lotto numbers in teh 1D array with eh following winning numbers: 1,3, 5
Return to the main() function how many numbers the use entered correctly and display this.
4. Reverse the contents of the 1D array containing the numbers the user entered correctly and display this.
Thanks a lot. This was a perfect step-by-step guide. Don’t think it could have been done better.
Kind Regards,
Savinder