Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

LNK1 - Editorial

$
0
0

PROBLEM LINK:

Practice

Contest

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.


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>