带有哈希图的拼字游戏代码

时间:2013-11-22 01:28:25

标签: hashmap

我不能为我的生活把这个问题想象出来。如果有人能指出我正确的方向?

根据单词列表,选择获得最高分的单词。

ScrabbleAssistant
+ getBestWord(List<String> options,
Map<Character, Integer> letterScores) : String
+ getScore(String word,
Map<Character, Integer> letterScores) : int

我们会给你一个单词列表和一个字典,告诉你单词中每个字母的价值是多少。你返回得分最高的单词。

1 个答案:

答案 0 :(得分:0)

我通常不会为他们做某人的功课,但这里是伪代码

maxScore = 0
bestWord = ""
for each word
    totalScore = 0
    for each letter in word
        totaScore = total + lookup value of letter from collection
    if totalScore > maxScore  
        maxScore = totalScore
        bestWord = word
相关问题