Skip to main content

Posts

Showing posts from 2017

Java String Tokens | Regex expression

Given a string,  , 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,  . Constraints  is composed of  any  of the following: English alphabetic letters, blank spaces, exclamation points ( ! ), commas ( , ), question marks ( ? ), periods ( . ), underscores ( _ ), apostrophes ( ' ), and at symbols ( @ ). Output Format On the first line, print an integer,  , denoting the number of tokens in string   (they  do not  need to be unique). Next, print each of the   tokens on a new line in the same order as they appear in input string  . Sample Input He is a very...

Java Anagrams

Two strings,   and  , 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   and   are case-insensitive anagrams, print "Anagrams"; otherwise, print "Not Anagrams" instead. Input Format The first line contains a string denoting  . The second line contains a string denoting  . Constraints Strings   and   consist of English alphabetic characters. The comparison should NOT be case sensitive. Output Format Print "Anagrams" if   and   are case-insensitive anagrams of each other; otherwise, print "Not Anagrams" instead. Sample Input 0 anagram margana Sample Output 0 Anagrams Explanation 0 Character Frequency:  anagram Freque...