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
/** | |
* Muhammad Ali, one of my great heroes, had a great line | |
* in the '70s when he was asked "How many sit-ups do you do?" | |
* He said, "I don't count my sit-ups. I only start counting when | |
* it starts hurting. When I feel pain, that's when I start counting | |
* because that's when it really counts". That's what makes you a | |
* champion. And that's the way it is with everything. | |
* ~ Arnold Schwarzenegger | |
**/ | |
#include <bits/stdc++.h> |
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
/** | |
* He said, "I don't count my sit-ups. I only start counting when | |
* it starts hurting. When I feel pain, that's when I start counting | |
* because that's when it really counts". That's what makes you a | |
* champion. And that's the way it is with everything. | |
* ~ Arnold Schwarzenegger | |
**/ | |
#include <bits/stdc++.h> | |
#include <algorithm> |
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
int Solution::perfectPeak(vector<int> &arr) { | |
int n = arr.size(); | |
set<int> left; | |
left.insert(arr[0]); | |
map<int, int> right; | |
for (int i = 1; i <= n - 1; i++) { | |
++right[arr[i]]; | |
} | |
for (int i = 1; i <= n - 2; i++) { |
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
#include <bits/stdc++.h> | |
#include <algorithm> | |
using namespace std; | |
#define fi first | |
#define se second | |
#define ll long long | |
#define pb push_back | |
#define mp make_pair |
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
int peakElement(int arr[], int n) | |
{ | |
int left = 0; | |
int right = n - 1; | |
while (left <= right) { | |
int mid = left + (right - left) / 2; | |
if ((mid == 0 && arr[mid + 1] <= arr[mid]) || | |
(mid == n - 1 && arr[mid - 1] <= arr[mid]) || |
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
#include <bits/stdc++.h> | |
#include <algorithm> | |
using namespace std; | |
int sumOfDigit(int n) { | |
int sum = 0; | |
while (n) { | |
sum += (n % 10); | |
n /= 10; |
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
#include <bits/stdc++.h> | |
#include <algorithm> | |
using namespace std; | |
#define fi first | |
#define se second | |
#define ll long long | |
#define pb push_back | |
#define mp make_pair |
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
INPUT 1 | |
4 3 3 3 2 s1 p1 4 p3 p4 p6 p7 p6 p10 p9 p1 | |
OUTPUT 1 | |
Enter total no. of sites: | |
Enter total no. of process in Site "s1" | |
Enter total no. of process in Site "s2" | |
Enter total no. of process in Site "s3" | |
Enter total no. of process in Site "s4" | |
No. of processes in Site :s1 are :p1 p2 p3 |
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
#include<bits/stdc++.h> | |
using namespace std; | |
set<string> result; | |
void _all_paths(vector<vector<int>> adjList, set<int>& visited, string path, int cur) { | |
if (visited.size() == adjList.size()) | |
return; |
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
#include <bits/stdc++.h> | |
#include <algorithm> | |
using namespace std; | |
#define deb(x) cout << #x << "=" << x << endl | |
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl | |
string number; | |
void intToString(int n) { |
NewerOlder