Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
sabira-khan committed Apr 23, 2022
1 parent 8af93d0 commit ddd2b3e
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
63 changes: 63 additions & 0 deletions JavaSolutions/src/com/gitproject/Beecrowd1063_uri.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.gitproject;

import java.util.ArrayList;
import java.util.Scanner;
import java.util.Stack;

public class Beecrowd1063_uri {
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
int n = s.nextInt();
while(n != 0)
{
Stack<Character> train= new Stack<>();

ArrayList<Character> in = new ArrayList<>();
ArrayList<Character> res = new ArrayList<>();
for(int i=0;i<n;i++)
{
in.add(s.next().charAt(0));
}
for(int i=0;i<n;i++)
{
res.add(s.next().charAt(0));
}
int t = 0;
for(int i=0;i<n;i++)
{

train.push(in.get(i));
System.out.print("I");

while (train.size() > 0 && res.get(t) == train.peek()) //coz we want combo same as res
{
train.pop();
System.out.print("R");
t++;
}
}

if (train.size() != 0)
System.out.println(" Impossible");

n = s.nextInt();
}
}
}
/*
Input goes as:
--bottom to top in stack/LIFO --
a
d
t
e
Output comes out as:
--top to bottom--
d
a
t
e
*/
42 changes: 42 additions & 0 deletions JavaSolutions/src/com/gitproject/Beecrowd3084_uri.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package com.gitproject;

import java.util.Scanner;

public class Beecrowd3084_uri {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);


while (s.hasNext()) {
String input = s.nextLine();
String[] list = input.split(" ");

int x = Integer.parseInt(list[0]);
int y = Integer.parseInt(list[1]);

if (x== 0 && y==0) {
System.out.println("00:00");
}
else {
x /= 30;
y /= 6;
if (x < 10 && y >= 10) {
System.out.printf("0%d:%d\n", x, y);
}
else if (y < 10 && x >= 10) {
System.out.printf("%d:0%d\n", x, y);
}
else if (y < 10) {
System.out.printf("0%d:0%d\n", x, y);
}
else
System.out.printf("%d:%d\n", x,y);
}

}
}
}




0 comments on commit ddd2b3e

Please sign in to comment.