Hackerrank – Java Solution – Tag Content Extractor Solution

Hackerrank – Java Solution – Tag Content Extractor Solution Problem Name –  Tag Content ExtractorProblem Link –   Tag Content Extractor Level – String Java Code import java.util.Scanner;import java.util.regex.Matcher;import java.util.regex.Pattern;public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testCases = Integer.parseInt(scan.nextLine()); /* Solution assumes we can’t have the symbol “<” […]

Continue Reading

Valid Username Regular Expression Solution Hackerrank – Java Solution

Valid Username Regular Expression Solution Hackerrank – Java Solution Problem Name – Valid Username Regular ExpressionProblem Link –  Valid Username Regular Expression Level – String Java Only Submitted Code class UsernameValidator { public static final String regularExpression = “([a-zA-Z])(\w){7,29}”;} Java Full Source Code import java.util.Scanner;class UsernameValidator { public static final String regularExpression = “([a-zA-Z])(\w){7,29}”;}public class Solution […]

Continue Reading

Hackerrank – Java Solution – Java Regex 2 – Duplicate Words Solution

Hackerrank – Java Solution – Java Regex 2 – Duplicate Words Solution Problem Name – Java Regex 2 – Duplicate WordsProblem Link –  Java Regex 2 – Duplicate Words Level – String Java Code import java.util.Scanner;import java.util.regex.Matcher;import java.util.regex.Pattern;public class DuplicateWords { public static void main(String[] args) { String regex = “\b(\w+)(\W+\1\b)+”; Pattern p = Pattern.compile(regex, Pattern.CASE_INSENSITIVE); Scanner […]

Continue Reading

Hackerrank – Java Solution – Java Regex Solution

Hackerrank – Java Solution – Java Regex Solution Problem Name – Java RegexProblem Link –  Java Regex  Level – String Java Only Submitted Code /* [01]?\d{1,2} matches numbers 0-199. 2[0-4]\d matches numbers 200-249 25[0-5] matches numbers 250-255*/class MyRegex { String num = “([01]?\d{1,2}|2[0-4]\d|25[0-5])”; String pattern = num + “.” + num + “.” + num + […]

Continue Reading

Hackerrank – Java Solution – Pattern Syntax Checker Solution

Hackerrank – Java Solution – Pattern Syntax Checker Solution Problem Name –  Pattern Syntax CheckerProblem Link –   Pattern Syntax Checker  Level – StringPoint – 20 Java Code import java.util.Scanner;import java.util.regex.Pattern;import java.util.regex.PatternSyntaxException;public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int testCases = scan.nextInt(); scan.nextLine(); // If a PatternSyntaxException is not […]

Continue Reading

Hackerrank – Java Solution – Java String Tokens solution

Hackerrank – Java Solution – Java String Tokens Problem Name – Java String TokensProblem Link –  Java String Tokens Level – StringPoint – 15 Java Code import java.util.Scanner;public class Solution { public static void main(String[] args) { /* Read input */ Scanner scan = new Scanner(System.in); String s = scan.nextLine(); scan.close(); s = s.trim(); // so […]

Continue Reading

Hackerrank – Java Solution – Java Anagrams Solution

Hackerrank – Java Solution – Java Anagrams Solution Problem Name – Java AnagramsProblem Link –  Java Anagrams  Level – String Java Anagram Full Code mport java.io.*;import java.util.*;public class Solution { static boolean isAnagram(String a, String b) { if ((a == null || b == null) || (a.length() != b.length())) { return false; } final char[] ARRAY_A […]

Continue Reading

Hackerrank – Java Solution – Java String Reverse Solution

Hackerrank – Java Solution – Java String Reverse Solution Problem Name – Java String ReverseProblem Link –  Java String Reverse Level – String Java Code import java.util.Scanner;public class Solution { public static void main(String[] args) { /* Read input */ Scanner scan = new Scanner(System.in); String str = scan.nextLine(); scan.close(); /* Reverse string and compare to original […]

Continue Reading

Hackerrank – Java Solution – Java Substring Comparisons Solution

Hackerrank – Java Solution – Java Substring Comparisons Solution Problem Name – Java Substring Comparisons Problem Link –  https://www.hackerrank.com/challenges/java-string-compare/problem Level – String Java Code import java.util.Scanner;public class Solution { public static void main(String[] args) { /* Save input */ Scanner scan = new Scanner(System.in); String s = scan.nextLine(); int k = scan.nextInt(); scan.close(); /* Create smallest […]

Continue Reading

Hackerrank – Java Solution – Java Substring Solution

Hackerrank – Java Solution – Java Substring Solution Problem Name –  Java SubstringProblem Link –   Java Substring Level – String Java Code import java.util.Scanner;public class Solution { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str = scan.next(); int start = scan.nextInt(); int end = scan.nextInt(); scan.close(); System.out.println(str.substring(start, end)); }} Tags: HackerRank […]

Continue Reading