Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ee44030

Browse files
updates
1 parent 128e18c commit ee44030

File tree

78 files changed

+540
-149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+540
-149
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
class CielandReceipt {
5+
static BufferedReader br;
6+
static StringTokenizer st;
7+
8+
static int nextInt() throws IOException {
9+
return Integer.parseInt(next());
10+
}
11+
12+
static String next() throws IOException {
13+
while (st == null || !st.hasMoreTokens()) {
14+
st = new StringTokenizer(br.readLine());
15+
}
16+
return st.nextToken();
17+
}
18+
19+
static long nextLong() throws IOException {
20+
return Long.parseLong(next());
21+
}
22+
23+
public static void main(String args[]) throws IOException {
24+
br = new BufferedReader(new InputStreamReader(System.in));
25+
int t = nextInt();
26+
while (t-- > 0) {
27+
input();
28+
}
29+
br.close();
30+
}
31+
32+
public static void input() throws IOException {
33+
int n = nextInt();
34+
int step=0;
35+
for(int i =11;i>=0;i--)
36+
{
37+
while(n>=Math.pow(2,i))
38+
{
39+
n=n-(int)Math.pow(2,i);
40+
step++;
41+
}
42+
}
43+
44+
System.out.println(step);
45+
}
46+
47+
48+
49+
50+
}

‎DSAPractice/Greedy Algorithm/chopsticks.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
package DSAPractise;
21
import java.io.*;
32
import java.util.*;
43

@@ -91,7 +90,11 @@ public static void main(String[] args) {
9190

9291
}
9392
}
94-
93+
94+
95+
96+
97+
9598

9699

97100

‎DSAPractice/Stacks and Queues/StackOfStack.java‎

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,47 @@
22
import java.util.*;
33

44
public class StackOfStack {
5-
6-
75
public static void main(String[] args) {
86
Scanner sc = new Scanner(System.in);
9-
System.out.println("Enter values");
10-
Stack<Integer>[] s = new Stack[2];
11-
for(int i=0;i<2;i++)
12-
{
13-
s[i]=new Stack<>();
14-
int len =sc.nextInt();
15-
int a[]=new int[len];
16-
for(int k=0;k<len;k++)
17-
{
18-
a[k]=sc.nextInt();
19-
20-
}
21-
22-
for(int u=len-1;u>=0;u--)
23-
{
24-
s[len-1-u].push(a[u]);
25-
}
7+
System.out.println("Enter no of stacks you want to add:");
8+
int nos = sc.nextInt();
9+
Stack<Integer>[] s = new Stack[nos];// this stack will have two stacks
10+
for (int i = 0; i < nos; i++) {
11+
s[i] = new Stack<>();
12+
System.out.println("Enter length of stack:");
13+
14+
int len = sc.nextInt();
15+
int a[] = new int[len];
16+
System.out.println("Enter all elements of the stack:");
17+
18+
for (int k = 0; k < len; k++) {
19+
a[k] = sc.nextInt();
20+
21+
}
22+
23+
for (int j = len - 1; j >= 0; j--)
24+
s[i].push(a[j]);
25+
26+
}
27+
28+
for (Stack<Integer> st : s) {
29+
System.out.print(Arrays.toString(st.toArray())+ " ");
30+
31+
st.pop();
32+
33+
System.out.print(Arrays.toString(st.toArray())+ " ");
34+
}
35+
System.out.println();
36+
System.out.println("------------------------------------");
37+
38+
for (int k = 0; k < s.length; k++) {
39+
for(int g =0;g<s[k].size();g++)
40+
{
41+
System.out.println(s[k].peek());
42+
s[k].pop();
43+
}
44+
System.out.println("============");
2645
}
2746

28-
for(Stack<Integer> st : s)
29-
System.out.println(Arrays.toString(st.toArray()));
3047
}
3148
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: LockFreeStack","url":"/home/mustansir/messedupJavaPrograms/CodeChef-Certified-Data-Structures-And-Algorithms-Programme/DSAPractice/recursion/LockFreeStack.java","tests":[],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/home/mustansir/messedupJavaPrograms/CodeChef-Certified-Data-Structures-And-Algorithms-Programme/DSAPractice/recursion/LockFreeStack.java","group":"local","local":true}

‎DSAPractice/recursion/Fire.java‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import java.io.*;
2+
import java.util.*;
3+
import java.math.BigInteger;
4+
5+
class Fire {
6+
static BufferedReader br;
7+
static StringTokenizer st;
8+
9+
static int nextInt() throws IOException {
10+
return Integer.parseInt(next());
11+
}
12+
13+
static String next() throws IOException {
14+
while (st == null || !st.hasMoreTokens()) {
15+
st = new StringTokenizer(br.readLine());
16+
}
17+
return st.nextToken();
18+
}
19+
20+
static long nextLong() throws IOException {
21+
return Long.parseLong(next());
22+
}
23+
24+
public static void main(String args[]) throws IOException {
25+
br = new BufferedReader(new InputStreamReader(System.in));
26+
int t = nextInt();
27+
while (t-- > 0) {
28+
input();
29+
}
30+
br.close();
31+
}
32+
33+
public static void input() throws IOException {
34+
int n = nextInt();
35+
long mod = nextLong();
36+
37+
long[] a = new long[n+1];
38+
a[0]=2;
39+
a[1]=2;
40+
41+
for(int i=2;i<=n;i++)
42+
{
43+
a[i]=(a[i-1]%mod+a[i-2]%mod)%mod;
44+
}
45+
46+
System.out.println(a[n-1]);
47+
48+
49+
}
50+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /