File tree 9 files changed +140
-43
lines changed
CodeChef/DSALearningSeries/ComplexityAnalysis&BasicsWarmUp
9 files changed +140
-43
lines changed Original file line number Diff line number Diff line change 5
5
"version" : " 0.2.0" ,
6
6
"configurations" : [
7
7
{
8
- "name" : " g++ - Build and debug active file" ,
8
+ "name" : " g++-9 - Build and debug active file" ,
9
9
"type" : " cppdbg" ,
10
10
"request" : " launch" ,
11
11
"program" : " ${fileDirname}/${fileBasenameNoExtension}" ,
22
22
"ignoreFailures" : true
23
23
}
24
24
],
25
- "preLaunchTask" : " g++ build active file" ,
25
+ "preLaunchTask" : " C/C++: g++-9 build active file" ,
26
26
"miDebuggerPath" : " /usr/bin/gdb"
27
27
}
28
28
]
Original file line number Diff line number Diff line change 1
1
{
2
2
"files.associations" : {
3
- "iostream" : " cpp"
3
+ "cmath" : " cpp" ,
4
+ "complex" : " cpp" ,
5
+ "array" : " cpp"
4
6
}
5
7
}
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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 number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments