Skip to content

Commit a3a8b6f

Browse files
committed
Initial commit
1 parent ca74de4 commit a3a8b6f

File tree

9 files changed

+140
-43
lines changed

9 files changed

+140
-43
lines changed

.vscode/launch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"version": "0.2.0",
66
"configurations": [
77
{
8-
"name": "g++ - Build and debug active file",
8+
"name": "g++-9 - Build and debug active file",
99
"type": "cppdbg",
1010
"request": "launch",
1111
"program": "${fileDirname}/${fileBasenameNoExtension}",
@@ -22,7 +22,7 @@
2222
"ignoreFailures": true
2323
}
2424
],
25-
"preLaunchTask": "g++ build active file",
25+
"preLaunchTask": "C/C++: g++-9 build active file",
2626
"miDebuggerPath": "/usr/bin/gdb"
2727
}
2828
]

.vscode/settings.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"files.associations": {
3-
"iostream": "cpp"
3+
"cmath": "cpp",
4+
"complex": "cpp",
5+
"array": "cpp"
46
}
57
}

.vscode/tasks.json

-40
This file was deleted.

AlgoDaily/is-an-anagram.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This is my solution for AlgoDaily problem Is An Anagram
2+
# Located at https://algodaily.com/challenges/is-an-anagram
3+
4+
def is_anagram(s, t):
5+
return sorted(s.lower()) == sorted(t.lower())
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
int n;
11+
cin >> n;
12+
vector<int> cars(n);
13+
for(int i = 0; i < n; i++){
14+
cin >> cars[i];
15+
}
16+
int count = 1;
17+
int temp = cars[0];
18+
for(int i = 1; i < n; i++){
19+
if(cars[i] < temp){
20+
count++;
21+
temp = cars[i];
22+
}
23+
}
24+
cout << count << endl;
25+
}
26+
return 0;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
int n;
11+
cin >> n;
12+
int temp, newN = 0;
13+
while(n){
14+
temp = n % 10;
15+
newN = newN * 10 + temp;
16+
n /= 10;
17+
}
18+
cout << newN << endl;
19+
}
20+
return 0;
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//auhtor @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int t;
8+
cin >> t;
9+
while(t--){
10+
string s;
11+
cin >> s;
12+
int n = s.size();
13+
string frnt = "", lst = "";
14+
for(int i = 0; i < n / 2; i++){
15+
frnt += s[i];
16+
}
17+
if(n % 2){
18+
frnt += s[n/2];
19+
}
20+
for(int i = n / 2; i < n; i++){
21+
lst += s[i];
22+
}
23+
map<char, int> mp;
24+
bool flag = true;
25+
for(char x : frnt){
26+
mp[x]++;
27+
}
28+
for(char x : lst){
29+
mp[x]--;
30+
if(mp[x] < 0){
31+
flag = false;
32+
break;
33+
}
34+
}
35+
if(flag){
36+
cout << "YES" << endl;
37+
}else{
38+
cout << "NO" << endl;
39+
}
40+
}
41+
return 0;
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
6+
int main(){
7+
int n;
8+
while(cin >> n){
9+
if(n == 42){
10+
return 0;
11+
}else{
12+
cout << n << endl;
13+
}
14+
}
15+
return 0;
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// author @Nishant
2+
3+
#include<bits/stdc++.h>
4+
using namespace std;
5+
#define ll long long int
6+
7+
int main(){
8+
ll n;
9+
cin >> n;
10+
vector<ll> budget(n);
11+
for(ll i = 0; i < n; i++){
12+
cin >> budget[i];
13+
}
14+
sort(budget.begin(), budget.end());
15+
ll maxProfit = 0;
16+
for(ll i = 0; i < n; i++){
17+
ll temp = budget[i];
18+
if(maxProfit < temp * (n - i)){
19+
maxProfit = temp * (n - i);
20+
}
21+
}
22+
cout << maxProfit;
23+
return 0;
24+
}

0 commit comments

Comments
 (0)