Skip to content

Instantly share code, notes, and snippets.

View SuryaPratapK's full-sized avatar

Surya Pratap SuryaPratapK

  • Durgapur
View GitHub Profile
class Spreadsheet {
using pii = pair<int,int>;
vector<vector<int>> sheet;
pii getRowCol(string cell){
int pos = 0;
int col = -1;
if(cell[0]>='A' and cell[0]<='Z'){
col = cell[0]-'A';
pos++;
class TaskManager {
using pii = pair<int,int>;
priority_queue<pii> maxheap;
unordered_map<int,pii> tid_priority_uid;
public:
TaskManager(vector<vector<int>>& tasks) {
for(auto& task: tasks){
maxheap.push({task[2],task[1]});
tid_priority_uid[task[1]] = {task[2],task[0]};
}
class FoodRatings {
#define pis pair<int,string>
struct compare {
bool operator()(const pis& a, const pis& b) const {
if (a.first != b.first)
return a.first < b.first; // higher rating = higher priority
return a.second > b.second; // lexicographically smaller name = higher priority
}
};
class Solution {
int findGCD(int a,int b){
if(a==0)
return b;
return findGCD(b%a, a);
}
public:
vector<int> replaceNonCoprimes(vector<int>& nums) {
vector<int> st;
int n = nums.size();
class Solution {
public:
bool doesAliceWin(string s) {
for(int i=0;i<s.size();++i)
if(s[i]=='a' or s[i]=='e' or s[i]=='i' or s[i]=='o' or s[i]=='u')
return true;
return false;
}
};
/*
class Solution {
#define pci pair<char,int>
int isVowel(const char& c){
return (c=='A' or c=='a' or c=='E' or c=='e' or c=='I' or c=='i' or c=='O' or c=='o' or c=='U' or c=='u');
}
public:
string sortVowels(string s) {
int n=s.size();
// Step-1: Count vowel frequency
class Solution {
bool cantTalk(const unordered_set<int>& s1, const unordered_set<int>& s2) {
for (int lang1 : s1)
if (s2.count(lang1)) return false;
return true;
}
public:
int minimumTeachings(int n, vector<vector<int>>& languages, vector<vector<int>>& friendships) {
int m = languages.size();
// STEP-1: person -> languages (1-based indexing for persons)
// C++: DP Tabulation
class Solution {
public:
int peopleAwareOfSecret(int n, int delay, int forget) {
int MOD = 1e9+7;
vector<int> dp(n+1);
dp[1] = 1;
int win_count = 0;
for(int curr=2;curr<=n;++curr){
if(curr-delay > 0)
class Solution {
public:
vector<int> getNoZeroIntegers(int n) {
int a = 0;
int b = 0;
int power = 1;
while(n){
int digit = n%10;
if(digit==0){
class Solution {
public:
int numberOfPairs(vector<vector<int>>& points) {
int n = points.size();
sort(points.begin(),points.end(),[](const vector<int>& p1,const vector<int>& p2){
return p1[0]==p2[0] ? p1[1]>p2[1] : p1[0]<p2[0];
});
int count = 0;
for(int A=0;A<n-1;++A){