--- palindromic double pointer string

Palindrome string

680. Valid Palindrome II (Easy)

Input: "abca"
Output: True
Explanation: You could delete the character 'c'.

Subject description:

You can delete a character, it can be configured to determine whether the palindrome string.

Code:

public boolean validPalindrome(String s){
    int i==-1;
    int j=s.length();
    while(++i<--j){
        if(s.charAt(i)!=s.charAt(j)){
            return isPalindrome (s, i, j-1) || isPalindrome (s, i + 1, j); // After deleting a character, it is determined whether the remaining palindrome
        }
    }
    private boolean isPalindrome(String s ,int i,int j){
        while(i<j){
            if(s.charAt(i++)!=s.charAt(j--))
                return false;
        }
        return true;
    }
}

Intelligent Recommendation

BZOJ_2565_ palindromic double the longest string _manacher

BZOJ_2565_ palindromic double the longest string _manacher Description And reverse sequence reads exactly the same string called a palindromic sequence. such asacbcaPalindromic sequence, andabcNot (ab...

String - string reverse (double pointer)

The meaning: Write a function that the role is to reverse the input string. The input string is given in the form of a character array char []. Don't assign additional space to additional arrays, you ...

String + double pointer _ string reverse

Reverse string Sliced ​​method Double pointer 16 ways to achieve string reverse Sliced ​​method Double pointer...

--- double pointer inverted string vowel

Reverse string vowel 345. Reverse Vowels of a String (Easy) Subject description: Given a string, the string vowels exchange, the exchange returns a string. Analysis of ideas: Two double vowel pointer ...

Java double flip string pointer

github:https://github.com/xiaozhengwei/Algorithms-And-DataStructure  ...

More Recommendation

Leetcode Permutation in String double pointer

Given two strings s1 and s2, write a function to return true if s2 contains the permutation of s1. In other words, one of the first string's permutations is the subs...

Leetcode Questions-Double Pointer String

Using double pointer method to solve string problem is a relatively common way to deal with; 344. Reverse string Write a function whose role is to reverse the input string. The input string is given a...

Leetcode344. Reverse string / double pointer

Article catalog Title: 344. Reverse string Basic ideas: double pointer Title: 344. Reverse string Write a function that the role is to reverse the input string. The input string is given in the form o...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top