Skip to content

1244. Design A Leaderboard #2

@altay9

Description

@altay9

https://leetcode.com/problems/design-a-leaderboard/

Bu soruda, bir skor tahtası dizayn etmemiz isteniyor.
addScore(playerId, score) methodu ile, bir oyuncunun skoru “artırılacak”
Eğer o oyuncuya dair hiç skor yoksa, direkt score değerinin kendisi konulacak.
Demek ki, bir HashMap<Integer, Integer> depo olarak iş görür.

top(K): methodunda, en yüksek skora sahip K sayıdaki sporcunun toplam skoru isteniyor.
Burada, depodaki listeyi, skora göre sıralamak gerekebilir.
reset(playerId): burada, id’si verilen sporcunun skorunun sıfırlanması isteniyor. Depodaki skor sıfırlanabilir.

Varsayılan kod:

class Leaderboard {

    public Leaderboard() {
        
    }
    
    public void addScore(int playerId, int score) {
        
    }
    
    public int top(int K) {
        
    }
    
    public void reset(int playerId) {
        
    }
}

image
image
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions