JAVA // Exam - 28 October 2018 Part II - MeTube Statistics
Здравейте, много ще се радвам, ако има някой, който да реши тази задача, че забих дотук.. https://pastebin.com/FpQrTPLL
Let’s create a video platform such as YouTube. It will be called MeTube. Your task is to store videos, videos’ views and likes.
You will be receiving lines in the following format: "{videoName}-{views}" until you receive "stats time". You should store video and its views, if the video already exists add the views to it.
You can receive a command to rate a video in the following format: "like:{video}" or "dislike:{video}". The like command will give a single like whereas the dislike command will remove a like, but the given video needs to exist.
After receiving "stats time" you will receive an order criterion – either "by views" or "by likes". If you receive "by views" order the videos by views in descending order, otherwise order the videos by likes in descending order.
Print each of the videos in the following format:
"{video} - {views} views - {likes} likes"
Input
Until you receive " stats time " you will be receiving videos in the following format: "{video}-{views}".
You can receive a rate command -> "like {video}" or "dislike {video}".
After "stats time" you will receive either "by views" or "by likes".
Output
Print the statistics for each video in the following format: "{video} - {views} views - {likes} likes"
Constraints
The views will be a valid integer in the range [1-1000].
The video's name will not contain dashes ('-') or colon (':').
Allowed working time / memory: 100ms / 16MB
Input Output
Eninem Venom-500 Funny cats - 700 views - 2 likes
like:Eninem Venom Enimem Venom 800 views - 1 likes
Funny Cats-700
like:Funny Cats
like:Funny Cats
Eninem Venom-300
stats time
by likes
Input Output
Eminem Ringer-300 Messi Top Goals - 500 views - 0 likes
Messi Top Goals-500 Eminem Ringer - 300 views - 1 likes
like:Eminem Ringer
like:Eminem Ringer
dislike:Eminem Ringer
stats time
by views
Разбрирам го, но след като го видя...Много благодаря!
А, ако искаме да вземем ключа от другия мап, а не стойсността му. Как ще стане?
пример:
Funny Cats - 700 views - Funny Cats
Eninem Venom - 800 views - Eminem Venom
Те ключовете в двата мапа са еднакви в този случай, но да речем, че не са.
Както е коднато ако ключовете не са еднакви значи става дума за различни видеа. Маповете views и likes винаги ще съдържат еднакви ключове и ще са с еднаква дължина. Сортировката по likes няма как да се счупи.