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 e07b519

Browse files
Day1 of 100daysof Code
1 parent ec6719b commit e07b519

Some content is hidden

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

46 files changed

+332
-0
lines changed

‎Leetcode/.m.c.swp

12 KB
Binary file not shown.

‎Leetcode/MinimumRotated.class

924 Bytes
Binary file not shown.

‎Leetcode/MinimumRotated.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.*;
2+
public class MinimumRotated{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int n=cin.nextInt();
6+
int[] array=new int[n];
7+
for(int i=0;i<n;i++){
8+
array[i]=cin.nextInt();
9+
}
10+
System.out.println(MinimumRotation(array));
11+
}
12+
public static int MinimumRotation(int[] array){
13+
int left=0,right=array.length-1;
14+
if(array[left]<array[right]) return array[left];
15+
if(array.length==1) return array[left];
16+
while(left<right){
17+
// Find the inflectionPoint
18+
int midPoint=(left+right)/2;
19+
//check if midpoint is not the inflectionPoint
20+
if(array[midPoint]>array[midPoint+1] && midPoint<array.length) return array[midPoint+1];
21+
if(array[midPoint]<array[midPoint-1] && midPoint>0) return array[midPoint];
22+
if(array[midPoint]>array[left]){
23+
left=midPoint+1;
24+
}else{
25+
right=midPoint-1;
26+
}
27+
}
28+
return -1;
29+
}
30+
}

‎cdblocks/challenge1/AnyBase.class

-1.12 KB
Binary file not shown.

‎cdblocks/challenge1/HollowDiamond.class

847 Bytes
Binary file not shown.

‎cdblocks/challenge1/HollowDiamond.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Basic Trick:
3+
* nsp= 2*nrow-1
4+
* nst=n-nsp
5+
*/
6+
7+
import java.util.Scanner;
8+
public class HollowDiamond{
9+
public static void main(String[] args){
10+
Scanner cin=new Scanner(System.in);
11+
int n=cin.nextInt();
12+
int nrow=1;
13+
int nsp=2*nrow-1;
14+
int nst=n-nsp;
15+
while(nrow<=n){
16+
int cst=1;
17+
while(cst<=nst){
18+
System.out.print("*\t");
19+
cst++;
20+
}
21+
int csp=1;
22+
while(csp<=nsp){
23+
System.out.print("\t");
24+
csp++;
25+
}
26+
System.out.println();
27+
if(nrow<n/2){
28+
nsp=2*nrow-1;
29+
nst=n-nsp;
30+
}else{
31+
//nst=2*nrow-k;
32+
//nsp=n-nsp;
33+
}
34+
nrow++;
35+
36+
}
37+
}
38+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import java.util.*;
2+
public class ManmohanLovesPatternsI{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int n=cin.nextInt();
6+
int nst=1;
7+
int nrow=1;
8+
while(nrow<=n){
9+
//work
10+
int cst=1;
11+
while(cst<=nst){
12+
if((nst%2==0 && nst!=2) &&(cst > 1 && cst<nst)){
13+
System.out.print("0");
14+
}else{
15+
System.out.print("1");
16+
}
17+
cst++;
18+
}
19+
//prep
20+
System.out.println();
21+
nrow++;
22+
nst++;
23+
}
24+
}
25+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import java.util.Scanner;
2+
public class ManmohanLovesPatternsII{
3+
public static void main(String[] args){
4+
Scanner cin=new Scanner(System.in);
5+
int n=cin.nextInt();
6+
int nst=1;
7+
int nrow=1;
8+
int pr=1;
9+
while(nrow<=n){
10+
//work
11+
int cst=1;
12+
while(cst<=nst){
13+
if(nst>2 && (cst>1 && cst<nst)){
14+
System.out.print("0");
15+
}
16+
else{
17+
System.out.print(pr);
18+
}
19+
cst++;
20+
}
21+
//prep
22+
System.out.println();
23+
nst++;
24+
nrow++;
25+
if(nrow>2)
26+
pr++;
27+
}
28+
}
29+
}
30+
31+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import java.util.Scanner;
2+
public class PattenrTriangle{
3+
public static void main+(String[] args){
4+
5+
int nr;
6+
std::cin>>nr;
7+
int row=1;
8+
int val,nst=1,nsp=nr-1;
9+
while(row<=nr){
10+
val=1;
11+
int csp=1;
12+
while(csp<=nsp){
13+
std::cout<<" ";
14+
csp++;
15+
}
16+
int cst=1;
17+
while(cst<=nst){
18+
std::cout<<val<<" ";
19+
//prep
20+
if(cst<=nst/2){
21+
val++;
22+
}else{
23+
val--;
24+
}
25+
cst++;
26+
}
27+
//prep
28+
std::cout<<std::endl;
29+
nsp--;
30+
nst+=2;
31+
row++;
32+
}
33+
}
1001 Bytes
Binary file not shown.

0 commit comments

Comments
(0)

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