Skip to content

Commit 02491b0

Browse files
author
sunilmaurya
committed
added more coding problem
1 parent 7045576 commit 02491b0

File tree

75 files changed

+1556
-28
lines changed

Some content is hidden

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

75 files changed

+1556
-28
lines changed

.DS_Store

2 KB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 3","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/3.c","tests":[{"id":1657730988351,"input":"4\n4\n1 3 2 4\n3\n3 2 1\n2\n2 1\n3\n2 1 3\n","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/3.c","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: zigzagTraversal","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/zigzagTraversal.cpp","tests":[{"id":1659191998775,"input":"2\n3 3 1\n1 2 3\n4 5 6\n7 8 9\n3 3 2\n1 2 3 \n4 5 6\n7 8 9","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/zigzagTraversal.cpp","group":"local","local":true}

codechef-solution/3.bin

32.9 KB
Binary file not shown.

codechef-solution/3.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#include<stdio.h>
2+
int test(){
3+
int n1,n2;
4+
while(n1!=n2)
5+
{
6+
if(n1 > n2)
7+
n1 -= n2;
8+
else
9+
n2 -= n1;
10+
}
11+
return 20;
12+
}
13+
int main()
14+
{
15+
test();
16+
int t;
17+
scanf("%d",&t);
18+
for(int xx=0;xx<t;xx++){
19+
int n;
20+
scanf("%d",&n);
21+
int a[n];
22+
int k=0;
23+
while(k<n){
24+
scanf("%d",&a[k]);
25+
k=k+1;
26+
}
27+
int count=0;
28+
k=0;
29+
while(k<n){
30+
if(a[k]==1){
31+
count = k;
32+
break;
33+
}
34+
k++;
35+
}
36+
k=count;
37+
while(k>0){
38+
a[k] = a[k-1];
39+
k=k-1;
40+
}
41+
a[0]=1;
42+
k=0;
43+
while(k<n){
44+
if(a[k]==n){
45+
count = count+ (n-1-k);
46+
}
47+
k++;
48+
}
49+
printf("%d\n",count);
50+
}
51+
return 0;
52+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 2journeyKnight","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/2journeyKnight.cpp","tests":[{"id":1657302035881,"input":"3\n1 1 1 1\n8 8 7 6\n8 8 8 6\n","output":"YES\nNO\nYES\n"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/2journeyKnight.cpp","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 3gameofPill","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/3gameofPill.cpp","tests":[{"id":1657302819147,"input":"3\n2\n2 2\n1\n10\n3\n1 5 6","output":"CHEFINA\nCHEFINA\nCHEF"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/3gameofPill.cpp","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 4Largest Square in the garden","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/4Largest Square in the garden.cpp","tests":[{"id":1657366466839,"input":"3\n1 1\n0 2\n1 2\n","output":"2"},{"id":1657366472802,"input":"8\n2 4\n2 4\n1 4\n0 7\n0 3\n1 2\n1 2\n1 1","output":"3"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/4Largest Square in the garden.cpp","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: 5xor","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/5xor.cpp","tests":[{"id":1657456690852,"input":"3\n2\n0 3 6\n2\n4 7 2\n5\n9 6 11 8 13 10\n","output":""}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/5xor.cpp","group":"local","local":true}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Local: slowsolution","url":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/slowsolution.cpp","tests":[{"id":1657300377886,"input":"4\n10 100 200\n3 10 100\n1000 1000 2200\n100 100 100","output":"20000\n300\n2040000\n10000"}],"interactive":false,"memoryLimit":1024,"timeLimit":3000,"srcPath":"/Users/sunilkumarmaurya/Desktop/solution-leedcode-codechef-codeforces-gfg-interviewbits-hackerEarth-HackerRank/codechef-solution/july 2022/slowsolution.cpp","group":"local","local":true}

0 commit comments

Comments
 (0)