Palindrome is a sequence of characters, which has the same meaning when read in either direction (left to right, right to left). When deciding whether the given word (phrase, number) is a palindrome, we usually omit white characters, punctuation marks and diacritics.

Among the basic types of palindromes belong palindromic words (radar, civic, level, rotor...), sentences (“Madam, I'm Adam”, “Never odd or even”...), numbers (99191112211...) a and dates (01/02/201010/12/2101...). Sometimes whole words are considered as units (“King, are you glad you are king?”).

Code

    /**
     * Check whether the given string is a palindrome
     * @param tested tested string
     * @param ignoreLetterCase flag indicating whether the letter case will be ignored - 
     *         true: case will be ignored, false: case won't be ignored 
     * @param ignoreWhitespaces flag indicating whether white characters will be ignored. 
     *         true: white characters will be ignored, false: white characters won't be ignored
     * @param ignoreDiacritics flag indicating whether diacritics will be ignored. 
     *         true: diacritics will be ignored, false: diacritics won't be ignored
     * @return true: if the testing string is palindrome, false: otherwise
     */
    public static boolean isPalindrome(String tested, boolean ignoreLetterCase, boolean ignoreWhitespaces, boolean ignoreDiacritics){
        if(ignoreLetterCase){
            tested = tested.toLowerCase();
        }
        if(ignoreWhitespaces){
            tested = tested.replaceAll("\\\\s", ""); //replace white characters with an empty string
        }
        if(ignoreDiacritics){
           tested = Normalizer.normalize(tested, Form.NFD).replaceAll("\\\\p{InCombiningDiacriticalMarks}+", ""); //decompose the character and remove the accent part
        }

        //check whether the string is a palindrome
        for(int i = 0; i < tested.length()/2; i++){
            if(tested.charAt(i) != tested.charAt(tested.length() - 1 - i)){
                return false;
            }
        }
        
        return true;
    }

SEO od společnosti Digital Pylon


Online casino s algoritmem

České casino online online slot-vegas.cz

Hrajte nejlepší hry jako je GoodGame Empire.





Zajímavé články: Jak najít práci snů? Zvolte kariéru v IT!, Češi mají rádi hrací automaty online, Jak funguje algoritmické obchodování Casino, Online výuka Algoritmus a online marketing mají svá pravidla, Automaty, Matematický vliv, Ratings, Jak fungují algoritmy hazardních her online: více znalostí, více peněz, SYPWAI - nástroj pro vědecký vývoj, Vynikají na globálním trhu: Nejlepší vývojáři softwaru pro online výherní automaty, Jak si vybrat nejlepší české online casino, Proč byste měli hrát online casino VPN revoluce, Kde najdeme algoritmy v každodenním životě?, Čeká vás pracovní pohovor mimo město? Podívejte se, jak dokonale zvládnout včasný příchod, 5 úžasných technologií ze světa hazardních her, Mirror and access to Mostbet, Svou kancelář můžete mít stále po ruce, Jaké výhody má digitalizovaná firma oproti off-line konkurenci?, Jaký systém vybrat pro snadné řízení výroby?, Nahradí umělá inteligence ajťáky?, Důvody, proč používat SnapTik ke stahování videí TikTok, Dokonalý den na pláži: Co si vzít s sebou, aby byl výlet zábavný a bezpečný?, Jak přežít dlouhý let?, Go pay GoodGame Empire, Blockchain, Rozhovor


Doporučujeme

Internet pro vaši firmu na míru

https://www.algoritmy.net