please suggest code in c language only with minimum execution time - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

please suggest code in c language only with minimum execution time

ronglay9876ronglay9876 Posts: 1Member
can anybody please help me to solve this problem in "C language" please:
N people are waiting in line to enter a concert. People get bored waiting so they turn and
look for someone familiar in the line. Two persons A and B standing in line can see each
other if they


  • StupidKidStupidKid VietnamPosts: 7Member

    Maybe it's too late now but I still reply :D I don't know anything about C or C++ so I will tell you the algorithm : Firstly, you have a var called "count" or sth like that. Its first value is n-1 (Cause everyone can see the person next to them). You have a loop for i from 1 to n-1, if the following number (a[i+1]) is bigger than a[i] then assign the a[i] with 0 or a specific value. The number of pairs are count+number of people have a value bigger than 0 - 1
    My english is just too bad. But I think it can help you

Sign In or Register to comment.