Today I'm going to present a really simple and educational application of dictionaries/maps, Distinct Values Sum, where we only care about the position of the most recent distinct value and add the sum of these positions in order to get the answer, my solution being the most simple you can find on the internet for this task.
It is a problem I highly recommend to people who are starting out with sets/maps.
Problem: https://cses.fi/problemset/task/3150/
C++ Solution Code: https://cses.fi/paste/20b6df3cfdc7ebbbdfbb40/
Python Solution Code: https://cses.fi/paste/cc4d9f7d56aac477dfbb4a/
My Algorithms Templates: https://github.com/stefdasca/CompetitiveProgramming/tree/master/Algorithms
My website: https://stefdasca.ro/
Codeforces profile: https://codeforces.com/profile/stefdasca
Discord server: https://discord.gg/ZDfmQBKHkC
Facebook page: https://www.facebook.com/stefan.dascalescu.2013/
Linkedin: https://www.linkedin.com/in/stefdasca/
Instagram page: https://www.instagram.com/stefdasca/
Download
0 formats
No download links available.
Distinct Values Sum (CSES Problem Set, Additional Problems I) - Video Tutorial | NatokHD