Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions java/paranthesismatching.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
}
10 changes: 10 additions & 0 deletions python/binarytodecimal.py
Original file line number Diff line number Diff line change
@@ -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))