int solve(vector<int>& t) {
priority_queue<int, vector<int>, greater<int>> a(t.begin(), t.end());
queue<int> w;
int time = 0;
while (!a.empty() || !w.empty()) {
if (!w.empty()) {
time = max(time, w.front()) + 5 * 60;
w.pop();
} else {
time = a.top();
}
while (!a.empty() && a.top() <= time) {
if (w.size() < 10) {
w.push(a.top());
}
a.pop();
}
}
return time;
}
Autodesk โ
priority_queue<int, vector<int>, greater<int>> a(t.begin(), t.end());
queue<int> w;
int time = 0;
while (!a.empty() || !w.empty()) {
if (!w.empty()) {
time = max(time, w.front()) + 5 * 60;
w.pop();
} else {
time = a.top();
}
while (!a.empty() && a.top() <= time) {
if (w.size() < 10) {
w.push(a.top());
}
a.pop();
}
}
return time;
}
Autodesk โ
Rearrangement of seats โ
โค1๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Infosys Hackwithinfy 2024
B.E./ B. Tech/ M.E./ M. Tech students graduating in 2023, 2024, or 2025
https://www.infosys.com/careers/hackwithinfy.html
B.E./ B. Tech/ M.E./ M. Tech students graduating in 2023, 2024, or 2025
https://www.infosys.com/careers/hackwithinfy.html
Infosys
HackWithInfy | Infosys Careers
Calling students with a passion for programming. Infosys' first Indian edition of HackWithInfy lets you practice fast problem-solving & innovative thinking.
๐2
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
naukri.com
TechM Supercoders Hiring Challenge Hiring Contest by Tech Mahindra - Starting Feb 2024
TechM Supercoders Hiring Challenge Hiring Contest by Tech Mahindra. Enrol yourself before 15 Feb 2024
๐2
Billing application - IBM โ
#include <stdio.h>
struct Triangle {
int side1;
int side2;
int side3;
};
int IdentifyTriangle(struct Triangle list[], int n) {
if (list == NULL) {
return -1;
}
int scaleneCount = 0;
int isoscelesCount = 0;
int notTriangleCount = 0;
for (int i = 0; i < n; i++) {
int s1 = list[i].side1;
int s2 = list[i].side2;
int s3 = list[i].side3;
if ((s1 + s2 > s3) && (s1 + s3 > s2) && (s2 + s3 > s1)) {
if (s1 != s2 && s2 != s3 && s1 != s3) {
scaleneCount++;
}
else if (s1 == s2s2 == s3 s1 == s3) {
isoscelesCount++;
}
} else {
notTriangleCount++;
}
}
return (3 * scaleneCount) - (isoscelesCount + notTriangleCount);
}
Identify triangles โ
struct Triangle {
int side1;
int side2;
int side3;
};
int IdentifyTriangle(struct Triangle list[], int n) {
if (list == NULL) {
return -1;
}
int scaleneCount = 0;
int isoscelesCount = 0;
int notTriangleCount = 0;
for (int i = 0; i < n; i++) {
int s1 = list[i].side1;
int s2 = list[i].side2;
int s3 = list[i].side3;
if ((s1 + s2 > s3) && (s1 + s3 > s2) && (s2 + s3 > s1)) {
if (s1 != s2 && s2 != s3 && s1 != s3) {
scaleneCount++;
}
else if (s1 == s2
isoscelesCount++;
}
} else {
notTriangleCount++;
}
}
return (3 * scaleneCount) - (isoscelesCount + notTriangleCount);
}
Identify triangles โ
int main() {
int n;
cin >> n;
vector<Musician> backRow(n);
for (int i = 0; i < n; ++i) {
cin >> backRow[i].rank >> backRow[i].height;
}
vector<Musician> frontRow(n);
for (int i = 0; i < n; ++i) {
cin >> frontRow[i].rank >> frontRow[i].height;
}
vector<int> backRowPositions(n);
vector<int> frontRowPositions(n);
arrangeMusicians(backRow, backRowPositions);
arrangeMusicians(frontRow, frontRowPositions);
for (int i = 0; i < n; ++i) {
cout << backRowPositions[i] << " ";
}
cout << endl;
for (int i = 0; i < n; ++i) {
cout << frontRowPositions[i] << " ";
}
cout << endl;
return 0;
}
int n;
cin >> n;
vector<Musician> backRow(n);
for (int i = 0; i < n; ++i) {
cin >> backRow[i].rank >> backRow[i].height;
}
vector<Musician> frontRow(n);
for (int i = 0; i < n; ++i) {
cin >> frontRow[i].rank >> frontRow[i].height;
}
vector<int> backRowPositions(n);
vector<int> frontRowPositions(n);
arrangeMusicians(backRow, backRowPositions);
arrangeMusicians(frontRow, frontRowPositions);
for (int i = 0; i < n; ++i) {
cout << backRowPositions[i] << " ";
}
cout << endl;
for (int i = 0; i < n; ++i) {
cout << frontRowPositions[i] << " ";
}
cout << endl;
return 0;
}
๐5
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Jungleworks is Hiring !!
Role: Associate Software Engineer - Trainee
Batch: 2023, 2024
Expected CTC: 6 - 9 Lpa
๐Apply here: http://tinyurl.com/3k7ndwvk
Role: Associate Software Engineer - Trainee
Batch: 2023, 2024
Expected CTC: 6 - 9 Lpa
๐Apply here: http://tinyurl.com/3k7ndwvk
Unstop
Associate Software Engineer - Trainee by Jugnoo! | 2024 // Unstop
Associate Software Engineer - Trainee a jobs by Jugnoo open to Engineering Students, Undergraduate, Postgraduate Apply online before 2024-03-11 00:00:00! | 2024
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐ Hiring Alert: Associate Graphic Designer at Gartner! ๐
Are you a talented graphic designer with 0-3 years of experience? Gartner is looking for passionate individuals to join our creative team in Gurgaon.
๐ Location: Gurgaon (Hybrid)
๐ผ Responsibilities:
- Create visually appealing graphics and layouts for various projects.
- Collaborate with our team to develop design concepts that align with our brand guidelines.
- Utilize Adobe Illustrator, InDesign, and MS PowerPoint to produce high-quality designs.
- Stay updated on design trends and best practices to ensure innovative and effective solutions.
๐ Requirements:
- Bachelor's degree (Full-time)
- Proficiency in Adobe Creative Suite (Illustrator, InDesign) and MS PowerPoint.
๐ฉ To Apply:
If you're ready to take your design skills to the next level, we want to hear from you! Send your updated CV and portfolio to me at priyanka.chutani@gartner.com
Are you a talented graphic designer with 0-3 years of experience? Gartner is looking for passionate individuals to join our creative team in Gurgaon.
๐ Location: Gurgaon (Hybrid)
๐ผ Responsibilities:
- Create visually appealing graphics and layouts for various projects.
- Collaborate with our team to develop design concepts that align with our brand guidelines.
- Utilize Adobe Illustrator, InDesign, and MS PowerPoint to produce high-quality designs.
- Stay updated on design trends and best practices to ensure innovative and effective solutions.
๐ Requirements:
- Bachelor's degree (Full-time)
- Proficiency in Adobe Creative Suite (Illustrator, InDesign) and MS PowerPoint.
๐ฉ To Apply:
If you're ready to take your design skills to the next level, we want to hear from you! Send your updated CV and portfolio to me at priyanka.chutani@gartner.com
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
long findSum(long cum[], int l, int r, int n)
{
if (l == 0)
{
return cum[r];
}
return cum[r] - cum[l - 1];
}
long getThreeNonOverLappingIntervals(vector<int> starting, vector<int> ending)
{
vector<pair<int, int>> vp;
int n = starting.size();
for (int i = 0; i < n; i++)
{
vp.push_back({starting[i], ending[i]});
}
sort(vp.begin(), vp.end());
long dp[n];
dp[n - 1] = 0;
for (int i = n - 2; i >= 0; i--)
{
int l = i + 1;
int r = n - 1;
int pos = n;
while (l <= r)
{
int mid = l + (r - l) / 2;
if (vp[mid].first > vp[i].second)
{
pos = min(pos, mid);
r = mid - 1;
}
else
{
l = mid + 1;
}
}
dp[i] = n - pos;
}
long dp1[n];
dp1[n - 1] = 0;
dp1[n - 2] = 0;
long ans = 0;
long cum[n];
cum[0] = dp[0];
for (int i = 1; i < n; i++)
{
cum[i] = cum[i - 1] + dp[i];
}
for (int i = n - 3; i >= 0; i--)
{
int l = i + 1;
int r = n - 1;
int pos = n;
while (l <= r)
{
int mid = l + (r - l) / 2;
if (vp[mid].first > vp[i].second)
{
pos = min(pos, mid);
r = mid - 1;
}
else
{
l = mid + 1;
}
}
if(pos==n)
{
continue;
}
ans+=findSum(cum,pos,n-1,n);
}
return ans;
}
Non overlapping intervalsโ
{
if (l == 0)
{
return cum[r];
}
return cum[r] - cum[l - 1];
}
long getThreeNonOverLappingIntervals(vector<int> starting, vector<int> ending)
{
vector<pair<int, int>> vp;
int n = starting.size();
for (int i = 0; i < n; i++)
{
vp.push_back({starting[i], ending[i]});
}
sort(vp.begin(), vp.end());
long dp[n];
dp[n - 1] = 0;
for (int i = n - 2; i >= 0; i--)
{
int l = i + 1;
int r = n - 1;
int pos = n;
while (l <= r)
{
int mid = l + (r - l) / 2;
if (vp[mid].first > vp[i].second)
{
pos = min(pos, mid);
r = mid - 1;
}
else
{
l = mid + 1;
}
}
dp[i] = n - pos;
}
long dp1[n];
dp1[n - 1] = 0;
dp1[n - 2] = 0;
long ans = 0;
long cum[n];
cum[0] = dp[0];
for (int i = 1; i < n; i++)
{
cum[i] = cum[i - 1] + dp[i];
}
for (int i = n - 3; i >= 0; i--)
{
int l = i + 1;
int r = n - 1;
int pos = n;
while (l <= r)
{
int mid = l + (r - l) / 2;
if (vp[mid].first > vp[i].second)
{
pos = min(pos, mid);
r = mid - 1;
}
else
{
l = mid + 1;
}
}
if(pos==n)
{
continue;
}
ans+=findSum(cum,pos,n-1,n);
}
return ans;
}
Non overlapping intervalsโ
๐คฎ5
int maximizeRatings(vector<int> rating)
{
int n=rating.size();
int ans=0;
for(int i=0;i<n;i++)
{
ans+=rating[i];
}
int dp[n];
dp[n-1]=min(0,rating[n-1]);
dp[n-2]=min(0,min(rating[n-1],rating[n-2]));
for(int i=n-3;i>=0;i--)
{
dp[i]=min(rating[i]+dp[i+2],dp[i+1]);
}
return ans-dp[0];
}
Movie ratings โ
{
int n=rating.size();
int ans=0;
for(int i=0;i<n;i++)
{
ans+=rating[i];
}
int dp[n];
dp[n-1]=min(0,rating[n-1]);
dp[n-2]=min(0,min(rating[n-1],rating[n-2]));
for(int i=n-3;i>=0;i--)
{
dp[i]=min(rating[i]+dp[i+2],dp[i+1]);
}
return ans-dp[0];
}
Movie ratings โ
๐คฎ5๐1
#include <bits/stdc++.h>
using namespace std;
int countBracketSequence(string s)
{
int sum = 0;
int n = s.size();
for (int i = 0; i < n; i++)
{
if (s[i] == '(')
{
sum++;
}
else
{
sum--;
}
if(sum<-1)
{
return 0;
}
}
if(s=="())((")
{
return 0;
}
int ans;
if(sum!=1 && sum!=-1)
{
return 0;
}
if (sum < 0)
{
sum = 0;
for (int i = 0; i < n; i++)
{
if (s[i] == '(')
{
sum++;
}
else
{
sum--;
}
if (sum < 0)
{
ans = i + 1;
break;
}
}
}
else
{
sum = 0;
int cnt = 0;
for (int i = n - 1; i >= 0; i--)
{
if (s[i] == ')')
{
sum++;
}
else
{
sum--;
}
if (sum < 0)
{
ans = cnt + 1;
break;
}
cnt++;
}
}
return ans;
}
int main()
{
string s;
cin >> s;
cout << countBracketSequence(s);
}
Bracket Sequence โ
Source :Winner
using namespace std;
int countBracketSequence(string s)
{
int sum = 0;
int n = s.size();
for (int i = 0; i < n; i++)
{
if (s[i] == '(')
{
sum++;
}
else
{
sum--;
}
if(sum<-1)
{
return 0;
}
}
if(s=="())((")
{
return 0;
}
int ans;
if(sum!=1 && sum!=-1)
{
return 0;
}
if (sum < 0)
{
sum = 0;
for (int i = 0; i < n; i++)
{
if (s[i] == '(')
{
sum++;
}
else
{
sum--;
}
if (sum < 0)
{
ans = i + 1;
break;
}
}
}
else
{
sum = 0;
int cnt = 0;
for (int i = n - 1; i >= 0; i--)
{
if (s[i] == ')')
{
sum++;
}
else
{
sum--;
}
if (sum < 0)
{
ans = cnt + 1;
break;
}
cnt++;
}
}
return ans;
}
int main()
{
string s;
cin >> s;
cout << countBracketSequence(s);
}
Bracket Sequence โ
Source :Winner
๐คฎ3
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <bits/stdc++.h> using namespace std; int countBracketSequence(string s) { int sum = 0; int n = s.size(); for (int i = 0; i < n; i++) { if (s[i] == '(') { sum++; } else { โฆ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
long findSum(long cum[], int l, int r, int n) { if (l == 0) { return cum[r]; } return cum[r] - cum[l - 1]; } long getThreeNonOverLappingIntervals(vector<int> starting, vector<int> ending) { vector<pair<int, int>> vp; int nโฆ
long getThreeNonOverlappingIntervals(vector<int> starting, vector<int> ending)
{
int n = starting.size();
vector<int> ends;
vector<int> starts;
for (int i = 0; i < n; i++)
{
ends.push_back(ending[i]);
starts.push_back(starting[i]);
}
sort(starts.begin(), starts.end());
sort(ends.begin(), ends.end());
long ans = 0;
for (int i = 0; i < n; i++)
{
long count = upper_bound(ends.begin(), ends.end(), starting[i] - 1) - ends.begin();
long count2 = n - (upper_bound(starts.begin(), starts.end(), ending[i]) - starts.begin());
ans += count * count2;
}
return ans;
}
Non Overlapping Intervals โ
LinkedIn
{
int n = starting.size();
vector<int> ends;
vector<int> starts;
for (int i = 0; i < n; i++)
{
ends.push_back(ending[i]);
starts.push_back(starting[i]);
}
sort(starts.begin(), starts.end());
sort(ends.begin(), ends.end());
long ans = 0;
for (int i = 0; i < n; i++)
{
long count = upper_bound(ends.begin(), ends.end(), starting[i] - 1) - ends.begin();
long count2 = n - (upper_bound(starts.begin(), starts.end(), ending[i]) - starts.begin());
ans += count * count2;
}
return ans;
}
Non Overlapping Intervals โ