#include<stdio.h>

int findMax(int *arr , int len)
{
 int i;
 int max = arr[0];
 for(i=0;i<len;i++)
 {
  if(arr[i]>=max)
   max= arr[i];
  }
  printf("%d\n",max);
return max;
}


int findMin(int *arr ,int len)
{
 int min,i;
 for(i=0;i<len;i++)
 {
  min=arr[0];
  if(arr[i]<arr[i+1])
   min= arr[i];
  }
  printf("%d\n",min);
return min;
}


int main()
{
 int arr[]={0,609,211,432,31,2222},len,p,m=0,n=0;
 len = sizeof(arr)/sizeof(arr[0]);
 n = findMax(arr,len);
 m = findMin(arr,len);
 p = n-m;
 printf("\n The Maximum Difference is\n");
 printf("%d\n",p);
 return 0;
}


This is the simple most inefficient code written for finding the
maximum difference .

I Need you to help me to come up better solutions to solve the problem
and the test cases on which it fails with alternate solutions .

Regards

Rajeev N B

I Blog @ www.opensourcemania.co.cc

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to