{"id":"f38f68f4-8de5-48ef-b0f3-50a28a29d89a","name":"Faulty Keyboard","description":"1. Your friend is typing his name into a faulty keyboard. \r\n2. Sometimes, when typing a character 'c', the key might get long pressed, and the character will be typed 1 or more times.\r\n3. You examine the typed characters of the keyboard. Return 'True' if it is possible that it was your friends name, with some characters (possibly none) being long pressed.","inputFormat":"name = \"mannu\", typed = \"mmaannu\"\r\nname = \"sumeet\", typed = \"sumeet\"\r\nname = \"shree\", typed = \"sshrre\"","outputFormat":"true\r\n[Explanation: 'm' and 'a' in 'mannu' were long pressed.]\r\ntrue\r\n[Explanation: It's not necessary to long press any character.]\r\nfalse\r\n[Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.]","constraints":"1. 1 &lt;= name.length &lt;= 1000\r\n2. 1 &lt;= typed.length &lt;= 1000\r\n3. name and typed contain only lowercase English letters.","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool isPossible(string name, string typed) {\n // Write your code here\n}\n\nint main(){\n string name, typed;\n cin>>name;\n cin>>typed;\n bool res = isPossible(name, typed);\n if(res){\n cout<<\"true\";\n }else{\n cout<<\"false\";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~~~~~~~~~~~User Section~~~~~~~~~~~~~~~~~~~~~\r\n\r\n public static boolean isPossible(String name, String typed) {\r\n // Write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~~~~~~~~Input Management~~~~~~~~~~~~~~~~~~~\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n \r\n String name = scn.next();\r\n String typed = scn.next();\r\n\r\n boolean res = isPossible(name, typed);\r\n\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":"def main():\r\n pass\r\n\r\nif __name__ == '__main__':\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"shree\r\nsshhrreee","sampleOutput":"true","questionVideo":"https://www.youtube.com/embed/738Dy3D-q-E?end=168","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":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"645b6f67-6c9b-47a1-95c1-92ed9c2318f0","name":"Faulty Keyboard","slug":"faulty-keyboard","type":1}],"next":{"id":"7478c976-0060-4645-88cc-e04903024d3d","name":"Faulty Keyboard","type":3,"slug":"faulty-keyboard"},"prev":null}}

Faulty Keyboard

1. Your friend is typing his name into a faulty keyboard. 2. Sometimes, when typing a character 'c', the key might get long pressed, and the character will be typed 1 or more times. 3. You examine the typed characters of the keyboard. Return 'True' if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

{"id":"f38f68f4-8de5-48ef-b0f3-50a28a29d89a","name":"Faulty Keyboard","description":"1. Your friend is typing his name into a faulty keyboard. \r\n2. Sometimes, when typing a character 'c', the key might get long pressed, and the character will be typed 1 or more times.\r\n3. You examine the typed characters of the keyboard. Return 'True' if it is possible that it was your friends name, with some characters (possibly none) being long pressed.","inputFormat":"name = \"mannu\", typed = \"mmaannu\"\r\nname = \"sumeet\", typed = \"sumeet\"\r\nname = \"shree\", typed = \"sshrre\"","outputFormat":"true\r\n[Explanation: 'm' and 'a' in 'mannu' were long pressed.]\r\ntrue\r\n[Explanation: It's not necessary to long press any character.]\r\nfalse\r\n[Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.]","constraints":"1. 1 &lt;= name.length &lt;= 1000\r\n2. 1 &lt;= typed.length &lt;= 1000\r\n3. name and typed contain only lowercase English letters.","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool isPossible(string name, string typed) {\n // Write your code here\n}\n\nint main(){\n string name, typed;\n cin>>name;\n cin>>typed;\n bool res = isPossible(name, typed);\n if(res){\n cout<<\"true\";\n }else{\n cout<<\"false\";\n }\n}"},"java":{"code":"import java.util.*;\r\n\r\npublic class Main {\r\n\r\n // ~~~~~~~~~~~~~~~~~~~~~User Section~~~~~~~~~~~~~~~~~~~~~\r\n\r\n public static boolean isPossible(String name, String typed) {\r\n // Write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~~~~~~~~Input Management~~~~~~~~~~~~~~~~~~~\r\n\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n \r\n String name = scn.next();\r\n String typed = scn.next();\r\n\r\n boolean res = isPossible(name, typed);\r\n\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":"def main():\r\n pass\r\n\r\nif __name__ == '__main__':\r\n main()"}},"points":10,"difficulty":"easy","sampleInput":"shree\r\nsshhrreee","sampleOutput":"true","questionVideo":"https://www.youtube.com/embed/738Dy3D-q-E?end=168","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":"35f2cfb0-6f25-4967-b0c9-92f2384b9260","name":"Arrays And Strings For Intermediate","slug":"arrays-and-strings-for-intermediate-732","type":0},{"id":"645b6f67-6c9b-47a1-95c1-92ed9c2318f0","name":"Faulty Keyboard","slug":"faulty-keyboard","type":1}],"next":{"id":"7478c976-0060-4645-88cc-e04903024d3d","name":"Faulty Keyboard","type":3,"slug":"faulty-keyboard"},"prev":null}}
plane

Editor


Loading...

Faulty Keyboard

easy

1. Your friend is typing his name into a faulty keyboard. 2. Sometimes, when typing a character 'c', the key might get long pressed, and the character will be typed 1 or more times. 3. You examine the typed characters of the keyboard. Return 'True' if it is possible that it was your friends name, with some characters (possibly none) being long pressed.

Constraints

1. 1 <= name.length <= 1000 2. 1 <= typed.length <= 1000 3. name and typed contain only lowercase English letters.

Format

Input

name = "mannu", typed = "mmaannu" name = "sumeet", typed = "sumeet" name = "shree", typed = "sshrre"

Output

true [Explanation: 'm' and 'a' in 'mannu' were long pressed.] true [Explanation: It's not necessary to long press any character.] false [Explanation: 'e' must have been pressed twice, but it wasn't in the typed output.]

Example

Sample Input

shree sshhrreee

Sample Output

true

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode