Problem Statement
Your teacher proposes the following quick method of evaluating the correctness of the answer to an exam question. She writes down several distinct keywords she expects to find in a correct answer. Each keyword has a score associated with it. She then searches for each keyword in the studentâs answer. If she finds it, she adds the score of the keyword to the student's score. If she finds the keyword multiple times, she only adds its score once.
You are given a
Definition
- Class:
- AnswerEvaluation
- Method:
- getScore
- Parameters:
- String[], int[], String
- Returns:
- int
- Method signature:
- int getScore(String[] keywords, int[] scores, String answer)
- (be sure your method is public)
Constraints
- keywords will contain between 1 and 25 elements, inclusive.
- Each element of keywords will contain between 1 and 50 characters, inclusive.
- Each element of keywords will contain only lowercase letters ('a'-'z').
- The strings in keywords will be distinct.
- scores will contain the same number of elements as keywords.
- Each element of scores will be between 1 and 1000, inclusive.
- answer will contain between 1 and 50 characters, inclusive.
- answer will contain only lowercase letters ('a'-'z') and spaces, and will not contain leading/trailing spaces or double spaces.
Examples
{"red", "fox", "lazy", "dogs"}
{25, 25, 25, 25}
"the quick brown fox jumped over the lazy dog"
Returns: 50
We can find the words "fox" and "lazy" in the student's answer, but not the other two words. The final score will be 25 + 25 = 50.
{"red", "fox", "lazy", "dogs"}
{25, 25, 25, 25}
"highschool matches are nice"
Returns: 0
This answer is totally unrelated with the question. We can not find any of the keywords in it.
{"red", "fox", "lazy", "dogs"}
{1, 2, 3, 4}
"lazy lazy lazy lazy"
Returns: 3
The word "lazy" is present in the answer multiple times, but we should count its contribution to the final score once.
{"bet", "audio", "puzzle"}
{362, 856, 765}
"finish audio puzzle puzzle bet bet bet audio audio"
Returns: 1983
{"he"}
{355}
"famous he involved he he he he he occurs each he"
Returns: 355
{"proof", "cycle", "attributions", "building", "attractively"}
{691, 983, 616, 71, 162}
"origin attributions sometimes unable count indices"
Returns: 616
{"mental", "act", "decimal", "paragraph", "cryptic", "internalized", "needs", "predefined", "recursive", "starts", "test", "clock", "dematch", "matched", "hash", "steps", "guesswork", "allowable", "eastern", "domains"}
{443, 103, 201, 828, 951, 862, 409, 54, 727, 718, 427, 649, 68, 533, 661, 953, 924, 792, 791, 461}
"person eastern eastern"
Returns: 791
{"calculate", "together", "interested", "explain", "covers", "area", "distribution", "car", "mixtures", "passes", "choose", "set", "modify", "schemes", "its"}
{35, 116, 626, 744, 24, 526, 431, 573, 155, 797, 238, 362, 437, 903, 430}
"choose unwinding modify beauty brings olog explain"
Returns: 1419
{"involved", "knapsack", "runs", "soma", "frequency", "eliminate", "declared", "entered", "complicated", "they", "codomain", "weve", "larger", "with"}
{23, 403, 193, 725, 810, 370, 984, 960, 618, 632, 548, 620, 298, 659}
"larger repetitious insert"
Returns: 298
{"significant", "bitmap", "design", "rephrase", "defines", "nowadays", "discovered", "realistic", "area", "evaluate", "nuts", "equivalent", "updated", "chose"}
{611, 314, 324, 375, 852, 990, 628, 747, 565, 535, 121, 40, 451, 286}
"realistic pays same packets intermission signs cc"
Returns: 747
{"couple", "vector"}
{21, 598}
"couple record couple vector looking joe dooms ypos"
Returns: 619
{"variable", "matrix", "the", "nodes", "quite", "slowly"}
{694, 146, 715, 921, 121, 96}
"slowly matroids arrived fragmented better fewer"
Returns: 96
{"hear", "form", "treat", "unintended", "exists", "button", "alternative", "maneuvers", "doubt", "million", "trimmed", "ask", "wise", "operations", "rooks", "nor", "restriction", "procedure", "satisfactory", "dooms", "bottomleft", "resulted"}
{147, 481, 699, 63, 420, 34, 424, 862, 646, 535, 764, 691, 463, 747, 266, 490, 796, 886, 819, 721, 911, 198}
"employees button nor bottomleft form million hear"
Returns: 2598
{"granted"}
{585}
"awarded granted granted granted granted sentence"
Returns: 585
{"presses", "individuals", "words", "prefer", "misnomer", "weve", "plan", "eliminating", "taxonomy", "comprehension", "ji"}
{810, 580, 549, 902, 533, 917, 839, 593, 213, 300, 635}
"losing optimized"
Returns: 0
{"allow", "guidance", "defined", "distribution", "useful", "seated", "forced", "omit", "breaking", "integer", "right", "intuitively", "down", "contemplating", "additional", "article", "albeit", "removing", "remind", "button", "tackling", "concentric", "scenes"}
{693, 616, 328, 587, 970, 547, 615, 311, 20, 867, 956, 916, 220, 543, 899, 170, 857, 493, 511, 393, 327, 690, 27}
"remind intuitively simulating forced albeit"
Returns: 2899
{"more", "students", "lining", "feasible", "nasty", "encouraging"}
{452, 497, 146, 361, 473, 293}
"parent years"
Returns: 0
{"programmer", "definecreate", "collection", "minimumcut", "follows", "moving", "instinct", "consuming", "involves", "addressed", "context", "conclude", "depth", "field", "subproblems", "knowledge", "actually", "selection", "ga", "against", "blocks", "reconsider", "already", "evaluator", "analysis"}
{166, 981, 667, 782, 69, 236, 943, 391, 701, 882, 694, 299, 824, 662, 46, 586, 602, 128, 612, 923, 90, 945, 119, 948, 551}
"selection changes instinct blocks involves types"
Returns: 1862
{"educated", "strength", "lace", "upcoming", "at", "knapsack", "fragmented"}
{218, 79, 92, 54, 49, 370, 640}
"appends youd knapsack upcoming educated lace keys"
Returns: 734
{"separating", "filled", "dissect", "items", "very", "lose", "decimal", "researched", "spending", "have", "at", "ease", "meaning", "storage"}
{186, 282, 721, 846, 270, 768, 2, 247, 896, 960, 14, 655, 487, 95}
"lose have skills corresponds researched separating"
Returns: 2161
{"cg", "doubly", "allocating", "abstraction", "help", "afford", "implementation", "editor", "wrote", "reasonable", "stating", "intended", "carries", "sufficient", "particularly", "represented", "lies", "scenes", "medaltable", "clarification", "persons", "represents", "keeping", "skilled", "dense"}
{303, 67, 684, 862, 138, 179, 602, 301, 324, 45, 368, 8, 402, 718, 102, 897, 439, 362, 129, 271, 276, 392, 546, 636, 217}
"opportunities"
Returns: 0
{"handling", "converse", "teamphoto", "gold", "millions", "compare", "computed", "song", "pages", "stacks", "helps", "substructure", "knights", "slumber", "introduction", "ascending", "permute", "tactics", "bigger", "levels", "really", "warning", "would", "fill"}
{253, 897, 98, 776, 529, 77, 445, 870, 308, 617, 913, 239, 657, 644, 467, 285, 718, 506, 779, 908, 42, 675, 245, 868}
"styles millions through contents permute song gold"
Returns: 2893
{"power", "that", "wouldnt", "catalog", "breathe", "garbage", "deststate", "change", "powerful", "keen", "ypos", "cn", "named", "holiday", "had"}
{602, 218, 204, 829, 818, 676, 139, 573, 408, 818, 698, 13, 629, 866, 461}
"wouldnt accurate complain holiday wouldnt defines"
Returns: 1070
{"deque", "nucleic", "provided", "respect", "breadth", "progress", "include", "coders", "solvers"}
{110, 993, 330, 532, 394, 149, 179, 881, 825}
"those include deque legality include include want"
Returns: 289
{"equal", "flow", "beloved", "intersections", "without", "approximately", "treats", "knows", "cents", "approximation", "readers", "much", "years", "acost", "leiserson"}
{457, 852, 351, 334, 26, 926, 546, 753, 64, 800, 356, 990, 787, 919, 474}
"looks flow much bioscore without eval treats pfs"
Returns: 2414
{"dauntingly", "analysis", "key", "arena", "matrix", "thought"}
{946, 376, 900, 696, 480, 328}
"matrix otherwise analysis"
Returns: 856
{"approaches", "group", "reverse", "consistency", "some", "minds", "flood", "situation", "finite", "remind", "again", "poem", "formed", "compute", "restrictions", "carefully"}
{967, 978, 45, 267, 852, 257, 213, 575, 561, 205, 415, 569, 34, 706, 501, 805}
"flood compute converse approaches carefully"
Returns: 2691
{"regular", "programmatically", "language", "satisfying", "drills"}
{598, 722, 755, 104, 654}
"programmatically satisfying legality satisfying"
Returns: 826
{"optimization", "reference"}
{244, 911}
"optimization closer optimization reference lot ask"
Returns: 1155
{"om", "domains", "check", "critique", "combine", "proportional", "amount", "let"}
{341, 452, 922, 727, 644, 181, 943, 201}
"looking noyes amount laid triplecoding amount city"
Returns: 943
{"error", "chug", "maintaining", "unlikely"}
{567, 446, 124, 346}
"maintaining error error max unlikely topcoders oh"
Returns: 1037
{"information", "interface", "cs", "fairworkload", "junction", "perform", "feels", "youre", "current", "java", "connect", "describes", "leiserson", "decimal"}
{909, 190, 965, 450, 677, 108, 988, 909, 821, 758, 526, 910, 141, 430}
"interface algo string know deletions field fastest"
Returns: 190
{"me", "parse", "advanced", "bell", "flawed", "unlikely", "leads", "techniques", "familiar"}
{1, 557, 46, 709, 625, 889, 334, 856, 83}
"intentionally primitives frequency familiar submit"
Returns: 83
{"sinks", "procedural", "more", "configurations", "modeled", "fewer", "five", "simulation", "impossible", "affected", "happy", "presses", "tactical", "lets", "consequently", "assigned", "studied", "seemingly", "comprehensive", "generate", "feels", "ultimately", "ability", "indefinitely"}
{930, 258, 385, 410, 432, 615, 802, 345, 1000, 774, 239, 806, 312, 272, 362, 416, 554, 895, 256, 782, 713, 126, 751, 996}
"lets wrap affected columns tactical modeled happy"
Returns: 2029
{"contain", "construct", "scientists", "usage", "ints", "cols", "several", "must", "ins", "formally"}
{603, 791, 790, 556, 593, 455, 183, 114, 803, 580}
"ints fundamental defining achieved several edges"
Returns: 776
{"instincts", "discipline", "outdegrees", "timepath", "contrast", "teach", "matches", "definitely", "pc", "illustrated", "relabel", "assumes", "forward", "resides", "criteria", "plan", "initially", "oriented", "encyclopedic", "gg", "side", "cycle", "poor", "applicable", "program"}
{687, 425, 158, 159, 665, 835, 444, 21, 552, 263, 198, 426, 945, 558, 877, 658, 517, 859, 431, 424, 975, 832, 648, 725, 261}
"outdegrees clash employees applicable reality poor"
Returns: 1531
{"off", "perspective", "empty", "values", "occurring", "locate", "predetermined", "yourself", "transform", "irrelevant", "email"}
{839, 761, 453, 684, 183, 85, 321, 923, 150, 723, 29}
"irrelevant calculated remain but ritual email else"
Returns: 752
{"subbullets", "closest", "constraints", "sigh", "obtain", "numeric", "traversal", "board", "help"}
{892, 524, 905, 743, 488, 486, 678, 823, 780}
"traversal satisfied sigh constraints board ready"
Returns: 3149
{"electronic", "saying", "conceive", "efficiently", "simulated", "have", "you", "spaces", "satisfying", "total", "cries", "successive", "encourages", "mistake", "person", "made", "extreme", "thing", "sequential", "react", "most", "road", "default", "money", "assumed"}
{253, 863, 956, 850, 437, 368, 538, 780, 942, 598, 484, 57, 508, 46, 173, 100, 195, 477, 7, 620, 427, 289, 100, 42, 556}
"assumed encourages most cries person manufactured"
Returns: 2148
{"time", "splitting", "chained", "result", "miner", "rarely", "understand", "branch", "permissiontree"}
{574, 395, 512, 964, 651, 367, 161, 743, 295}
"chained managers enable knapsack defined result"
Returns: 1476
{"acost", "modeled", "click", "applying", "search", "context", "need", "mainly", "off", "populated", "tie", "clarify", "centered", "this", "current"}
{31, 568, 916, 42, 236, 9, 258, 756, 194, 135, 965, 650, 634, 569, 58}
"context applying click computer basis"
Returns: 967
{"environment", "infinitely", "dark", "computer", "problems", "greatest", "intended", "competing", "foundpath", "almost", "efficiently", "act", "allocate", "transported", "expected", "three", "alone", "along", "probably", "happens", "dumb"}
{429, 334, 308, 776, 57, 61, 178, 40, 42, 144, 51, 623, 674, 963, 368, 372, 917, 57, 961, 847, 382}
"expected alone core way alone wordfind greatest"
Returns: 1346
{"strategically", "expect", "previous", "transforming", "approximate", "applicable", "prewriting", "separated", "writeup", "chess", "recall", "advantages", "claim", "over", "slowest", "later", "style", "purchase"}
{132, 255, 135, 942, 757, 800, 14, 444, 993, 504, 159, 560, 864, 727, 230, 24, 467, 634}
"purchase claim lookup purchase claim next dynamic"
Returns: 1498
{"constitutes", "minds", "reals"}
{650, 226, 281}
"constitutes used reals index reals minds often if"
Returns: 1157
{"imagine", "kit", "written", "chug", "involved", "guide", "level", "gives", "cb", "from", "typing", "blank", "ordering", "sequences", "global", "teller"}
{516, 825, 417, 330, 481, 878, 208, 668, 598, 483, 656, 407, 701, 647, 314, 41}
"gate newcost typing teller written global teller"
Returns: 1428
{"lines", "chase", "algebra", "my", "taking", "flood", "invitational", "circle", "pass", "fall"}
{197, 801, 412, 958, 249, 943, 561, 308, 72, 975}
"gain lots invitational pass lines chase flood pass"
Returns: 2574
{"coffee", "planning"}
{502, 773}
"wednesday proponent coffee coffee planning cup"
Returns: 1275
{"uses", "extremities", "becomes", "view", "realworld", "indexed", "mind", "considered", "both", "oevlogv", "assignment", "those", "attention"}
{100, 669, 155, 756, 93, 399, 93, 634, 744, 383, 531, 88, 755}
"warning extremities becomes both oevlogv"
Returns: 1951
{"fifteen", "writer", "championship", "cancel"}
{63, 352, 686, 126}
"writer writer ok championship championship hurt"
Returns: 1038
{"nonrandom"}
{836}
"dissect"
Returns: 0
{"programmatically", "follow", "eyes", "asks", "they", "consisted", "predicate", "supplies", "permute", "cs", "shortcut", "lstwherei"}
{328, 986, 10, 701, 212, 854, 165, 729, 305, 254, 627, 16}
"automatically predicate follow calculations nphard"
Returns: 1151
{"priority", "deststate", "classroom", "underbelly", "indices", "nothing", "pathcapacity", "besides", "affected", "presides", "min", "illustrate", "tricks", "empty", "green", "complete", "fit", "reached", "ambiguities", "decide"}
{168, 911, 542, 80, 280, 316, 77, 80, 368, 588, 889, 93, 815, 213, 259, 222, 710, 388, 486, 592}
"believe dewey needed besides refine bigger"
Returns: 80
{"function", "solution", "ascii", "simplicity", "occurs", "watch", "sides", "likely", "elegant", "gnarly", "reaches", "accessed", "simplex", "plays"}
{906, 410, 573, 590, 76, 551, 704, 517, 213, 478, 275, 138, 549, 881}
"clarifies replace man watch objective howmanyint"
Returns: 551
{"choices", "obedient", "predicate", "bar", "hours", "underbelly", "target", "hopefully", "clarity", "elegant", "expecting", "reasonable", "view", "clock", "explained", "typing", "framework", "depending", "trees", "variations", "oevlogv", "serving", "vertical", "tree", "pulled"}
{601, 705, 343, 847, 309, 473, 747, 601, 310, 634, 131, 376, 549, 570, 867, 255, 95, 499, 790, 281, 576, 358, 15, 6, 75}
"take formed algorithmic explained unmatched well"
Returns: 867
{"image"}
{70}
"comparing image cents painless my experiment image"
Returns: 70
{"classify", "employees", "stable", "together", "trying", "chess", "introduction", "finals", "shared", "looking", "expecting", "unreachable", "team", "root", "took", "finished", "presides", "thus", "behaves", "composed", "except", "mean", "game"}
{277, 229, 562, 412, 809, 444, 313, 947, 697, 516, 538, 502, 761, 512, 341, 249, 335, 804, 668, 301, 240, 597, 71}
"finished expecting fit centers omit encyclopedic"
Returns: 787
{"filing", "excludes", "specification", "configuration", "determined", "fingers", "trying", "inexperienced", "formation", "exhausted", "rock", "everywhere", "powerful", "aspects"}
{600, 431, 704, 757, 916, 522, 195, 554, 407, 649, 144, 276, 658, 682}
"aspects bruteforce decided reverse important cars"
Returns: 682
{"give", "coding", "approached", "fundamental", "maximize"}
{116, 469, 102, 947, 947}
"approached maximize"
Returns: 1049
{"fall", "pix", "required", "editorial", "present", "lists", "workload", "minimal", "accordingly", "nowhere", "deals", "tired", "contested", "prefer", "owns", "way", "sudden", "dissect", "composition", "satisfy", "formal", "method", "individual", "explanatory", "tend"}
{202, 57, 363, 986, 737, 548, 367, 769, 526, 447, 164, 182, 107, 923, 824, 180, 585, 515, 71, 583, 311, 292, 575, 975, 580}
"original radical stores sustainably after amid my"
Returns: 0
{"benchmark", "also", "updated", "speedy", "who", "trick", "came", "however", "blocks", "property", "charge", "never", "construct", "agrees", "for", "eliminate", "free", "programs", "position", "contrast", "easier", "restrict", "iterating"}
{638, 8, 784, 465, 571, 285, 594, 824, 120, 757, 363, 341, 667, 371, 824, 97, 187, 378, 77, 282, 867, 952, 81}
"charge five dark mined"
Returns: 363
{"opportunities", "well", "pull", "deal", "need", "cells", "accumulate", "skeleton", "lies", "predisposed", "graphs", "nonmutatable", "connect", "axis", "ambiguities", "started", "offered", "paralyzed", "inputs", "sum"}
{808, 620, 874, 924, 854, 455, 966, 181, 238, 960, 871, 66, 530, 113, 618, 193, 896, 562, 662, 273}
"deterministic connect starts allocate wrong cables"
Returns: 530
{"technique", "chessmetric", "passed", "itself", "macros", "maintains", "pass", "fromnext", "calculates", "disprove"}
{104, 415, 157, 688, 391, 557, 762, 451, 717, 413}
"passed maintains maintains pass disprove ever pass"
Returns: 1889
{"can", "language", "rails", "max"}
{741, 179, 987, 116}
"consisting max covers im quote max"
Returns: 116
{"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "x", "y", "z"}
{1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000, 1000}
"a b c d e f g h i j k l m n o p q r s t u v x y z"
Returns: 25000
{"war" }
{100 }
"warwarwarwar"
Returns: 0
{"a", "b" }
{2, 2 }
"ab"
Returns: 0
{"ab" }
{100 }
"aba"
Returns: 0
{"a", "ab", "gh", "z", "y", "yz", "ll", "l", "lm", "pp", "qqrsss" }
{1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 997 }
"ab y yz yz llm qqrssss ppll l lppl p q qrs s"
Returns: 178
{"blada" }
{9 }
"dupablada hehe"
Returns: 0
{"bc" }
{1 }
"abc"
Returns: 0
{"dupa" }
{1 }
"dupaa"
Returns: 0
{"a" }
{5 }
"aa"
Returns: 0
{"a" }
{1 }
"aa"
Returns: 0
{"red", "fox", "lazy", "dogs" }
{25, 25, 25, 25 }
"the quick brown fox jumped over the lazy dog"
Returns: 50
{"fox" }
{1 }
"foxs"
Returns: 0
{"a" }
{1 }
"aaa aaa"
Returns: 0
{"b" }
{10 }
"ab"
Returns: 0
{"aa" }
{1 }
"aaaa"
Returns: 0
{"a", "b", "ab" }
{1, 1, 1 }
"ab"
Returns: 1
{"red", "fox", "lazy", "dogs" }
{1, 2, 3, 4 }
"lazy lazy lazy lazy"
Returns: 3
{"red", "fox", "lazy", "dogs" }
{25, 25, 25, 25 }
"the quick brown foxjumped over the lazy dog"
Returns: 25
{"carl" }
{10 }
"scarls stays"
Returns: 0
{"a", "b" }
{1, 1 }
"aa bb"
Returns: 0
{"red", "fox", "lazy", "dogs" }
{25, 25, 25, 25 }
"reddddd"
Returns: 0
{"fx" }
{20 }
"fxx"
Returns: 0
{"a", "ab" }
{1, 2 }
"ab"
Returns: 2
{"b", "ab" }
{1, 2 }
"ab"
Returns: 2
{"ab", "b" }
{20, 20 }
"ab"
Returns: 20
{"a", "ab" }
{20, 20 }
"ab"
Returns: 20