Howdy, Stranger!

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


please suggest code in c language only with minimum execution time

ronglay9876ronglay9876 Member Posts: 1
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 VietnamMember Posts: 7

    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.