title-img


Java String Reverse

A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward.(Wikipedia) Given a string A, print Yes if it is a palindrome, print No otherwise. Constraints A will consist at most 50 lower case english letters.

View Solution →

Java Anagrams

Two strings, a and b, are called anagrams if they contain all the same characters in the same frequencies. For example, the anagrams of CAT are CAT, ACT, TAC, TCA, ATC, and CTA. Complete the function in the editor. If a and b are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead. Input Format The first line contains a string denoting a. The second line contains a string denoting b. Constraints 1<=length(a),length(b)<=50 Strings a and b consi

View Solution →

Java String Tokens

Given a string, s, matching the regular expression [A-Za-z !,?._'@]+, split the string into tokens. We define a token to be one or more consecutive English alphabetic letters. Then, print the number of tokens, followed by each token on a new line. Note: You may find the String.split method helpful in completing this challenge. Input Format A single string, s. Constraints 1 <= length of s <= 4.10^5 s is composed of any of the following: English alphabetic letters, blank spaces,

View Solution →

Pattern Syntax Checker Java

Using Regex, we can easily match or search for patterns in a text. Before searching for a pattern, we have to specify one using some well-defined syntax. In this problem, you are given a pattern. You have to check whether the syntax of the given pattern is valid. Note: In this problem, a regex is only valid if you can compile it using the Pattern.compile method. Input Format The first line of input contains an integer N, denoting the number of test cases. The next N lines contain a s

View Solution →

Java Regex

Write a class called MyRegex which will contain a string pattern. You need to write a regular expression and assign it to the pattern such that it can be used to validate an IP address. Use the following definition of an IP address: IP address is a string in the form "A.B.C.D", where the value of A, B, C, and D may range from 0 to 255. Leading zeros are allowed. The length of A, B, C, or D can't be greater than 3. Some valid IP address: 000.12.12.034 121.234.12.12 23.45.12.56 Some

View Solution →