help in solving question

Help in solving below problem. I am unable to solve this problem.

Therasa is a Nurse. She wants to give some tablets to the patients in her practice. All the patients sit in a line and each of them has a rating score according to his or her health score. Therasa wants to give at least 1 tablet for each patient. Patients get jealous of their immediate neighbors, so if two patients sit next to each other then the one with the higher rating must get more tablets. Therasa wants to save money, so she wants to minimize the total number of tablets.

The first line of the input is an integer N, the number of patients in Therasa’s practice. Each of the following N lines contains an integer indicates the health score of each patient.

Output a single line containing the minimum number of tablets Therasa must give.

1 <= N <= 100000
1 <= health score <= 100000

link to problem

Sort the list and allocate tablets.

  1. Start with allocating 1 tablet.
  2. Continue allocating 1 tablet until rating increases for the next patient.
  3. When rating increases give 2 tablets.
  4. Continue until rating increases continuosly, when a same rating occurs reduce the no of tablets to 1 as two patient with same rating will never bother about # tablets given to each other.
  5. In this way i think we can have the minimum number of tablets allcated to the patients.
  6. Goto step 3

mind sharing the problem link? Or giving us some test cases?

@tacoder problem link