kol
BAN USERStudent
- 0of 0 votes
AnswersFind the maximum element per level in a BST .?
- kol in United States for bing
In O(n) time and O(1) space ..? or O(logn) time and O(n) space.. telephonic interview| Report Duplicate | Flag | PURGE
Microsoft Algorithm
I believe the test case is for reversing a string
1.What happens if string is null
2.what if string has same characters
3.what if string is a palidrome.
4.what is the longest length of the string func can accept.
5.can this reverse integers?
6.If it fails due to some reason how does it cope up?
7.what if the end of string is not terminated by NULL character ?
#include <iostream>
#include <stdio.h>
using namespace std;
void FindInterleaving(char* cResult, int nResult, char *cSt1,char *cSt2){
if(*cSt1=='\0' && *cSt2=='\0')
return ;
if(*cSt1=='\0'){
while(*cSt2!='\0'){
cResult[nResult++]=*cSt2;
cSt2++;
}
cResult[nResult]='\0';
printf("%s\n",cResult);
return ;
}
if(*cSt2=='\0'){
while(*cSt1!='\0'){
cResult[nResult++]=*cSt1;
cSt1++;
}
cResult[nResult]='\0';
printf("%s\n",cResult);
return ;
}
cResult[nResult++]=*cSt1;
FindInterleaving(cResult,nResult,cSt1+1,cSt2);
cResult[nResult-1]=*cSt2;
FindInterleaving(cResult,nResult,cSt1,cSt2+1);
}
int main(){
char cSt1[3]="AB",cSt2[3]="CD";
char *cResult= new char[5];
int nResult=0;
FindInterleaving(cResult,nResult,cSt1,cSt2);
}
@Raju yes you can..
- kol July 15, 2012Please dun spam this website, if you have put some efforts in finding the answer and asked your query here , you'll surely get a response ..