abhishek
BAN USER
Questions (2)
Comments (5)
Reputation 70
- 2of 2 votes
Answerstwo BST are given find common elements in both....
- abhishek in India for idc| Report Duplicate | Flag | PURGE
Microsoft Intern Trees and Graphs - 0of 0 votes
Answersgiven s string "1010101010" in base2 convert it into string with base4.not use extra space....
- abhishek in India for idc| Report Duplicate | Flag | PURGE
Microsoft Intern String Manipulation
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
#include<stdio.h>
#include<strings.h>
char exploreString(char str[],int k)
{
int i=0;
int current=0;
int l=strlen(str) ;
for(i=0;i<l;i++)
{
if(str[i]>47 &&str[i]<55)
{
current+=str[i]-'0' ;
if(k<=current)
return str[i-1] ;
}
}
printf("k is not in string\n") ;
}
void main()
{
char str[50],ch ;
int k;
printf("enter the string\n") ;
scanf("%s",str) ;
printf("enter the number\n") ;
scanf("%d",&k) ;
ch=exploreString(str,k) ;
printf("%c",ch) ;
}
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
#include<stdio.h>
- abhishek July 25, 2013#include<strings.h>
int bsearch(char a[],int low,int high)
{
int mid,index;
mid=low+(high-low)/2 ;
printf("%d%d\n",low,high) ;
if(low>high||low==high && a[low]=='0')
return -1 ;
index=bsearch(a,low,mid-1) ;
if(index!=-1)
return index ;
if(a[mid]=='1')
return mid ;
return bsearch(a,mid+1,high) ;
}
void main()
{
char s[100] ;
int i=0;
printf("enter the string\n") ;
gets(s) ;
fflush(stdin) ;
while(s[i++]!='\0') ;
printf("%d\n",i) ;
printf("at %d index first occurance of 1",bsearch(s,0,i-1)) ;
}