{"id":"b31b70a0-638d-4d83-9d56-5e510343f61c","name":"Valid Palindrome 2","description":"1. Given a string s.\r\n2. Return true if the s can be palindrome after deleting at most one character from it.\r\n","inputFormat":"s = \"abca\"\r\n","outputFormat":"true\r\nExplanation: You could delete the character 'c'.","constraints":"1. 1 &lt;= s.length &lt;= 10^5\r\n2. s consists of lowercase English letters.\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool validPalindrome(string s) {\n //write your code here\n}\n\nint main(){\n string str;\n cin>>str;\n bool res = validPalindrome(str);\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 public static boolean validPalindrome(String s) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~Input Management~~~~~~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String str = scn.nextLine();\r\n\r\n boolean res = validPalindrome(str);\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"abca","sampleOutput":"true","questionVideo":"","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":"1e2f7859-a0e4-4173-9424-75d27de3ab75","name":"Valid Palindrome 2","slug":"valid-palindrome-2","type":1}],"next":{"id":"01420e2d-9a5b-469e-b60b-72014a0f2b0b","name":"Valid Palindrome 2","type":3,"slug":"valid-palindrome-2"},"prev":{"id":"8212d45a-645f-407d-af86-7827a99b85dd","name":"Complex Number Multiplication MCQ","type":0,"slug":"complex-number-multiplication-mcq"}}}

Valid Palindrome 2

1. Given a string s. 2. Return true if the s can be palindrome after deleting at most one character from it.

{"id":"b31b70a0-638d-4d83-9d56-5e510343f61c","name":"Valid Palindrome 2","description":"1. Given a string s.\r\n2. Return true if the s can be palindrome after deleting at most one character from it.\r\n","inputFormat":"s = \"abca\"\r\n","outputFormat":"true\r\nExplanation: You could delete the character 'c'.","constraints":"1. 1 &lt;= s.length &lt;= 10^5\r\n2. s consists of lowercase English letters.\r\n","sampleCode":{"cpp":{"code":"#include<bits/stdc++.h>\nusing namespace std;\n\nbool validPalindrome(string s) {\n //write your code here\n}\n\nint main(){\n string str;\n cin>>str;\n bool res = validPalindrome(str);\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 public static boolean validPalindrome(String s) {\r\n // write your code here\r\n }\r\n\r\n // ~~~~~~~~~~~~Input Management~~~~~~~~~~~~~~~~\r\n public static void main(String[] args) {\r\n Scanner scn = new Scanner(System.in);\r\n String str = scn.nextLine();\r\n\r\n boolean res = validPalindrome(str);\r\n System.out.println(res);\r\n }\r\n}"},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"abca","sampleOutput":"true","questionVideo":"","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":"1e2f7859-a0e4-4173-9424-75d27de3ab75","name":"Valid Palindrome 2","slug":"valid-palindrome-2","type":1}],"next":{"id":"01420e2d-9a5b-469e-b60b-72014a0f2b0b","name":"Valid Palindrome 2","type":3,"slug":"valid-palindrome-2"},"prev":{"id":"8212d45a-645f-407d-af86-7827a99b85dd","name":"Complex Number Multiplication MCQ","type":0,"slug":"complex-number-multiplication-mcq"}}}
plane

Editor


Loading...

Valid Palindrome 2

easy

1. Given a string s. 2. Return true if the s can be palindrome after deleting at most one character from it.

Constraints

1. 1 <= s.length <= 10^5 2. s consists of lowercase English letters.

Format

Input

s = "abca"

Output

true Explanation: You could delete the character 'c'.

Example

Sample Input

abca

Sample Output

true

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode