Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
Google Forms: Sign-in | Rohit Awasthi | 42 comments
Hiring an Asst. Manager for my team in Flipkart !
Job role- Data Analytics and Planning in category
An ideal candidate would have strong Excel and data analysis skills with 0-2 years of experience.
Location- Bangalore (Work from office)
Interested candidatesโฆ
Job role- Data Analytics and Planning in category
An ideal candidate would have strong Excel and data analysis skills with 0-2 years of experience.
Location- Bangalore (Work from office)
Interested candidatesโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Infraveo Technologies is hiring for Fullstack Developer (Frontend)
Experience: 0-1 years
Apply here: https://www.linkedin.com/jobs/view/fullstack-developer-frontend-at-infraveo-technologies-4073943384/
Experience: 0-1 years
Apply here: https://www.linkedin.com/jobs/view/fullstack-developer-frontend-at-infraveo-technologies-4073943384/
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Ismartrecruit
<p><strong>What we offer:</strong></p>
<ul>
<li><strong>6 Months Internship followed with job opportunity</strong></li>
โฆ
<ul>
<li><strong>6 Months Internship followed with job opportunity</strong></li>
โฆ
What we offer:
6 Months Internship followed with job opportunity
Hands-on training and mentorship from industry experts.
Opportunity to work on live projects and client interactions.
A vibrant and learning-driven work culture.
5 days a weekโฆ
6 Months Internship followed with job opportunity
Hands-on training and mentorship from industry experts.
Opportunity to work on live projects and client interactions.
A vibrant and learning-driven work culture.
5 days a weekโฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Flutter Internship Application form
https://docs.google.com/forms/d/e/1FAIpQLSfAeQa1raoh7Ci5jBY85CDrJ0WzZk5qTxRjvkzfHPyn5BNf3Q/viewform
https://docs.google.com/forms/d/e/1FAIpQLSfAeQa1raoh7Ci5jBY85CDrJ0WzZk5qTxRjvkzfHPyn5BNf3Q/viewform
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Vance (YC W22) is hiring for Frontend Engineering Intern
Experience: 0-1 year's
Expected Stipend: 5-7 LPA
Apply here: https://www.linkedin.com/jobs/view/frontend-engineering-intern-at-vance-yc-w22-4075138175/?originalSubdomain=in
Experience: 0-1 year's
Expected Stipend: 5-7 LPA
Apply here: https://www.linkedin.com/jobs/view/frontend-engineering-intern-at-vance-yc-w22-4075138175/?originalSubdomain=in
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
#fresher looking for data science and data engineering roles, please send your resume with a brief introduction of your skills and strengths to ๐ priya1.sharma@infogain.com, c to neelima.trehan@infogain.com. Good opportunity in a tough market!!
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Nutanix Hiring !!
Role - SDET
Experience: 0 to 1 year
Expected CTC- 24 to 30 LPA
๐ปApply Link: https://careers.nutanix.com/en/jobs/27886/sdet-automation-0-1-years/
Role - SDET
Experience: 0 to 1 year
Expected CTC- 24 to 30 LPA
๐ปApply Link: https://careers.nutanix.com/en/jobs/27886/sdet-automation-0-1-years/
Nutanix Careers
SDET- Automation [ 0-1 years]
Hungry, Humble, Honest, with Heart. The Opportunity We are looking for engineers who are passionate about working on scalable distributed systems. You will be part of the Nutanix Cassandra team, which owns the metadata part of the Nutanix Storage Virtualization.โฆ
๐2
vector<int> countVisibleTowers(vector<int>& height) {
int n = height.size();
vector<int> visible(n, 0);
stack<int> s;
for (int i = 0; i < n; ++i) {
visible[i] += s.size();
while (!s.empty() && height[s.top()] <= height[i]) {
s.pop();
}
s.push(i);
}
while (!s.empty()) s.pop();
for (int i = n - 1; i >= 0; --i) {
visible[i] += s.size();
while (!s.empty() && height[s.top()] <= height[i]) {
s.pop();
}
s.push(i);
}
return visible;
}
Rippling โ
๐1
#include <iostream>
using namespace std;
const int MOD = 1000000007;
long countWays(int n) {
long long dp[100001][2] = {0};
dp[1][0] = 1;
dp[1][1] = 0;
if(n >= 2) {
dp[2][0] = 1;
dp[2][1] = 1;
}
for(int i = 3; i <= n; i++) {
dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % MOD;
dp[i][1] = dp[i-2][0] % MOD;
}
return (dp[n][0] + dp[n][1]) % MOD;
}
int main() {
int n;
cin >> n;
cout << countWays(n) << endl;
return 0;
}
Vimo โ
using namespace std;
const int MOD = 1000000007;
long countWays(int n) {
long long dp[100001][2] = {0};
dp[1][0] = 1;
dp[1][1] = 0;
if(n >= 2) {
dp[2][0] = 1;
dp[2][1] = 1;
}
for(int i = 3; i <= n; i++) {
dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % MOD;
dp[i][1] = dp[i-2][0] % MOD;
}
return (dp[n][0] + dp[n][1]) % MOD;
}
int main() {
int n;
cin >> n;
cout << countWays(n) << endl;
return 0;
}
Vimo โ
๐1๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Antino is Hiring!
Are you looking for a challenging and rewarding career where you can make a real impact?
We're seeking fresh talent for the following internship positions:
HR Intern: https://lnkd.in/gqnizVXY
Account Intern:https://lnkd.in/gd6mmdMz
Motion Graphic Intern:https://lnkd.in/gMzMvSAe
Business Development Intern:https://lnkd.in/gPaiGZ53
Job Locations: Gurgaon/Bangalore
Are you looking for a challenging and rewarding career where you can make a real impact?
We're seeking fresh talent for the following internship positions:
HR Intern: https://lnkd.in/gqnizVXY
Account Intern:https://lnkd.in/gd6mmdMz
Motion Graphic Intern:https://lnkd.in/gMzMvSAe
Business Development Intern:https://lnkd.in/gPaiGZ53
Job Locations: Gurgaon/Bangalore
lnkd.in
LinkedIn
This link will take you to a page thatโs not on LinkedIn
#include <bits/stdc++.h>
#define ll long long
using namespace std;
string mergePalindrome(string&a,string&b)
{
ll n=a.length();
ll m=b.length();
unordered_map<char,ll> m1,m2;
for(char it:a) m1[it]++;
for(char it:b) m2[it]++;
string mid="",ans="";
for (char i='a';i<='z';i++)
{
if(m1[i]%2 and m2[i]%2 and mid.length()<=1) mid=string(2,i);
if((m1[i]%2 or m2[i]%2) and mid.length()==0) mid=i;
ans+=string((m1[i]/2+m2[i]/2),i);
}
string tt=ans;
if (mid.length()==2)
{
tt+=mid[0];
ans+=mid[0];
sort(begin(ans),end(ans));
tt=ans+string(rbegin(ans),rend(ans));
}
else tt+=mid+string(rbegin(ans),rend(ans));
return tt;
}
signed main()
{
string s,t; cin>>s>>t;
cout<<solve(s,t);
return 0;
}
Merging palindromes โ
#define ll long long
using namespace std;
string mergePalindrome(string&a,string&b)
{
ll n=a.length();
ll m=b.length();
unordered_map<char,ll> m1,m2;
for(char it:a) m1[it]++;
for(char it:b) m2[it]++;
string mid="",ans="";
for (char i='a';i<='z';i++)
{
if(m1[i]%2 and m2[i]%2 and mid.length()<=1) mid=string(2,i);
if((m1[i]%2 or m2[i]%2) and mid.length()==0) mid=i;
ans+=string((m1[i]/2+m2[i]/2),i);
}
string tt=ans;
if (mid.length()==2)
{
tt+=mid[0];
ans+=mid[0];
sort(begin(ans),end(ans));
tt=ans+string(rbegin(ans),rend(ans));
}
else tt+=mid+string(rbegin(ans),rend(ans));
return tt;
}
signed main()
{
string s,t; cin>>s>>t;
cout<<solve(s,t);
return 0;
}
Merging palindromes โ
๐1
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((lli)a.size())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct Line {
int x1, y1, x2, y2;
bool vertical() const { return x1 == x2; }
bool horizontal() const { return y1 == y2; }
bool diagonal() const { return abs(x2 - x1) == abs(y2 - y1); }
};
int N, K;
vector<Line> lines;
map<pair<int, int>, vector<int>> ptsMap;
void add(const Line& line, int idx) {
int x1 = line.x1, y1 = line.y1;
int x2 = line.x2, y2 = line.y2;
if (line.vertical()) {
int yStart = min(y1, y2);
int yEnd = max(y1, y2);
for(int y = yStart; y <= yEnd; y++) {
ptsMap[{x1, y}].push_back(idx);
}
}
else if (line.horizontal()) {
int xStart = min(x1, x2);
int xEnd = max(x1, x2);
for(int x = xStart; x <= xEnd; x++) {
ptsMap[{x, y1}].push_back(idx);
}
}
else if (line.diagonal()) {
int steps = abs(x2 - x1);
int dx = (x2 - x1) / steps;
int dy = (y2 - y1) / steps;
for(int i = 0; i <= steps; i++) {
int x = x1 + i * dx;
int y = y1 + i * dy;
ptsMap[{x, y}].push_back(idx);
}
}
}
int ff(int x1, int y1, int x2, int y2) {
if(x1 == x2) return abs(y1 - y2);
if(y1 == y2) return abs(x1 - x2);
if(abs(x1 - x2) == abs(y1 - y2)) return abs(x1 - x2);
return 0;
}
int solve(const pair<int, int>& pt, const vector<int>& lst) {
vector<int> d;
for(auto lIdx : lst) {
const Line& ln = lines[lIdx];
bool oneSided = (pt.first == ln.x1 && pt.second == ln.y1) ||
(pt.first == ln.x2 && pt.second == ln.y2);
if(oneSided) {
int ex = (pt.first == ln.x1 && pt.second == ln.y1) ? ln.x2 : ln.x1;
int ey = (pt.first == ln.x1 && pt.second == ln.y1) ? ln.y2 : ln.y1;
d.push_back(ff(pt.first, pt.second, ex, ey));
}
else {
d.push_back(ff(pt.first, pt.second, ln.x1, ln.y1));
d.push_back(ff(pt.first, pt.second, ln.x2, ln.y2));
}
}
return d.empty() ? 0 : *min_element(d.begin(), d.end());
}
void solve() {
cin >> N;
lines.resize(N);
for(int i = 0; i < N; i++) {
cin >> lines[i].x1 >> lines[i].y1 >> lines[i].x2 >> lines[i].y2;
add(lines[i], i);
}
cin >> K;
int total = 0;
for(auto &[pt, lst] : ptsMap) {
if(sz(lst) == K) {
total += solve(pt, lst);
}
}
cout << total << "\n";
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
solve();
return 0;
}
Magic Stars โ
TCS Codevita
Source : ishaan
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((lli)a.size())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct Line {
int x1, y1, x2, y2;
bool vertical() const { return x1 == x2; }
bool horizontal() const { return y1 == y2; }
bool diagonal() const { return abs(x2 - x1) == abs(y2 - y1); }
};
int N, K;
vector<Line> lines;
map<pair<int, int>, vector<int>> ptsMap;
void add(const Line& line, int idx) {
int x1 = line.x1, y1 = line.y1;
int x2 = line.x2, y2 = line.y2;
if (line.vertical()) {
int yStart = min(y1, y2);
int yEnd = max(y1, y2);
for(int y = yStart; y <= yEnd; y++) {
ptsMap[{x1, y}].push_back(idx);
}
}
else if (line.horizontal()) {
int xStart = min(x1, x2);
int xEnd = max(x1, x2);
for(int x = xStart; x <= xEnd; x++) {
ptsMap[{x, y1}].push_back(idx);
}
}
else if (line.diagonal()) {
int steps = abs(x2 - x1);
int dx = (x2 - x1) / steps;
int dy = (y2 - y1) / steps;
for(int i = 0; i <= steps; i++) {
int x = x1 + i * dx;
int y = y1 + i * dy;
ptsMap[{x, y}].push_back(idx);
}
}
}
int ff(int x1, int y1, int x2, int y2) {
if(x1 == x2) return abs(y1 - y2);
if(y1 == y2) return abs(x1 - x2);
if(abs(x1 - x2) == abs(y1 - y2)) return abs(x1 - x2);
return 0;
}
int solve(const pair<int, int>& pt, const vector<int>& lst) {
vector<int> d;
for(auto lIdx : lst) {
const Line& ln = lines[lIdx];
bool oneSided = (pt.first == ln.x1 && pt.second == ln.y1) ||
(pt.first == ln.x2 && pt.second == ln.y2);
if(oneSided) {
int ex = (pt.first == ln.x1 && pt.second == ln.y1) ? ln.x2 : ln.x1;
int ey = (pt.first == ln.x1 && pt.second == ln.y1) ? ln.y2 : ln.y1;
d.push_back(ff(pt.first, pt.second, ex, ey));
}
else {
d.push_back(ff(pt.first, pt.second, ln.x1, ln.y1));
d.push_back(ff(pt.first, pt.second, ln.x2, ln.y2));
}
}
return d.empty() ? 0 : *min_element(d.begin(), d.end());
}
void solve() {
cin >> N;
lines.resize(N);
for(int i = 0; i < N; i++) {
cin >> lines[i].x1 >> lines[i].y1 >> lines[i].x2 >> lines[i].y2;
add(lines[i], i);
}
cin >> K;
int total = 0;
for(auto &[pt, lst] : ptsMap) {
if(sz(lst) == K) {
total += solve(pt, lst);
}
}
cout << total << "\n";
}
int32_t main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
solve();
return 0;
}
Magic Stars โ
TCS Codevita
Source : ishaan
๐2
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
\#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((int)a.size())
#define YES cout << "YES";
#define NO cout << "NO";
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct game {
int start;
int end;
string type;
};
bool solve(vector<int>& dieRolls, unordered_map<int, int>& board, int finalPos) {
int position = 1;
for (int roll : dieRolls) {
if (position + roll <= 100) {
position += roll;
}
while (board.find(position) != board.end()) {
position = board[position];
}
}
if (board.find(position) != board.end()) {
return false;
}
return position == finalPos;
}
void solve()
{
int N;
cin >> N;
vector<game> snakesLadders;
unordered_map<int, int> board;
for (int i = 0; i < N; ++i) {
int start, end;
cin >> start >> end;
game sl;
sl.start = start;
sl.end = end;
if (start > end) {
sl.type = "Snake";
} else {
sl.type = "Ladder";
}
snakesLadders.push_back(sl);
board[start] = end;
}
vector<int> remainingInput;
int num;
while (cin >> num) {
remainingInput.push_back(num);
}
if (remainingInput.empty()) {
cout << "Not reachable";
return;
}
int finalPos = remainingInput.back();
remainingInput.pop_back();
vector<int> dieRolls = remainingInput;
if (solve(dieRolls, board, finalPos)) {
cout << "Not affected";
return;
}
for (size_t i = 0; i < snakesLadders.size(); ++i) {
game& sl = snakesLadders[i];
board.erase(sl.start);
int newStart = sl.end;
int newEnd = sl.start;
string newType = (sl.type == "Snake") ? "Ladder" : "Snake";
if (newStart == 1 || board.find(newStart) != board.end()) {
board[sl.start] = sl.end;
continue;
}
board[newStart] = newEnd;
if (solve(dieRolls, board, finalPos)) {
cout << newType << " " << newStart << " " << newEnd;
return ;
}
board.erase(newStart);
board[sl.start] = sl.end;
}
cout << "Not reachable";
return ;
}
int32_t main()
{
int tc = 1;
// cin >> tc;
while (tc--)
{
solve();
}
return 0;
}
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((int)a.size())
#define YES cout << "YES";
#define NO cout << "NO";
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct game {
int start;
int end;
string type;
};
bool solve(vector<int>& dieRolls, unordered_map<int, int>& board, int finalPos) {
int position = 1;
for (int roll : dieRolls) {
if (position + roll <= 100) {
position += roll;
}
while (board.find(position) != board.end()) {
position = board[position];
}
}
if (board.find(position) != board.end()) {
return false;
}
return position == finalPos;
}
void solve()
{
int N;
cin >> N;
vector<game> snakesLadders;
unordered_map<int, int> board;
for (int i = 0; i < N; ++i) {
int start, end;
cin >> start >> end;
game sl;
sl.start = start;
sl.end = end;
if (start > end) {
sl.type = "Snake";
} else {
sl.type = "Ladder";
}
snakesLadders.push_back(sl);
board[start] = end;
}
vector<int> remainingInput;
int num;
while (cin >> num) {
remainingInput.push_back(num);
}
if (remainingInput.empty()) {
cout << "Not reachable";
return;
}
int finalPos = remainingInput.back();
remainingInput.pop_back();
vector<int> dieRolls = remainingInput;
if (solve(dieRolls, board, finalPos)) {
cout << "Not affected";
return;
}
for (size_t i = 0; i < snakesLadders.size(); ++i) {
game& sl = snakesLadders[i];
board.erase(sl.start);
int newStart = sl.end;
int newEnd = sl.start;
string newType = (sl.type == "Snake") ? "Ladder" : "Snake";
if (newStart == 1 || board.find(newStart) != board.end()) {
board[sl.start] = sl.end;
continue;
}
board[newStart] = newEnd;
if (solve(dieRolls, board, finalPos)) {
cout << newType << " " << newStart << " " << newEnd;
return ;
}
board.erase(newStart);
board[sl.start] = sl.end;
}
cout << "Not reachable";
return ;
}
int32_t main()
{
int tc = 1;
// cin >> tc;
while (tc--)
{
solve();
}
return 0;
}
โค1๐1
from collections import defaultdict
import sys
def parse_recipes(n, recipes):
graph = defaultdict(list)
for recipe in recipes:
potion, ingredients = recipe.split('=')
graph[potion].append(ingredients.split('+'))
return graph
def min_orbs(target, graph, cache):
if target in cache:
return cache[target]
if target not in graph:
cache[target] = 0
return 0
min_cost = sys.maxsize
for recipe in graph[target]:
cost = len(recipe) - 1
for ingredient in recipe:
cost += min_orbs(ingredient, graph, cache)
min_cost = min(min_cost, cost)
cache[target] = min_cost
return min_cost
n = int(input())
recipes = [input().strip() for _ in range(n)]
target_potion = input().strip()
graph = parse_recipes(n, recipes)
cache = {}
result = min_orbs(target_potion, graph, cache)
print(result, end="")
Frenkitsen
TCS Codevita โ
๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <bits/stdc++.h>
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((int)a.size())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct Flight {
string src;
string to;
int dt;
int at;
int cost;
};
int parse_time(const string& time_str) {
int hour = stoi(time_str.substr(0, 2));
int minute = stoi(time_str.substr(3, 2));
string am_pm = time_str.substr(5, 2);
if (am_pm == "Am") {
if (hour == 12) hour = 0;
} else if (am_pm == "Pm") {
if (hour != 12) hour += 12;
}
return hour * 60 + minute;
}
void solve()
{
int N;
cin >> N;
vector<Flight> fff(N);
unordered_map<string, vector<Flight>> mp;
for (int i = 0; i < N; ++i) {
string src, to, des, arrival_str;
int cost;
cin >> src >> to >> des >> arrival_str >> cost;
int dt = parse_time(des);
int at = parse_time(arrival_str);
Flight ff = {src, to, dt, at, cost};
fff[i] = ff;
mp[src].push_back(ff);
}
string src, des;
cin >> src >> des;
string edes, last;
cin >> edes >> last;
int earliest_dt = parse_time(edes);
int latest_at = parse_time(last);
typedef tuple<int, int, string> State;
priority_queue<State, vector<State>, greater<State>> pq;
for (const auto& ff : mp[src]) {
if (ff.dt >= earliest_dt) {
if (ff.at <= latest_at) {
pq.emplace(ff.cost, ff.at, ff.to);
}
}
}
unordered_map<string, int> ans;
unordered_map<string, int> at;
while (!pq.empty()) {
int cost_so_far, current_at;
string current_city;
tie(cost_so_far, current_at, current_city) = pq.top();
pq.pop();
if (ans.find(current_city) != ans.end()) {
if (cost_so_far > ans[current_city]) continue;
if (cost_so_far == ans[current_city] && current_at >= at[current_city]) continue;
}
ans[current_city] = cost_so_far;
at[current_city] = current_at;
if (current_city == des) {
cout << cost_so_far;
return ;
}
for (const auto& ff : mp[current_city]) {
if (ff.dt >= current_at) {
if (ff.dt >= earliest_dt && ff.at <= latest_at) {
int new_cost = cost_so_far + ff.cost;
pq.emplace(new_cost, ff.at, ff.to);
}
}
}
}
cout << "Impossible";
return ;
}
int32_t main()
{
int tc = 1;
// cin >> tc;
while (tc--)
{
solve();
}
return 0;
}
Flight optimizationโ
using namespace std;
#define loop(i, a, n) for (lli i = (a); i < (n); ++i)
#define loopD(i, a, n) for (lli i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define sz(a) ((int)a.size())
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define endl '\n'
#define fastio std::ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define pb push_back
#define pp pop_back()
#define fi first
#define si second
#define v(a) vector<int>(a)
#define vv(a) vector<vector<int>>(a)
#define present(c, x) ((c).find(x) != (c).end())
#define set_bits __builtin_popcountll
#define MOD 1000000007
#define int long long
typedef long long lli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli, lli> pll;
typedef pair<int, int> pii;
typedef unordered_map<int, int> umpi;
typedef map<int, int> mpi;
typedef vector<pii> vp;
typedef vector<lli> vll;
typedef vector<vll> vvll;
struct Flight {
string src;
string to;
int dt;
int at;
int cost;
};
int parse_time(const string& time_str) {
int hour = stoi(time_str.substr(0, 2));
int minute = stoi(time_str.substr(3, 2));
string am_pm = time_str.substr(5, 2);
if (am_pm == "Am") {
if (hour == 12) hour = 0;
} else if (am_pm == "Pm") {
if (hour != 12) hour += 12;
}
return hour * 60 + minute;
}
void solve()
{
int N;
cin >> N;
vector<Flight> fff(N);
unordered_map<string, vector<Flight>> mp;
for (int i = 0; i < N; ++i) {
string src, to, des, arrival_str;
int cost;
cin >> src >> to >> des >> arrival_str >> cost;
int dt = parse_time(des);
int at = parse_time(arrival_str);
Flight ff = {src, to, dt, at, cost};
fff[i] = ff;
mp[src].push_back(ff);
}
string src, des;
cin >> src >> des;
string edes, last;
cin >> edes >> last;
int earliest_dt = parse_time(edes);
int latest_at = parse_time(last);
typedef tuple<int, int, string> State;
priority_queue<State, vector<State>, greater<State>> pq;
for (const auto& ff : mp[src]) {
if (ff.dt >= earliest_dt) {
if (ff.at <= latest_at) {
pq.emplace(ff.cost, ff.at, ff.to);
}
}
}
unordered_map<string, int> ans;
unordered_map<string, int> at;
while (!pq.empty()) {
int cost_so_far, current_at;
string current_city;
tie(cost_so_far, current_at, current_city) = pq.top();
pq.pop();
if (ans.find(current_city) != ans.end()) {
if (cost_so_far > ans[current_city]) continue;
if (cost_so_far == ans[current_city] && current_at >= at[current_city]) continue;
}
ans[current_city] = cost_so_far;
at[current_city] = current_at;
if (current_city == des) {
cout << cost_so_far;
return ;
}
for (const auto& ff : mp[current_city]) {
if (ff.dt >= current_at) {
if (ff.dt >= earliest_dt && ff.at <= latest_at) {
int new_cost = cost_so_far + ff.cost;
pq.emplace(new_cost, ff.at, ff.to);
}
}
}
}
cout << "Impossible";
return ;
}
int32_t main()
{
int tc = 1;
// cin >> tc;
while (tc--)
{
solve();
}
return 0;
}
Flight optimizationโ
def solve(skills, p):
n = len(skills)
if n < 2 or p < 1 or p > (n * (n-1)) // 2:
return []
skills.sort()
from heapq import heappush, heappop
inefficiencies = []
for i in range(n-1):
for j in range(i+1, n):
inefficiency = abs(skills[i] - skills[j])
heappush(inefficiencies, inefficiency)
result = []
for _ in range(p):
if inefficiencies:
result.append(heappop(inefficiencies))
return result
Amazon โ
n = len(skills)
if n < 2 or p < 1 or p > (n * (n-1)) // 2:
return []
skills.sort()
from heapq import heappush, heappop
inefficiencies = []
for i in range(n-1):
for j in range(i+1, n):
inefficiency = abs(skills[i] - skills[j])
heappush(inefficiencies, inefficiency)
result = []
for _ in range(p):
if inefficiencies:
result.append(heappop(inefficiencies))
return result
Amazon โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Microsoft
Role: Research Science Intern
Batch eligible: 2024 and 2025 grads
Apply: https://jobs.careers.microsoft.com/global/en/job/1695728
Role: Research Science Intern
Batch eligible: 2024 and 2025 grads
Apply: https://jobs.careers.microsoft.com/global/en/job/1695728