トラック


解き方
私の解き方
def solution(max_weight, specs, names):
    dict_specs = dict(specs)
    count = 1
    weight = 0
    
    for name in names:
        weight += int(dict_specs.get(name))
        if max_weight < weight:
            count += 1
            weight = int(dict_specs.get(name))

    return count
sol1
問題の収穫
知るところ
dict()関数
dict()関数のパラメータ変数はdicksherner(ハッシュ)型に変換されます.
weight += int(dict_specs.get(name))
get()関数でディクシャナ型変数のキー値の値を返します.
改善すべき点
私たちはPythonでハッシュ問題を解決する方法を学ぶべきだと思います.
ソース
https://school.programmers.co.kr/courses/13093/lessons/88768