diff --git a/java/paranthesismatching.java b/java/paranthesismatching.java new file mode 100644 index 00000000..b9d55e48 --- /dev/null +++ b/java/paranthesismatching.java @@ -0,0 +1,33 @@ +package com.company.Stacks; + +import java.util.Scanner; + +public class ParenthesisMatching { + + public static boolean parenthesisMatch(String exp, CharStack st){ + for (int i = 0; i < exp.length(); i++) { + if (exp.charAt(i) == '('){ + st.push("("); + } + else if (exp.charAt(i) == ')'){ + if (st.isEmpty()){ + return false; + } + st.pop(); + } + } + return st.isEmpty(); + } + + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + String exp = sc.nextLine(); + CharStack st = new CharStack(exp.length()); + if (parenthesisMatch(exp, st)){ + System.out.println("Parenthesis Match"); + } + else{ + System.out.println("Parenthesis Missing"); + } + } +} \ No newline at end of file diff --git a/python/binarytodecimal.py b/python/binarytodecimal.py new file mode 100644 index 00000000..47bd2061 --- /dev/null +++ b/python/binarytodecimal.py @@ -0,0 +1,10 @@ +def bin_to_dec(x): + l=list(x) + l=list(map(int,l)) + bin=j=0 + for i in range(len(l)-1,-1,-1): + bin+=l[i]*2**j + j+=1 + return bin +x=input("Enter a Binary Number: ") +print(bin_to_dec(x)) \ No newline at end of file