`{"id":"f13fafbc-d15a-4c2d-b7b0-3e3b4a5bd5dd","name":"Max Score","description":"1. You are given a list of words, a list of alphabets(might be repeating) and score of every alphabet \r\n from a to z.\r\n2. You have to find the maximum score of any valid set of words formed by using the given \r\n alphabets.\r\n3. A word can not be used more than one time.\r\n4. Each alphabet can be used only once. \r\n5. It is not necessary to use all the given alphabets.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A number N representing number of words\r\nN space separated strings\r\nA number M representing number of alphabets(might be repeating)\r\nM space separated characters\r\n26 numbers representing score of unique alphabets from a to z.","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= N &lt;= 14\r\n1 &lt;= length of word &lt;= 15\r\n1 &lt;= M &lt;= 100\r\n1 &lt;= Value of score &lt;= 10\r\n","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String[] words, int[] farr, int[] score, int idx) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint nofWords = scn.nextInt();\r\n\t\tString[] words = new String[nofWords];\r\n\t\tfor(int i = 0 ; i < words.length; i++) {\r\n\t\t\twords[i] = scn.next();\r\n\t\t}\r\n\t\tint nofLetters = scn.nextInt();\r\n\t\tchar[] letters = new char[nofLetters];\r\n\t\tfor (int i = 0; i < letters.length; i++) {\r\n\t\t\tletters[i] = scn.next().charAt(0);\r\n\t\t}\r\n\t\tint[] score = new int[26];\r\n\t\tfor (int i = 0; i < score.length; i++) {\r\n\t\t\tscore[i] = scn.nextInt();\r\n\t\t}\r\n\t\tif (words == null || words.length == 0 || letters == null || letters.length == 0 || score == null\r\n\t\t\t\t|| score.length == 0) {\r\n\t\t\tSystem.out.println(0);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tint[] farr = new int[score.length];\r\n\t\tfor (char ch : letters) {\r\n\t\t\tfarr[ch - ''a'']++;\r\n\t\t}\r\n\t\tSystem.out.println(solution(words, farr, score, 0));\r\n\r\n\t}\r\n}"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"4\r\ndog cat dad good\r\n9\r\na b c d d d g o o\r\n1 0 9 5 0 0 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0","sampleOutput":"23","questionVideo":"https://www.youtube.com/embed/XtmW3a8Q9M4?start=0&end=202","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"44ae5d41-3f83-49cb-abe0-05c5cd262839","name":"Max Score","slug":"max-score","type":1}],"next":{"id":"28e342bf-ae87-462a-aa5e-faa6eb4dcfa1","name":"Max Score MCQ","type":0,"slug":"max-score-mcq"},"prev":{"id":"1a943abe-d658-4054-80a4-6416dd592006","name":"N queens -Branch and bound MCQ","type":0,"slug":"n-queens-branch-and-bound-mcq"}}}`

# Max Score

1. You are given a list of words, a list of alphabets(might be repeating) and score of every alphabet from a to z. 2. You have to find the maximum score of any valid set of words formed by using the given alphabets. 3. A word can not be used more than one time. 4. Each alphabet can be used only once. 5. It is not necessary to use all the given alphabets. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

`{"id":"f13fafbc-d15a-4c2d-b7b0-3e3b4a5bd5dd","name":"Max Score","description":"1. You are given a list of words, a list of alphabets(might be repeating) and score of every alphabet \r\n from a to z.\r\n2. You have to find the maximum score of any valid set of words formed by using the given \r\n alphabets.\r\n3. A word can not be used more than one time.\r\n4. Each alphabet can be used only once. \r\n5. It is not necessary to use all the given alphabets.\r\n\r\nNote -> Check out the question video and write the recursive code as it is intended without \r\n changing signature. The judge can't force you but intends you to teach a concept.","inputFormat":"A number N representing number of words\r\nN space separated strings\r\nA number M representing number of alphabets(might be repeating)\r\nM space separated characters\r\n26 numbers representing score of unique alphabets from a to z.","outputFormat":"Check the sample ouput and question video.","constraints":"1 &lt;= N &lt;= 14\r\n1 &lt;= length of word &lt;= 15\r\n1 &lt;= M &lt;= 100\r\n1 &lt;= Value of score &lt;= 10\r\n","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n\tpublic static int solution(String[] words, int[] farr, int[] score, int idx) {\r\n\t\t//write your code here\r\n\t\t\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tpublic static void main(String[] args) {\r\n\r\n\t\tScanner scn = new Scanner(System.in);\r\n\t\tint nofWords = scn.nextInt();\r\n\t\tString[] words = new String[nofWords];\r\n\t\tfor(int i = 0 ; i < words.length; i++) {\r\n\t\t\twords[i] = scn.next();\r\n\t\t}\r\n\t\tint nofLetters = scn.nextInt();\r\n\t\tchar[] letters = new char[nofLetters];\r\n\t\tfor (int i = 0; i < letters.length; i++) {\r\n\t\t\tletters[i] = scn.next().charAt(0);\r\n\t\t}\r\n\t\tint[] score = new int[26];\r\n\t\tfor (int i = 0; i < score.length; i++) {\r\n\t\t\tscore[i] = scn.nextInt();\r\n\t\t}\r\n\t\tif (words == null || words.length == 0 || letters == null || letters.length == 0 || score == null\r\n\t\t\t\t|| score.length == 0) {\r\n\t\t\tSystem.out.println(0);\r\n\t\t\treturn;\r\n\t\t}\r\n\t\tint[] farr = new int[score.length];\r\n\t\tfor (char ch : letters) {\r\n\t\t\tfarr[ch - ''a'']++;\r\n\t\t}\r\n\t\tSystem.out.println(solution(words, farr, score, 0));\r\n\r\n\t}\r\n}"},"python":{"code":""}},"points":10,"difficulty":"hard","sampleInput":"4\r\ndog cat dad good\r\n9\r\na b c d d d g o o\r\n1 0 9 5 0 0 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0","sampleOutput":"23","questionVideo":"https://www.youtube.com/embed/XtmW3a8Q9M4?start=0&end=202","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"082986ae-d618-4a59-9ab3-6d79056679a4","name":"Recursion and Backtracking For Intermediate","slug":"recursion-and-backtracking-for-intermediate-330","type":0},{"id":"44ae5d41-3f83-49cb-abe0-05c5cd262839","name":"Max Score","slug":"max-score","type":1}],"next":{"id":"28e342bf-ae87-462a-aa5e-faa6eb4dcfa1","name":"Max Score MCQ","type":0,"slug":"max-score-mcq"},"prev":{"id":"1a943abe-d658-4054-80a4-6416dd592006","name":"N queens -Branch and bound MCQ","type":0,"slug":"n-queens-branch-and-bound-mcq"}}}`

Editor

# Max Score

hard

1. You are given a list of words, a list of alphabets(might be repeating) and score of every alphabet from a to z. 2. You have to find the maximum score of any valid set of words formed by using the given alphabets. 3. A word can not be used more than one time. 4. Each alphabet can be used only once. 5. It is not necessary to use all the given alphabets. Note -> Check out the question video and write the recursive code as it is intended without changing signature. The judge can't force you but intends you to teach a concept.

## Constraints

1 <= N <= 14 1 <= length of word <= 15 1 <= M <= 100 1 <= Value of score <= 10

## Format

### Input

A number N representing number of words N space separated strings A number M representing number of alphabets(might be repeating) M space separated characters 26 numbers representing score of unique alphabets from a to z.

### Output

Check the sample ouput and question video.

## Example

Sample Input

```.css-23h8hz{color:inherit;font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;}4 dog cat dad good 9 a b c d d d g o o 1 0 9 5 0 0 3 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0```

### Sample Output

`.css-3oaykw{color:var(--chakra-colors-active-primary);font-size:0.875rem;line-height:1.125rem;letter-spacing:0.016rem;font-weight:var(--chakra-fontWeights-normal);white-space:pre-wrap;font-family:Monospace;}23`

Question Video

Discussions

Show Discussion

Related Resources