{"id":"eceafea9-cd62-4623-95e8-f98d69b47d00","name":"Check If Word Is Valid After Insertion","description":"1. You are given a string s determine if it is valid or not.\r\n2. A valid string is a string that can be created by inserting abc at any index any number of times.\r\n\r\nExample:\r\naabcbc can be created \r\n\"\" -> \"<span style=\"text-decoration: underline;\">abc</span>\" -> \"a<span style=\"text-decoration: underline;\">abc</span>bc\"\r\n\r\nwhile it is impossible to create abccba.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1: s consists of letters 'a', 'b', and 'c' only.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\n bool isValid(string S) {\n // write your code here\n }\n\nint main(){ \n \n string s;\n cin>>s;\n bool result =isValid(s);\n if(result == 1){\n cout<<\"true\"<<endl;\n } if(result==0){\n cout<< \"false\"<<endl;\n }\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n public static boolean isValid(String S) {\r\n // write your code here\r\n\r\n return false;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader read = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n boolean result = isValid(read.readLine());\r\n System.out.println(result);\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcbc","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/ynuC2fGlwUw","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":"8c6022a5-8654-4226-918f-8110af738bd4","name":"Stacks For Intermediate","slug":"stacks-for-intermediate-688","type":0},{"id":"a6c59060-b618-424c-8e7d-36a94b77aae2","name":"Check If Word Is Valid After Insertion","slug":"check-if-word-is-valid-after-insertion","type":1}],"next":{"id":"1150b0b9-7b77-4d5e-be02-1904cf847c76","name":"Check If Word Is Valid After Insertion MCQ","type":0,"slug":"check-if-word-is-valid-after-insertion-mcq"},"prev":{"id":"f6df04d0-153f-42c9-a266-8a57eb389d6d","name":"Max-stack","type":3,"slug":"max-stack"}}}

Check If Word Is Valid After Insertion

1. You are given a string s determine if it is valid or not. 2. A valid string is a string that can be created by inserting abc at any index any number of times. Example: aabcbc can be created "" -> "<span style="text-decoration: underline;">abc</span>" -> "a<span style="text-decoration: underline;">abc</span>bc" while it is impossible to create abccba.

{"id":"eceafea9-cd62-4623-95e8-f98d69b47d00","name":"Check If Word Is Valid After Insertion","description":"1. You are given a string s determine if it is valid or not.\r\n2. A valid string is a string that can be created by inserting abc at any index any number of times.\r\n\r\nExample:\r\naabcbc can be created \r\n\"\" -> \"<span style=\"text-decoration: underline;\">abc</span>\" -> \"a<span style=\"text-decoration: underline;\">abc</span>bc\"\r\n\r\nwhile it is impossible to create abccba.","inputFormat":"Input is managed for you","outputFormat":"Output is managed for you","constraints":"1: s consists of letters 'a', 'b', and 'c' only.","sampleCode":{"cpp":{"code":"#include <bits/stdc++.h>\nusing namespace std;\n\n bool isValid(string S) {\n // write your code here\n }\n\nint main(){ \n \n string s;\n cin>>s;\n bool result =isValid(s);\n if(result == 1){\n cout<<\"true\"<<endl;\n } if(result==0){\n cout<< \"false\"<<endl;\n }\n return 0;\n}"},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n public static boolean isValid(String S) {\r\n // write your code here\r\n\r\n return false;\r\n }\r\n\r\n public static void main(String[] args) throws Exception {\r\n BufferedReader read = new BufferedReader(new InputStreamReader(System.in));\r\n\r\n boolean result = isValid(read.readLine());\r\n System.out.println(result);\r\n\r\n }\r\n}\r\n"},"python":{"code":""}},"points":10,"difficulty":"medium","sampleInput":"aabcbc","sampleOutput":"true\r\n","questionVideo":"https://www.youtube.com/embed/ynuC2fGlwUw","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":"8c6022a5-8654-4226-918f-8110af738bd4","name":"Stacks For Intermediate","slug":"stacks-for-intermediate-688","type":0},{"id":"a6c59060-b618-424c-8e7d-36a94b77aae2","name":"Check If Word Is Valid After Insertion","slug":"check-if-word-is-valid-after-insertion","type":1}],"next":{"id":"1150b0b9-7b77-4d5e-be02-1904cf847c76","name":"Check If Word Is Valid After Insertion MCQ","type":0,"slug":"check-if-word-is-valid-after-insertion-mcq"},"prev":{"id":"f6df04d0-153f-42c9-a266-8a57eb389d6d","name":"Max-stack","type":3,"slug":"max-stack"}}}
plane

Editor


Loading...

Check If Word Is Valid After Insertion

medium

1. You are given a string s determine if it is valid or not. 2. A valid string is a string that can be created by inserting abc at any index any number of times. Example: aabcbc can be created "" -> "abc" -> "aabcbc" while it is impossible to create abccba.

Constraints

1: s consists of letters 'a', 'b', and 'c' only.

Format

Input

Input is managed for you

Output

Output is managed for you

Example

Sample Input

aabcbc

Sample Output

true

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode