title-img


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 →

Java Regex 2 - Duplicate Words

In this challenge, we use regular expressions (RegEx) to remove instances of words that are repeated more than once, but retain the first occurrence of any case-insensitive repeated word. For example, the words love and to are repeated in the sentence I love Love to To tO code. Can you complete the code in the editor so it will turn I love Love to To tO code into I love to code? To solve this challenge, complete the following three lines: 1.Write a RegEx that will match any repeated word.

View Solution →