diff --git a/correct_parenthesis.java b/correct_parenthesis.java new file mode 100644 index 0000000..26e9502 --- /dev/null +++ b/correct_parenthesis.java @@ -0,0 +1,18 @@ +import java.util.*; +class Solution { + boolean solution(String s) { + boolean answer = true; + Deque parenthesis = new ArrayDeque<>(); + Map pair = Map.of(')','('); + for(char c : s.toCharArray()){ + if(c=='('){ + parenthesis.push(c); + }else{ + if(parenthesis.isEmpty() || pair.get(c)!=parenthesis.pop()){ + return false; + } + } + } + return parenthesis.isEmpty(); + } +} diff --git a/no_completion.java b/no_completion.java new file mode 100644 index 0000000..ce7991c --- /dev/null +++ b/no_completion.java @@ -0,0 +1,14 @@ +import java.util.*; +class Solution { + public String solution(String[] participant, String[] completion) { + Arrays.sort(participant); + Arrays.sort(completion); + int i; + for(i=0; i