PROBLEM LINK:
DIFFICULTY:
EASY
EXPLANATION:
This is a straight forward question. Link only defeats monsters which have a level greater than or equal to his.
Initially Link's level is zero and total XP is zero. Move from left to right in the array.
If the level of the monster is greater than or equal to Link's level, then defeat it, add the monster's level to the total XP, and set Link's level to the level of the monster.
Else, skip that monster.
This solution has a complexity of O(n).
AUTHOR'S AND TESTER'S SOLUTIONS:
Author's solution can be found here.
Tester's solution can be found here.