Added 20 solutions
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Author: Rodney Shaghoulian
|
||||
// Github: github.com/rshaghoulian
|
||||
// HackerRank: hackerrank.com/rshaghoulian
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.text.*;
|
||||
import java.math.*;
|
||||
import java.util.regex.*;
|
||||
|
||||
public class Solution {
|
||||
public static void main(String[] args){
|
||||
Scanner in = new Scanner(System.in);
|
||||
int testCases = Integer.parseInt(in.nextLine());
|
||||
while(testCases>0){
|
||||
String username = in.nextLine();
|
||||
//String pattern = Complete this line in the editable area below
|
||||
String pattern = "^[a-zA-Z]\\w{7,29}$";
|
||||
|
||||
Pattern r = Pattern.compile(pattern);
|
||||
Matcher m = r.matcher(username);
|
||||
|
||||
if (m.find( )) {
|
||||
System.out.println("Valid");
|
||||
} else {
|
||||
System.out.println("Invalid");
|
||||
}
|
||||
testCases--;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,3 @@
|
||||
// Author: Rodney Shaghoulian
|
||||
// Github: github.com/rshaghoulian
|
||||
// HackerRank: hackerrank.com/rshaghoulian
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
@@ -13,7 +9,7 @@ public class Solution {
|
||||
public static void main(String[] args){
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int testCases = Integer.parseInt(scan.nextLine());
|
||||
while (testCases > 0){
|
||||
while (testCases-- > 0){
|
||||
String pattern = scan.nextLine();
|
||||
try {
|
||||
Pattern.compile(pattern);
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Author: Rodney Shaghoulian
|
||||
// Github: github.com/rshaghoulian
|
||||
// HackerRank: hackerrank.com/rshaghoulian
|
||||
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/* Solution assumes we can't have the symbol "<" as text between tags */
|
||||
public class Solution{
|
||||
public static void main(String[] args){
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int testCases = Integer.parseInt(scan.nextLine());
|
||||
|
||||
while (testCases-- > 0) {
|
||||
String line = scan.nextLine();
|
||||
|
||||
boolean matchFound = false;
|
||||
Pattern r = Pattern.compile("<(.+)>([^<]+)</\\1>");
|
||||
Matcher m = r.matcher(line);
|
||||
|
||||
while (m.find()) {
|
||||
System.out.println(m.group(2));
|
||||
matchFound = true;
|
||||
}
|
||||
if ( ! matchFound) {
|
||||
System.out.println("None");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user