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 36c82a9

Browse files
adding codes
1 parent e5e2b45 commit 36c82a9

File tree

25 files changed

+549
-0
lines changed

25 files changed

+549
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* @author: sauravjaiswalsj
3+
*/
4+
import java.util.*;
5+
public class brkbks{
6+
public static void main(String[] args){
7+
final Scanner cin = new Scanner(System.in);
8+
int test=cin.nextInt();
9+
while(test-->0){
10+
int s = cin.nextInt();
11+
int w1 = cin.nextInt();
12+
int w2 = cin.nextInt();
13+
int w3 = cin.nextInt();
14+
System.out.println(BreakingBricks(s,w1,w2,w3));
15+
}
16+
}
17+
/*
18+
* @params takes the strength and widths
19+
* @return the number of hits needed to break the bricks
20+
*/
21+
public static int BreakingBricks(int s,int w1,int w2,int w3){
22+
int step=0;
23+
if(s>=(w1+w2+w3)){
24+
return 1;
25+
}
26+
else if(s>=w1+w2 && s>=w3){
27+
System.out.println("1");
28+
return 2;
29+
}
30+
else {
31+
int sum=w1+w3;
32+
if(s==sum){
33+
step++;
34+
}
35+
if(s>=w2){
36+
step++;
37+
}
38+
}
39+
return step;
40+
}
41+
}

‎Leetcode/2.add-two-numbers.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* @lc app=leetcode id=2 lang=java
3+
*
4+
* [2] Add Two Numbers
5+
*/
6+
7+
// @lc code=start
8+
/**
9+
* Definition for singly-linked list.
10+
* public class ListNode {
11+
* int val;
12+
* ListNode next;
13+
* ListNode(int x) { val = x; }
14+
* }
15+
*/
16+
class Solution {
17+
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
18+
19+
}
20+
}
21+
// @lc code=end
22+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* @lc app=leetcode id=34 lang=java
3+
*
4+
* [34] Find First and Last Position of Element in Sorted Array
5+
*/
6+
7+
// @lc code=start
8+
class Solution {
9+
public int[] searchRange(int[] nums, int target) {
10+
int[] arr= new int[2];
11+
int low=0;
12+
int high=nums.length;
13+
while(low<high){
14+
int mid=(low+high)/2;
15+
if(mid==target){
16+
arr[0]=mid;
17+
}
18+
if(mid<target)
19+
}
20+
}
21+
}
22+
// @lc code=end
23+

‎atcoder/8-March/Station.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import java.util.*;
2+
import java.io.*;
3+
public class Station{
4+
public static void main(String[] args)throws IOException{
5+
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
6+
String S=br.readLine();
7+
System.out.println(getStationPair(S));
8+
}
9+
public static String getStationPair(String S){
10+
if(S.charAt(0).equals(S.charAt(1))&&(S.charAt(1).equals(S.charAt(2)))){
11+
return "No";
12+
}
13+
return "YES";
14+
}
15+
}

‎codeforces/636/candies

15.4 KB
Binary file not shown.

‎codeforces/636/candies.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include<bits/stdc++.h>
2+
3+
void findX(int n){
4+
double x;
5+
for(int k=1;k<=n;k++){
6+
double p=pow(2,k);
7+
x=n*((1-k)/(1-p));
8+
std::cout<<x<<" ";
9+
}
10+
11+
//std::cout<<x<<"\n";
12+
}
13+
int main(void){
14+
int t,n;
15+
std::cin>>t;
16+
while(t!=0){
17+
std::cin>>n;
18+
findX(n);
19+
t--;
20+
}
21+
return 0;
22+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.*;
2+
public class NextRound{
3+
public static void main(String[] args){
4+
final Scanner cin=new Scanner(System.in);
5+
int n=cin.nextInt();
6+
int k=cin.nextInt();
7+
int[] arr = new int[n];
8+
for(int i=0;i<n;i++){
9+
arr[i]=cin.nextInt();
10+
}
11+
System.out.print(countWinner(n,k,arr));
12+
}
13+
//10 9 8 7 7 7 5 5
14+
public static int countWinner(int n,int k,int[] arr){
15+
int count=0,diffcount=0;
16+
for(int i=k;i<n;i++){
17+
if(arr[i]>k){
18+
count++;
19+
}
20+
}
21+
for(int i=0;i<k+1;i++){
22+
if(arr[i]>=k){
23+
diffcount++;
24+
}
25+
}
26+
return diffcount+count;
27+
}
28+
}

‎practice/algorithms/merge.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import java.util.io;
2+
public class merge{
3+
public static void main(String[] args){
4+
int[] arr=[1,4,5,8,10];
5+
int[] arr2=[0,2,3,6,7,9];
6+
merge(arr,arr2);
7+
}
8+
public static merge(int[] arr,int[] arr2){
9+
int[] newArray=new int[arr.length+arr2.length];
10+
int i=0;
11+
int n=newArray.length;
12+
while(i<n){
13+

‎practice/bruteforce/printMicrosoft.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#include<bits/stdc++.h>
2+
3+
int main(){
4+
int n;
5+
std::cin>>n;
6+
int temp=n;
7+
do{
8+
std::cout<<n<<"a ";
9+
if(n>0){
10+
n=n-5;
11+
std::cout<<n<<"b ";
12+
}
13+
else{
14+
std::cout<<n<<"c ";
15+
n=n+5;
16+
}
17+
if(n==temp){
18+
std::cout<<n<<"d ";
19+
break;
20+
21+
}
22+
std::cout<<n<<" ";
23+
}while(n==temp);
24+
return 0;
25+
}

‎practice/recursion/.addArray.cpp.swp

12 KB
Binary file not shown.

0 commit comments

Comments
(0)

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