rishi
BAN USER
C solution using array.
void commonCharacters(char* str1, char* str2, char* str3)
{
int i=0;
int array[26]={0};
while(*str1!='\0')
{
if(array[*str1-97]==0)
array[*str1-97]=1;
str1++;
}
while(*str2!='\0')
{
if(array[*str2-97]==1)
array[*str2-97]=2;
str2++;
}
while(*str3!='\0')
{
if(array[*str3-97]==2)
array[*str3-97]=3;
str3++;
}
for(i=0;i<26;i++)
{
if(array[i]==3)
printf("%c\n",i+97);
}
}
Recursive solution
int rotated_binary_search(int A[], int start, int end, int key)
{
int middle=(start+end)/2;
if(start==end)
{
if(A[start]==key)
return start;
else
return -1;
}
if(A[start] <= A[middle] )
{
if(A[start]<=key && key<=A[middle])
return rotated_binary_search(A,start,middle,key);
else
return rotated_binary_search(A,middle+1,end,key);
}
else
{
if(A[middle]<=key && key<=A[end])
return rotated_binary_search(A,middle,end,key);
else
return rotated_binary_search(A,start,middle-1,key);
}
}
Repmarthajpatton, Data Scientist at AppPerfect
Managed a small team implementing gravy in Prescott, AZ. Developed several new methods for easy break up spells.Had some ...
Reprohitrana0777, Animator at AMD
I am work in free lancing as a editor in web developer. I also like play sports. I like kabaddi ...
Repthonylermat, OOPS Experienced at 247quickbookshelp
I have been assigned based on the successful candidate's level of training and experience but will include types of ...
Steps:
Iterate the array recursively
at each call create node and update its key
if it is leaf node, return the newly created node
if not leaf node, call function to update left and right child nodes.
We need a pointer to keep track of location in array.
- rishi September 04, 2014