O03

Top Value Customers

Junior Level Candidate
Target Time: 15 - 20 Minutes
Type: ARRAY

Problem Statement & Objective

Analyze an e-commerce customer transaction graph to find top revenue clusters.

Function Signature (Python)

top_value_customers(orders: list, k: int) -> list[str]

Input & Output Contract

Output Rule:En fazla k elemanlı string dizisi. Müşteri sayısı k'dan azsa TÜM müşteriler döner. Sipariş listesi boşsa [].

System Constraints

0 <= siparisler.length <= 10^5
1 <= k <= 10^3
tutarlar pozitif tam sayı
müşteri adları küçük ASCII harf

Example Execution Walkthrough

siparisler = [["ali",100], ["zeynep",300], ["ali",250], ["mert",300], ["can",50]]
toplamlar: ali=350, zeynep=300, mert=300, can=50
azalan tutar: ali(350), sonra zeynep(300) ve mert(300) EŞİT -> alfabetik: mert, zeynep
k=3 -> cevap: ["ali", "mert", "zeynep"]

Example Test Scenarios (3)

Example 1
Input:[[["ali",100],["zeynep",300],["ali",250],["mert",300],["can",50]],3]
Expected Output:["ali","mert","zeynep"]
Example 2: İki Müşteri Toplamı
Input:[[["kerem",500],["asli",400],["kerem",100]],2]
Expected Output:["kerem","asli"]
Example 3: Eşit Tutar Alfabetik Sıra
Input:[[["ali",50],["veli",50]],1]
Expected Output:["ali"]
Loading Python Editor...
Input Parameters
[
  [
    [
      "ali",
      100
    ],
    [
      "zeynep",
      300
    ],
    [
      "ali",
      250
    ],
    [
      "mert",
      300
    ],
    [
      "can",
      50
    ]
  ],
  3
]
Expected Output
[
  "ali",
  "mert",
  "zeynep"
]