O GoConqr está de visual novo! Conte para nós o que você achou.

Flashcards

Palindromic Substrings - Leetcode

Suhas S Inglês 1 flashcard

Flashcards do conjunto (1)

  1. 1Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist of same characters. Input: "abc" Output: 3 Explanation: Three palindromic strings: "a", "b", "c".class Solution {
    int count = 0;
    public int countSubstrings(String s) {
    for(int i = 0; i < s.length(); i++){
    extendPalindrome(s,i,i);
    extendPalindrome(s,i,i+1);
    }
    return count;
    }
    private void extendPalindrome(String s, int left, int right){
    while(left >=0 && right < s.length() && s.charAt(left) == s.charAt(right)){
    count++;
    left--;
    right++;
    }
    }
    }

Informações

Descrição
FlashCards sobre Palindromic Substrings - Leetcode, criado por Suhas S em 24-03-2018.
Criado por
Suhas S
Visualizações
2
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?