-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 46fad39
Showing
21 changed files
with
378 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
int calculate_earth_minutes(int minutes, int second){ | ||
int earthTime = 0; | ||
|
||
int totalSec = minutes * second; | ||
|
||
return ceil((float)totalSec/60); | ||
|
||
//return earthTime; | ||
|
||
} | ||
int main(){ | ||
|
||
cout << calculate_earth_minutes(1000, 20); | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
int GetBuildingCount(int n, string s){ | ||
set<char> row,col; | ||
int pos = 0; | ||
|
||
for(int i = 0;i < s.size(); i++){ | ||
char ch = s[i]; | ||
if(ch != '{' && ch != ',' && ch != '}'){ | ||
if(pos == 0){ | ||
row.insert(ch); | ||
} | ||
else{ | ||
col.insert(ch); | ||
} | ||
pos = (pos+1)%2; | ||
|
||
} | ||
|
||
} | ||
return ((row.size() + col.size()) * 8 - n); | ||
} | ||
int main(){ | ||
int n; cin >> n; | ||
string s; cin >> s; | ||
|
||
cout << GetBuildingCount(n, s); | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
string solve(string s, unordered_set<string> list){ | ||
|
||
for(int i = 0; i < s.size(); i++){ | ||
int j = i; | ||
while(j < s.size() && s[j] != ' '){ | ||
j++; | ||
} | ||
if(list.find(s.substr(i, j-i)) != list.end()){ | ||
|
||
s[i] = toupper(s[i]); | ||
|
||
} | ||
|
||
i = j; | ||
|
||
} | ||
|
||
return s; | ||
|
||
} | ||
int main(){ | ||
|
||
unordered_set<string>list; | ||
int n; cin >> n; | ||
for(int i = 0 ; i < n ;i++){ | ||
string temp; cin >> temp; | ||
list.insert(temp); | ||
} | ||
|
||
string s; | ||
//cin >> s; | ||
getline(cin, s); | ||
|
||
|
||
|
||
cout << solve(s, list); | ||
//cout << s; | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<html> | ||
<head> | ||
<style> | ||
div{ | ||
padding: 10px; | ||
margin: 10px; | ||
height: 10px; | ||
width: 10px; | ||
background-color : black ; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div></div> | ||
<script> | ||
console.log(document.getElementsByTagName('div')[0].clientHeight); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div class="div1"> | ||
<div class="div2"></div> | ||
</div> | ||
<style> | ||
.div1{ | ||
position: relative; | ||
width: 200px; | ||
height: 200px; | ||
border: 2px solid black; | ||
} | ||
.div2{ | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
border: 2px solid black; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
#include<iostream> | ||
#include <vector> | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
struct Result { | ||
Result() : output1() {}; | ||
int output1[100]; | ||
}; | ||
|
||
Result placement(int input, int input2[]) { | ||
//vector<int> r(input); | ||
struct Result res; | ||
|
||
for (int i = input - 1; i >= 0; i--) { | ||
int cnt = 0; | ||
for (int j = i - 1; j >= 0; j--) { | ||
if (input2[j] > input2[i]) | ||
cnt++; | ||
} | ||
res.output1[i] = cnt; | ||
} | ||
return res; | ||
} | ||
|
||
|
||
|
||
int main() { | ||
int n; cin >> n; | ||
int input2[n]; | ||
for (int i = 0; i < n; i++) | ||
cin >> input2[i]; | ||
|
||
struct Result res = placement(n, input2); | ||
|
||
for (int i = 0;i < n;i++) { | ||
cout << res.output1[i] << " "; | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include<iostream> | ||
#include<vector> | ||
#include<unordered_map> | ||
using namespace std; | ||
struct Result { | ||
Result() : output1() {}; | ||
int output1[100]; | ||
}; | ||
Result duplicatearrya(int input, int input1[]) { | ||
unordered_map<int, int> mp; | ||
Result res; | ||
for (int i = 0; i < input; i++) { | ||
mp[input1[i]]++; | ||
} | ||
int j = 0; | ||
for (auto &it : mp) { | ||
if (it.second > 1) { | ||
res.output1[j++] = it.first; | ||
} | ||
} | ||
return res; | ||
} | ||
|
||
int main() { | ||
int input; | ||
cin >> input; | ||
int input1[input]; | ||
for (int i = 0; i < input; i++) { | ||
cin >> input1[i]; | ||
} | ||
Result res = duplicatearrya(input, input1); | ||
|
||
for (int i = 0; i< input;i++) { | ||
cout << res.output1[i] << " "; | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
struct Result | ||
{ | ||
Result() : output1(){}; | ||
int output1[100]; | ||
}; | ||
|
||
Result DuplicateArray(int input1, input2[]){ | ||
|
||
for(int i = ) | ||
|
||
} | ||
int main(){ | ||
int n; cin >> n; | ||
int input2[n]; | ||
|
||
for(int i =0;i < n;i++){ | ||
|
||
} | ||
|
||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
int solve(int i, int j, int n, int m, vector<vector<int> > &dp) | ||
{ | ||
if (i == n && j == m) | ||
{ | ||
return 0; | ||
} | ||
if (i > n || j > m) | ||
return 1e9; | ||
if (dp[i][j] != -1) | ||
return dp[i][j]; | ||
return dp[i][j] = 1 + min(solve(i, j + i, n, m, dp), solve(i + j, j, n, m, dp)); | ||
} | ||
int minSteps(int input1, int input2) | ||
{ | ||
vector<vector<int> > dp(input1 + 1, vector<int>(input2 + 1, -1)); | ||
return solve(1, 1, input1, input2, dp); | ||
} | ||
int main() | ||
{ | ||
int n, m; | ||
cin >> n >> m; | ||
int ans = minSteps(n, m); | ||
if (ans >= 1e9) | ||
cout << -1; | ||
else | ||
cout << ans; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
#include<iostream> | ||
#include <vector> | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
struct Result { | ||
Result() : output1() {}; | ||
int output1[100]; | ||
}; | ||
|
||
Result placement(int input, int input2[]) { | ||
Result result ; | ||
for (int i = input - 1; i >= 0; i--) { | ||
int cnt = 0; | ||
for (int j = i - 1; j >= 0; j--) { | ||
if (input2[j] > input2[i]) | ||
cnt++; | ||
} | ||
result.output1[i] = cnt; | ||
} | ||
return result; | ||
} | ||
|
||
|
||
|
||
int main() { | ||
int n; cin >> n; | ||
int input2[n]; | ||
for (int i = 0; i < n; i++) | ||
cin >> input2[i]; | ||
|
||
Result res = placement(n, input2); | ||
|
||
for (int i = 0; i< n;i++) { | ||
cout << res.output1[i] << " "; | ||
} | ||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include<iostream> | ||
using namespace std; | ||
void linearSearch(){ | ||
|
||
} | ||
int recursiveLinearSearch(int arr[], int n, int key){ | ||
if(n == 0){ | ||
return -1; | ||
} | ||
|
||
if(arr[n-1] == key){ | ||
return n-1; | ||
} | ||
|
||
else{ | ||
return recursiveLinearSearch(arr, n-1, key); | ||
} | ||
} | ||
int main(){ | ||
|
||
int arr[] = {5, 6, 7, 8, 3}; | ||
cout << recursiveLinearSearch(arr, 5, 9); | ||
|
||
|
||
|
||
return 0; | ||
|
||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include<stdio.h> | ||
int main(){ | ||
int i = (1, 2, 3); | ||
printf("%d", i); | ||
|
||
|
||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include<stdio.h> | ||
#include<string.h> | ||
#include<iostream> | ||
#include <vector> | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
struct Result { | ||
Result() : output1() {}; | ||
int output1[100]; | ||
}; | ||
|
||
vector<int> placement(int input, int input2[]) { | ||
vector<int> r(input); | ||
for (int i = input - 1; i >= 0; i--) { | ||
int cnt = 0; | ||
for (int j = i - 1; j >= 0; j--) { | ||
if (input2[j] > input2[i]) | ||
cnt++; | ||
} | ||
r[i] = cnt; | ||
} | ||
return r; | ||
} | ||
|
||
|
||
|
||
int main() { | ||
int n; cin >> n; | ||
int input2[n]; | ||
for (int i = 0; i < n; i++) | ||
cin >> input2[i]; | ||
|
||
vector<int> v = placement(n, input2); | ||
|
||
for (auto it : v) { | ||
cout << it << " "; | ||
} | ||
|
||
return 0; | ||
} |