Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package node;
- import com.oracle.jrockit.jfr.Transition;
- import java.util.Scanner;
- public class Swaggg{
- static Scanner in = new Scanner(System.in);
- private static boolean isEqual(Stack<Integer> s1, Stack<Integer> s2){
- Stack<Integer> temp = new Stack<>();
- Stack<Integer> temp1 = new Stack<>();
- while(!s1.isemepty())
- {
- while (!s2.isemepty()){
- int x=s1.top();
- int x2=s2.top();
- if (x==x2){
- System.out.println("swag");
- break;
- }
- temp.push(s2.pop());
- if(s2.isemepty()){
- return false;
- }
- }
- while (!temp.isemepty()){
- s2.push(temp.pop());
- }
- temp1.push(s1.pop());
- }
- while(!temp1.isemepty()){
- s1.push(temp1.pop());
- }
- return true;
- }
- public static boolean DoSifrati(Stack<Integer> s1){
- boolean Equel;
- Stack<Integer> S1,S2,S3;
- S1=new Stack<Integer>();
- S2=new Stack<Integer>();
- S3=new Stack<Integer>();
- while (!s1.isemepty()){
- int x=s1.pop();
- S3.push(x);
- S1.push(x/10);
- S2.push(x%10);
- }
- while(!S3.isemepty()){
- s1.push(S3.pop());
- }
- Equel=isEqual(S1, S2);
- return Equel;
- }
- public static void main(String[] args){
- Stack<Integer> s2=new Stack<Integer>();
- s2.push(13);
- s2.push(42);
- s2.push(31);
- s2.push(24);
- int n=110;
- System.out.println(DoSifrati(s2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement