Skip to content
DeepForgeby svx
All problems
EasyNLPnlp-381

Greedy Decode Argmax Index

Problem

Greedy decoding picks the token with the highest score, breaking ties toward the smallest index.

Given the score list, return the chosen index.

Hint

Use a strict comparison to keep the earliest index on ties.

Test cases

case 1
in: [[0.1,0.5,0.4]]
expected: 1
case 2
in: [[1,1,1]]
expected: 0
case 3
in: [[-1,-2]]
expected: 0
Starter codePython
def greedy_argmax_decode(scores):
    # Your code here
    pass

3 test cases · run your code against them in the editor