`{"id":"b0e78f97-3698-479f-9b32-1b05e6610e37","name":"Print Kpc","description":"<p>1. You are given a string str. The string str will contains numbers only, where each number stands for a key pressed on a mobile phone. 2. The following list is the key to characters map 0 -&gt; .; 1 -&gt; abc 2 -&gt; def 3 -&gt; ghi 4 -&gt; jkl 5 -&gt; mno 6 -&gt; pqrs 7 -&gt; tu 8 -&gt; vwx 9 -&gt; yz 3. Complete the body of printKPC function - without changing signature - to print the list of all words that could be produced by the keys in str. Use sample input and output to take idea about output. Note -&gt; The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.</p>","inputFormat":"<p>A string str</p>","outputFormat":"<p>Words that can be produced by pressed keys indictated by str in order hinted by Sample output</p>","constraints":"<p>0 &lt;= str.length &lt;= 10 str contains numbers only</p>","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nstring codes[] = {\".;\", \"abc\", \"def\", \"ghi\", \"jkl\", \"mno\", \"pqrs\", \"tu\", \"vwx\", \"yz\"};\r\n\r\nvoid printKPC(string ques, string asf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n string str;\r\n cin >> str;\r\n printKPC(str, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n public static void printKPC(String str, String asf) {\r\n \r\n }\r\n\r\n}"},"python":{"code":"def print_kpc(ques , asf):\r\n\t# write your code here\r\n\r\nstring = input().strip()\r\nprint_kpc(string , \"\");"}},"points":10,"difficulty":"easy","sampleInput":"78","sampleOutput":"tv\r\ntw\r\ntx\r\nuv\r\nuw\r\nux","questionVideo":"https://www.youtube.com/embed/HVCajDe2Uus","hints":[],"associated":[{"id":"159c8371-c691-4134-808c-8f75ffde439f","name":"(Print KPC) Do we need to put a base case in this Question ?","slug":"print-kpc-do-we-need-to-put-a-base-case-in-this-question","type":4},{"id":"995ade3c-d952-47ae-ac6c-3ea575840b17","name":"(Print KPC)What is the use of .charAt(index) function ?","slug":"print-kpc-what-is-the-use-of-charat-index-function","type":4},{"id":"9e6776eb-a2bd-4c9e-9bb0-73ba9c7c88a7","name":"(Print KPC) Where is the use of .substring() function?","slug":"print-kpc-where-is-the-use-of-substring-function","type":4},{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","slug":"print-kpc","type":3}],"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":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"bfb6be5d-323f-4d65-9e65-88d7cba030f4","name":"Print Kpc","slug":"print-kpc","type":1}],"next":{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","type":3,"slug":"print-kpc"},"prev":{"id":"08238ac3-64eb-4a1d-8b02-733026bc2563","name":"Print Subsequence","type":3,"slug":"print-subsequence"}}}`

# Print Kpc

<p>1. You are given a string str. The string str will contains numbers only, where each number stands for a key pressed on a mobile phone. 2. The following list is the key to characters map 0 -&gt; .; 1 -&gt; abc 2 -&gt; def 3 -&gt; ghi 4 -&gt; jkl 5 -&gt; mno 6 -&gt; pqrs 7 -&gt; tu 8 -&gt; vwx 9 -&gt; yz 3. Complete the body of printKPC function - without changing signature - to print the list of all words that could be produced by the keys in str. Use sample input and output to take idea about output. Note -&gt; The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.</p>

`{"id":"b0e78f97-3698-479f-9b32-1b05e6610e37","name":"Print Kpc","description":"<p>1. You are given a string str. The string str will contains numbers only, where each number stands for a key pressed on a mobile phone. 2. The following list is the key to characters map 0 -&gt; .; 1 -&gt; abc 2 -&gt; def 3 -&gt; ghi 4 -&gt; jkl 5 -&gt; mno 6 -&gt; pqrs 7 -&gt; tu 8 -&gt; vwx 9 -&gt; yz 3. Complete the body of printKPC function - without changing signature - to print the list of all words that could be produced by the keys in str. Use sample input and output to take idea about output. Note -&gt; The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.</p>","inputFormat":"<p>A string str</p>","outputFormat":"<p>Words that can be produced by pressed keys indictated by str in order hinted by Sample output</p>","constraints":"<p>0 &lt;= str.length &lt;= 10 str contains numbers only</p>","sampleCode":{"cpp":{"code":"#include <iostream>\r\nusing namespace std;\r\n\r\nstring codes[] = {\".;\", \"abc\", \"def\", \"ghi\", \"jkl\", \"mno\", \"pqrs\", \"tu\", \"vwx\", \"yz\"};\r\n\r\nvoid printKPC(string ques, string asf){\r\n // write your code here\r\n \r\n}\r\n\r\nint main(){\r\n string str;\r\n cin >> str;\r\n printKPC(str, \"\");\r\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n\r\n }\r\n\r\n public static void printKPC(String str, String asf) {\r\n \r\n }\r\n\r\n}"},"python":{"code":"def print_kpc(ques , asf):\r\n\t# write your code here\r\n\r\nstring = input().strip()\r\nprint_kpc(string , \"\");"}},"points":10,"difficulty":"easy","sampleInput":"78","sampleOutput":"tv\r\ntw\r\ntx\r\nuv\r\nuw\r\nux","questionVideo":"https://www.youtube.com/embed/HVCajDe2Uus","hints":[],"associated":[{"id":"159c8371-c691-4134-808c-8f75ffde439f","name":"(Print KPC) Do we need to put a base case in this Question ?","slug":"print-kpc-do-we-need-to-put-a-base-case-in-this-question","type":4},{"id":"995ade3c-d952-47ae-ac6c-3ea575840b17","name":"(Print KPC)What is the use of .charAt(index) function ?","slug":"print-kpc-what-is-the-use-of-charat-index-function","type":4},{"id":"9e6776eb-a2bd-4c9e-9bb0-73ba9c7c88a7","name":"(Print KPC) Where is the use of .substring() function?","slug":"print-kpc-where-is-the-use-of-substring-function","type":4},{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","slug":"print-kpc","type":3}],"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":"d341a7c9-1269-409c-b851-0bb512289544","name":"Recursion And Backtracking For Beginners","slug":"recursion-and-backtracking-for-beginners","type":0},{"id":"bfb6be5d-323f-4d65-9e65-88d7cba030f4","name":"Print Kpc","slug":"print-kpc","type":1}],"next":{"id":"f076b80f-ee54-4ae4-b1f0-8dd840103474","name":"PRINT KPC","type":3,"slug":"print-kpc"},"prev":{"id":"08238ac3-64eb-4a1d-8b02-733026bc2563","name":"Print Subsequence","type":3,"slug":"print-subsequence"}}}`

Editor

# Print Kpc

easy

1. You are given a string str. The string str will contains numbers only, where each number stands for a key pressed on a mobile phone. 2. The following list is the key to characters map 0 -> .; 1 -> abc 2 -> def 3 -> ghi 4 -> jkl 5 -> mno 6 -> pqrs 7 -> tu 8 -> vwx 9 -> yz 3. Complete the body of printKPC function - without changing signature - to print the list of all words that could be produced by the keys in str. Use sample input and output to take idea about output. Note -> The online judge can't force you to write the function recursively but that is what the spirit of question is. Write recursive and not iterative logic. The purpose of the question is to aid learning recursion and not test you.

## Constraints

0 <= str.length <= 10 str contains numbers only

## Format

A string str

### Output

Words that can be produced by pressed keys indictated by str in order hinted by Sample output

## 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;}78`

### 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;}tv tw tx uv uw ux```

Question Video

Discussions

Show Discussion

Related Resources