Skip to content

Commit 945fba0

Browse files
First 3 Problem solved of Mid Exam
1 parent 2834e2f commit 945fba0

14 files changed

+88
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Monkey","group":"HackerRank - Mid Term | Introduction to C++ for DSA | Batch 05","url":"https://www.hackerrank.com/contests/mid-term-a-introduction-to-c-for-dsa-a-batch-05/challenges/monkey-1-2","interactive":false,"memoryLimit":512,"timeLimit":4000,"tests":[{"id":1718861655060,"input":"monkey\ni love flower\n","output":"ekmnoy\neefilloorvw\n"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"Monkey"}},"batch":{"id":"5d6bcc2b-c992-4b2d-9c83-046cea425bb2","size":1},"srcPath":"f:\\Tutorials\\Video Tutorials\\Phitron\\2. Introduction to C++\\Monkey.cpp"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Sort It","group":"HackerRank - Mid Term | Introduction to C++ for DSA | Batch 05","url":"https://www.hackerrank.com/contests/mid-term-a-introduction-to-c-for-dsa-a-batch-05/challenges/sort-it-6-3","interactive":false,"memoryLimit":512,"timeLimit":4000,"tests":[{"id":1718860457803,"input":"5\n2 4 6 1 3\n","output":"1 2 3 4 6\n6 4 3 2 1\n"}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"SortIt"}},"batch":{"id":"aa36db4f-3073-4ec8-8a40-88942de66a91","size":1},"srcPath":"f:\\Tutorials\\Video Tutorials\\Phitron\\2. Introduction to C++\\Sort_It.cpp"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"name":"Sort It 2","group":"HackerRank - Mid Term | Introduction to C++ for DSA | Batch 05","url":"https://www.hackerrank.com/contests/mid-term-a-introduction-to-c-for-dsa-a-batch-05/challenges/sort-it-2-1-1","interactive":false,"memoryLimit":512,"timeLimit":4000,"tests":[{"input":"5\n1 4 2 3 5\n","output":"5 4 3 2 1\n","id":1718861052464}],"testType":"single","input":{"type":"stdin"},"output":{"type":"stdout"},"languages":{"java":{"mainClass":"Main","taskClass":"SortIt2"}},"batch":{"id":"0253a250-f359-4de5-832a-106c271d40f5","size":1},"srcPath":"f:\\Tutorials\\Video Tutorials\\Phitron\\2. Introduction to C++\\Sort_It_2.cpp"}

.vscode/settings.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"files.associations": {
33
"iostream": "cpp",
4-
"iomanip": "cpp"
4+
"iomanip": "cpp",
5+
"istream": "cpp"
56
}
67
}

Monkey.bin

65.9 KB
Binary file not shown.

Monkey.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int main()
5+
{
6+
char s[1000000];
7+
while (cin.getline(s, 1000000))
8+
{
9+
long int len = strlen(s);
10+
sort(s, s + len);
11+
for (long int i = 0; i < len; i++)
12+
{
13+
if ((int)s[i] == 32)
14+
{
15+
continue;
16+
}
17+
cout << s[i];
18+
}
19+
cout << endl;
20+
}
21+
22+
return 0;
23+
}

Monkey.exe

65.9 KB
Binary file not shown.

Sort_It.bin

77.7 KB
Binary file not shown.

Sort_It.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#include <iostream>
2+
#include <algorithm>
3+
using namespace std;
4+
5+
int main()
6+
{
7+
int n;
8+
cin >> n;
9+
long long int a[n];
10+
for (int i = 0; i < n; i++)
11+
{
12+
cin >> a[i];
13+
}
14+
15+
sort(a, a + n);
16+
for (int i = 0; i < n; i++)
17+
{
18+
cout << a[i] << " ";
19+
}
20+
21+
cout << endl;
22+
23+
sort(a, a + n, greater<int>());
24+
for (int i = 0; i < n; i++)
25+
{
26+
cout << a[i] << " ";
27+
}
28+
29+
return 0;
30+
}

Sort_It.exe

77.7 KB
Binary file not shown.

Sort_It_2.bin

69.2 KB
Binary file not shown.

Sort_It_2.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
long long int *sort_it(int n)
5+
{
6+
long long int *a = new long long int[n];
7+
for (int i = 0; i < n; i++)
8+
{
9+
cin >> a[i];
10+
}
11+
sort(a, a + n, greater<int>());
12+
return a;
13+
}
14+
15+
int main()
16+
{
17+
int n;
18+
cin >> n;
19+
long long int *a = sort_it(n);
20+
for (int i = 0; i < n; i++)
21+
{
22+
cout << a[i] << " ";
23+
}
24+
25+
return 0;
26+
}

input.txt

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
5
2-
1 2 3 4 5
3-
10
4-
6 7 8 9 10
1+
monkey
2+
i love flower

output.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
2-
1 2 3 4 5 6 7 8 9 10
1+
ekmnoy
2+
eefilloorvw

0 commit comments

Comments
 (0)