Had, my google internship, 1st interview today(Telephonic). Love it when the questions come out simple. But I think, a BE student is either kept light, or it being the first one, they planned to lighten me out. And i was introduced to google docs, which I don't know, why I hadn't been using. The questions were on phone as well as on the Google document and they seemed to analyse the code as i wrote it.
Q 0 - About my internship at MS - Was expecting that. Said whatever, I was allowed to and indeed got a little over excited at occasions which might go bad on me. But anyhow, I had worked, so found it easy to answer.
The rest are on the google document I place here. And I was not the one to write the code alone, for I was being adviced of the test cases especially for question one, quite often, and I then could correct them. Luckily, unlike my earlier MS interview, last year, I was able to crack all acses missing. Seems string questions are hot favourites, for they came to be twice and in both the cases, the test cases were the key.
The questions are simple, I think, in comparison to what the other bloggers give, but I think, the best is still to come (If I pass through). I would blame it on myself, if I do not make it, for i really messed the second one at the start, the panic of the brand name getting on to me. It went so bad that she asked me whether I know Inorder(the basics). But I think, I improved upon over that when I started out writing and I hope all goes well. Recession has really limited the opportunities, especially if you are not an IITian, but we have to fight it together.
Without any more Ado, the doc:
1.) Given a string find the first non-consecutively repeated character in the string.
Example: "aaabbcaabbcc", the answer is c (sixth letter)
/*
Algo:
Scan linearly- store i-1th element and compare to ith
*/
char conConsecutive(char *sIp)
{
int len=strlen(sIp);
if(len==0) return 0;
if(len==1) return sIp[0];
if(sIp[0] != sIp[1]) {
return sIp[0];
}
for(int i=1;i
{
if(sIp[i] == sIp[i-1]) continue;
if(sIp[i] == sIp[i+1]) {i+=2; continue;}
return sIp[i];
}
if(sIp[len-2] != sIp[len-1] ) return sIp[len-1];
return 0;
}
abbaa - Ist char unique
aabba - Last char unique
aaabbaacbb - String has three(odd) char with same type
2.) Print the Nth inorder node in a binary tree.
int printK(Struct Tree *ptr, int l)
{
if(ptr==NULL) return l;
int k= printK(ptr->left,l);
if(k==0) return 0;
if(k==1)
{
cout<
info;
return 0;
}
k=printK(ptr->right,k-1)
return k;
}
3. How many zeros are present in 100!
int CountZeroes(int n)
{
int k=1;
int ret=0;
while(pow(5,k)<=n)
{
ret+=n/pow(5,k);
k++;
}
return ret;