cout << ((int)((int*)upperbound(a,a+5,k)-a))/4-1;
2009/3/1 sharad kumar <[email protected]>
> #include<iostream.h>
> int main()
> {
> int a[5]={3,3,3,6,7};
> int k;
> cin>>k;
> int i=0,j=1,c=0;
> for(;i<5;i++)
> {
> if(a[j-1]!=a[i]&& a[i]!=k)
> j++;
> else
> c=i;
> }
> cout<<c;
> return 0;
>
> }
>
> On Sun, Mar 1, 2009 at 9:50 AM, sharad kumar <[email protected]>wrote:
>
>>
>> hi,
>> does the above solution need any time complexity and space complexity in
>> specifific. idont understand use binary search
>>
>> On Sun, Mar 1, 2009 at 12:13 AM, jaanu <[email protected]> wrote:
>>
>>>
>>> Given a sorted arrays of N integers, possibly with duplicates, write a
>>> function that
>>> returns the highest index of an element X in that array if found or -1
>>> otherwise.(use Binary search)
>>>
>>>
>>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---