๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
bool isValidMove(int x, int y, const vector<vector<char>>& maze, char forb) {
int rows = maze.size();
int cols = maze[0].size();
return x >= 0 && x < rows && y >= 0 && y < cols && maze[x][y] != forb;
}
int bfs(const vector<vector<char>>& maze, char forb) {
int rows = maze.size();
int cols = maze[0].size();
pair<int, int> start = make_pair(0, 0);
pair<int, int> end = make_pair(rows - 1, cols - 1);
vector<vector<bool>> visited(rows, vector<bool>(cols, false));
deque<tuple<int, int, int>> queue;
queue.push_back(make_tuple(start.first, start.second, 0));
while (!queue.empty()) {
int x, y, length;
tie(x, y, length) = queue.front();
queue.pop_front();
if (make_pair(x, y) == end) {
return length;
}
if (!visited[x][y]) {
visited[x][y] = true;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
for (int i = 0; i < 4; ++i) {
int new_x = x + dx[i];
int new_y = y + dy[i];
if (isValidMove(new_x, new_y, maze, forb)) {
queue.push_back(make_tuple(new_x, new_y, length + 1));
}
}
}
}
return -1; // No path found
}
The Maze Runner โ
int rows = maze.size();
int cols = maze[0].size();
return x >= 0 && x < rows && y >= 0 && y < cols && maze[x][y] != forb;
}
int bfs(const vector<vector<char>>& maze, char forb) {
int rows = maze.size();
int cols = maze[0].size();
pair<int, int> start = make_pair(0, 0);
pair<int, int> end = make_pair(rows - 1, cols - 1);
vector<vector<bool>> visited(rows, vector<bool>(cols, false));
deque<tuple<int, int, int>> queue;
queue.push_back(make_tuple(start.first, start.second, 0));
while (!queue.empty()) {
int x, y, length;
tie(x, y, length) = queue.front();
queue.pop_front();
if (make_pair(x, y) == end) {
return length;
}
if (!visited[x][y]) {
visited[x][y] = true;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
for (int i = 0; i < 4; ++i) {
int new_x = x + dx[i];
int new_y = y + dy[i];
if (isValidMove(new_x, new_y, maze, forb)) {
queue.push_back(make_tuple(new_x, new_y, length + 1));
}
}
}
}
return -1; // No path found
}
The Maze Runner โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Rubrik
Role: Software Engineer Intern
Batch eligible: 2024 grads only
Stipend: 1.5 Lac per month
Apply: https://www.rubrik.com/company/careers/departments/job.5225502.1929
Share with Friends โ๐ป
Role: Software Engineer Intern
Batch eligible: 2024 grads only
Stipend: 1.5 Lac per month
Apply: https://www.rubrik.com/company/careers/departments/job.5225502.1929
Share with Friends โ๐ป
Rubrik
Error
int maximumLearning(vector<int>& articles, vector<int>& iv, int p) {
int n = articles.size();
vector<pair<int, int>> associated;
for (int i = 0; i < n; ++i) {
associated.push_back({2 * articles[i], iv[i]});
}
int maxIntelValue = 0;
for (int mask = 0; mask < (1 << n); ++mask) {
int pagesRead = 0;
int currentValue = 0;
for (int i = 0; i < n; ++i) {
if (mask & (1 << i)) {
if (pagesRead + associated[i].first <= p) {
pagesRead += associated[i].first;
currentValue += associated[i].second;
}
}
}
maxIntelValue = max(maxIntelValue, currentValue);
}
return maxIntelValue;
}
Atlassian โ
int n = articles.size();
vector<pair<int, int>> associated;
for (int i = 0; i < n; ++i) {
associated.push_back({2 * articles[i], iv[i]});
}
int maxIntelValue = 0;
for (int mask = 0; mask < (1 << n); ++mask) {
int pagesRead = 0;
int currentValue = 0;
for (int i = 0; i < n; ++i) {
if (mask & (1 << i)) {
if (pagesRead + associated[i].first <= p) {
pagesRead += associated[i].first;
currentValue += associated[i].second;
}
}
}
maxIntelValue = max(maxIntelValue, currentValue);
}
return maxIntelValue;
}
Atlassian โ
typedef long long ll;
pair<ll, ll> dfs(ll curr, ll prv, const vector<vector<ll>>& adj, const vector<ll>& connect_val, ll k) {
ll tmp = connect_val[curr - 1];
pair<ll, ll> ans = {tmp, tmp};
for (ll x : adj[curr]) {
if (x == prv) continue;
auto tmp = dfs(x, curr, adj, connect_val, k);
ans.second += tmp.second;
ans.first += tmp.first;
}
ans.first = max(ans.first, -k);
return ans;
}
long long get_max_efficiency(ll connect_nodes, const vector<ll>& connect_from, const vector<ll>& connect_to, const vector<ll>& connect_val, ll k) {
ll n = connect_nodes;
vector<vector<ll>> adj(n + 1);
for (ll i = 0; i < connect_from.size(); i++) {
ll u = connect_from[i], v = connect_to[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
return dfs(1, 0, adj, connect_val, k).first;
}
Graph one
Atlassian โ
pair<ll, ll> dfs(ll curr, ll prv, const vector<vector<ll>>& adj, const vector<ll>& connect_val, ll k) {
ll tmp = connect_val[curr - 1];
pair<ll, ll> ans = {tmp, tmp};
for (ll x : adj[curr]) {
if (x == prv) continue;
auto tmp = dfs(x, curr, adj, connect_val, k);
ans.second += tmp.second;
ans.first += tmp.first;
}
ans.first = max(ans.first, -k);
return ans;
}
long long get_max_efficiency(ll connect_nodes, const vector<ll>& connect_from, const vector<ll>& connect_to, const vector<ll>& connect_val, ll k) {
ll n = connect_nodes;
vector<vector<ll>> adj(n + 1);
for (ll i = 0; i < connect_from.size(); i++) {
ll u = connect_from[i], v = connect_to[i];
adj[u].push_back(v);
adj[v].push_back(u);
}
return dfs(1, 0, adj, connect_val, k).first;
}
Graph one
Atlassian โ
ll solve(ll n, ll m, ll k) {
vector<int>a(n, 1);
k--;
ll sum = n, maxjob = 1;
while(sum <= m) {
a[k]++;
maxjob = a[k];
for(ll i = k - 1; i >= 0; i--) {
if(a[i + 1] - a[i] > 1) a[i]++;
}
for(ll i = k + 1; i < n; i++) {
if(a[i - 1] - a[i] > 1) a[i]++;
}
sum = 0;
for(ll i = 0; i < n; i++) sum += a[i];
}
}
Job one
Atlassian โ
vector<int>a(n, 1);
k--;
ll sum = n, maxjob = 1;
while(sum <= m) {
a[k]++;
maxjob = a[k];
for(ll i = k - 1; i >= 0; i--) {
if(a[i + 1] - a[i] > 1) a[i]++;
}
for(ll i = k + 1; i < n; i++) {
if(a[i - 1] - a[i] > 1) a[i]++;
}
sum = 0;
for(ll i = 0; i < n; i++) sum += a[i];
}
}
Job one
Atlassian โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: MasterCard
Role: Software Engineer 1
Batch eligible: 2022 and 2023 grads
Apply: https://careers.mastercard.com/us/en/job/MASRUSR201744EXTERNALENUS/Software-Engineer-I
Role: Software Engineer 1
Batch eligible: 2022 and 2023 grads
Apply: https://careers.mastercard.com/us/en/job/MASRUSR201744EXTERNALENUS/Software-Engineer-I
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
ZS is hiring for DAA
Qualifications:
โข 0-2 years of experience.
โข Bachelor's degree in any engineering discipline, MIS, operations management, or other relevant degree.
โข Proficiency in MS Excel, Python, SQL and regression techniques.
if you interested send ur resume &Referral
varunvj181@gmail.com
Qualifications:
โข 0-2 years of experience.
โข Bachelor's degree in any engineering discipline, MIS, operations management, or other relevant degree.
โข Proficiency in MS Excel, Python, SQL and regression techniques.
if you interested send ur resume &Referral
varunvj181@gmail.com
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
const int MAXN = 105;
const int LOGN = 20;
int n;
vector<int> adj[MAXN];
char label[MAXN];
int parent[MAXN][LOGN];
int depth[MAXN];
int freq[MAXN][26];
void dfs(int node, int par, int d) {
parent[node][0] = par;
depth[node] = d;
for (int i = 1; i < LOGN; ++i) {
if (parent[node][i - 1] != -1) {
parent[node][i] = parent[parent[node][i - 1]][i - 1];
}
}
for (int child : adj[node]) {
if (child != par) {
dfs(child, node, d + 1);
}
}
}
void preprocess() {
memset(parent, -1, sizeof(parent));
dfs(1, -1, 0);
for (int node = 1; node <= n; ++node) {
freq[node][label[node] - 'a']++;
for (int i = 0; i < 26; ++i) {
freq[node][i] += freq[parent[node][0]][i];
}
}
}
int lca(int u, int v) {
if (depth[u] < depth[v]) {
swap(u, v);
}
int diff = depth[u] - depth[v];
for (int i = 0; i < LOGN; ++i) {
if ((diff >> i) & 1) {
u = parent[u][i];
}
}
if (u == v) {
return u;
}
for (int i = LOGN - 1; i >= 0; --i) {
if (parent[u][i] != parent[v][i]) {
u = parent[u][i];
v = parent[v][i];
}
}
return parent[u][0];
}
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> label[i];
}
for (int i = 0; i < n - 1; ++i) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
preprocess();
int q;
cin >> q;
while (q--) {
int u, v;
char c;
cin >> u >> v >> c;
int l = lca(u, v);
int ans = freq[u][c - 'a'] + freq[v][c - 'a'] - 2 * freq[l][c - 'a'] + (label[l] == c);
cout << ans << endl;
}
return 0;
}
Colored Vertex โ
#include <vector>
#include <cstring>
using namespace std;
const int MAXN = 105;
const int LOGN = 20;
int n;
vector<int> adj[MAXN];
char label[MAXN];
int parent[MAXN][LOGN];
int depth[MAXN];
int freq[MAXN][26];
void dfs(int node, int par, int d) {
parent[node][0] = par;
depth[node] = d;
for (int i = 1; i < LOGN; ++i) {
if (parent[node][i - 1] != -1) {
parent[node][i] = parent[parent[node][i - 1]][i - 1];
}
}
for (int child : adj[node]) {
if (child != par) {
dfs(child, node, d + 1);
}
}
}
void preprocess() {
memset(parent, -1, sizeof(parent));
dfs(1, -1, 0);
for (int node = 1; node <= n; ++node) {
freq[node][label[node] - 'a']++;
for (int i = 0; i < 26; ++i) {
freq[node][i] += freq[parent[node][0]][i];
}
}
}
int lca(int u, int v) {
if (depth[u] < depth[v]) {
swap(u, v);
}
int diff = depth[u] - depth[v];
for (int i = 0; i < LOGN; ++i) {
if ((diff >> i) & 1) {
u = parent[u][i];
}
}
if (u == v) {
return u;
}
for (int i = LOGN - 1; i >= 0; --i) {
if (parent[u][i] != parent[v][i]) {
u = parent[u][i];
v = parent[v][i];
}
}
return parent[u][0];
}
int main() {
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> label[i];
}
for (int i = 0; i < n - 1; ++i) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
preprocess();
int q;
cin >> q;
while (q--) {
int u, v;
char c;
cin >> u >> v >> c;
int l = lca(u, v);
int ans = freq[u][c - 'a'] + freq[v][c - 'a'] - 2 * freq[l][c - 'a'] + (label[l] == c);
cout << ans << endl;
}
return 0;
}
Colored Vertex โ
int lengthOfLIS(vector<int>& nums) {
vector<int>dp(nums.size(),1);
for(int i = 0; i < nums.size(); i++)
for(int j = i -1 ; j >= 0; j--)
if(nums[i] > nums[j]) dp[i] = max(dp[i], 1 + dp[j]);
return *max_element(dp.begin(),dp.end());
}
};
Good subsequenceโ
(Oracle)
vector<int>dp(nums.size(),1);
for(int i = 0; i < nums.size(); i++)
for(int j = i -1 ; j >= 0; j--)
if(nums[i] > nums[j]) dp[i] = max(dp[i], 1 + dp[j]);
return *max_element(dp.begin(),dp.end());
}
};
Good subsequenceโ
(Oracle)
string getLongestRegex(string a, string b, string c)
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
Amazon โ
{
const size_t n = a.size();
int idx = -1;
for (int i = 0; i < n; i++) {
if (c[i] != a[i] && c[i] != b[i]) { idx = i; }
}
if (idx == -1) return "-1";
string res;
for (int i = 0; i < n; i++) {
if (i == idx) {
string cur = "[";
for (int j = 'A'; j <= 'Z'; j++) if (j != c[i]) cur += j;
cur += "]";
res += cur;
} else {
res += "[ABCDEFGHIJKLMNOPQRSTUVWXYZ]";
}
}
return res;
}
Amazon โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Geopits DBA - Freshers Bangalore
Batch: 2023/2022
https://www.geopits.com/careers/dba-fresher-walk-in-interview.html?fbclid=IwAR2iYpwE-QyfahLoEGXJ5e0YaEl5d4RPNa_1fm5dzK3XDU9urTZ3gf-txnc
Batch: 2023/2022
https://www.geopits.com/careers/dba-fresher-walk-in-interview.html?fbclid=IwAR2iYpwE-QyfahLoEGXJ5e0YaEl5d4RPNa_1fm5dzK3XDU9urTZ3gf-txnc
Geopits
Careers | Geopits
Career at Geopits
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: EdgeVerve
Role: Software Engineer
Batch eligible: 2022 and 2023 grads
Apply: https://sjobs.brassring.com/TGnewUI/Search/home/HomeWithPreLoad?PageType=JobDetails&partnerid=26209&siteid=5179&Areq=1972BR#jobDetails=1192953_5179
Role: Software Engineer
Batch eligible: 2022 and 2023 grads
Apply: https://sjobs.brassring.com/TGnewUI/Search/home/HomeWithPreLoad?PageType=JobDetails&partnerid=26209&siteid=5179&Areq=1972BR#jobDetails=1192953_5179
Brassring
- EdgeVerve Systems Limited - Job Details
Job Details:
#include<bits/stdc++.h>
using namespace std;
vector<int> smallestRange(vector<vector<int>>& nums) {
vector<int>res={-100000,100000};
int k=nums.size();
int maxi=INT_MIN;
priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>pq;
for(int i=0;i<k;i++){
int num=nums[i][0];
vector<int>vec{num,0,i};
//0th minimum element of list
//1st index of element from the vector
//2nd index of the vector
//1st <4,0,0> 2nd <0,0,1> 3rd <5,0,2>
maxi=max(maxi,num);//took the max of members //5
pq.push(vec);
//<0,0,1><4,0,0><5,0,2>
}
while(true){//until condition breaks
vector<int>minval=pq.top();//<0,0,1>
pq.pop();//<4,0,0><5,0,2>
if(res[1]-res[0]>maxi-minval[0]){//5-0=5
res[0]=minval[0];//res[0]=0
res[1]=maxi;//res[1]=5
}
minval[1]++;//<0,1,1>,now from which we poped element in queue that min element containing vector , we should choose another element
vector<int>vec2=nums[minval[2]];//minval[2]=1,so <0,9,12,20>
if(minval[1]==vec2.size()){//1!=4
break;
}
else{
minval[0]=vec2[minval[1]];//minival[0]=vec2[1]=9
maxi=max(maxi,vec2[minval[1]]);//maxi=max(5,9)=9
pq.push(minval);//push <9,1,1>
}
}
return res;
}
int main(){
int m,n;
cin>>m>>n;
vector<vector<int>>v(m,vector<int>(n));
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>v[i][j];
}
sort(v[i].begin(),v[i].end());
}
vector<int> ans = smallestRange(v);
cout<<ans[0]<<" "<<ans[1];
}
E comm
Amazon โ
using namespace std;
vector<int> smallestRange(vector<vector<int>>& nums) {
vector<int>res={-100000,100000};
int k=nums.size();
int maxi=INT_MIN;
priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>pq;
for(int i=0;i<k;i++){
int num=nums[i][0];
vector<int>vec{num,0,i};
//0th minimum element of list
//1st index of element from the vector
//2nd index of the vector
//1st <4,0,0> 2nd <0,0,1> 3rd <5,0,2>
maxi=max(maxi,num);//took the max of members //5
pq.push(vec);
//<0,0,1><4,0,0><5,0,2>
}
while(true){//until condition breaks
vector<int>minval=pq.top();//<0,0,1>
pq.pop();//<4,0,0><5,0,2>
if(res[1]-res[0]>maxi-minval[0]){//5-0=5
res[0]=minval[0];//res[0]=0
res[1]=maxi;//res[1]=5
}
minval[1]++;//<0,1,1>,now from which we poped element in queue that min element containing vector , we should choose another element
vector<int>vec2=nums[minval[2]];//minval[2]=1,so <0,9,12,20>
if(minval[1]==vec2.size()){//1!=4
break;
}
else{
minval[0]=vec2[minval[1]];//minival[0]=vec2[1]=9
maxi=max(maxi,vec2[minval[1]]);//maxi=max(5,9)=9
pq.push(minval);//push <9,1,1>
}
}
return res;
}
int main(){
int m,n;
cin>>m>>n;
vector<vector<int>>v(m,vector<int>(n));
for(int i=0;i<m;i++){
for(int j=0;j<n;j++){
cin>>v[i][j];
}
sort(v[i].begin(),v[i].end());
}
vector<int> ans = smallestRange(v);
cout<<ans[0]<<" "<<ans[1];
}
E comm
Amazon โ
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
queue<int>q[N];
void solve(){
int n,k;
cin>>n;
// 1 2 3
vector<int>v(n);
int ans = 1e9;
for(int i=0;i<n;i++){
cin>>v[i];
}
cin>>k;
for(int i=0;i<n;i++){
if(q[v[i]].size()==k)q[v[i]].pop();
if(q[v[i]].size()==k-1){
ans = min(i-q[v[i]].front(),ans);
}
q[v[i]].push(i);
}
if(ans == 1e9){cout<<"-1"<<endl;return;}
cout<<ans-k+1<<endl;
return;
}
signed main() {
solve();
return 0;
}
this was video streaming โ
Amazon
using namespace std;
const int N = 1e5+1;
queue<int>q[N];
void solve(){
int n,k;
cin>>n;
// 1 2 3
vector<int>v(n);
int ans = 1e9;
for(int i=0;i<n;i++){
cin>>v[i];
}
cin>>k;
for(int i=0;i<n;i++){
if(q[v[i]].size()==k)q[v[i]].pop();
if(q[v[i]].size()==k-1){
ans = min(i-q[v[i]].front(),ans);
}
q[v[i]].push(i);
}
if(ans == 1e9){cout<<"-1"<<endl;return;}
cout<<ans-k+1<<endl;
return;
}
signed main() {
solve();
return 0;
}
this was video streaming โ
Amazon
int64_t getDiscountPairs(int x, vector<int> price)
{
const size_t n = price.size();
map<int, int64_t> cnt;
int64_t res = 0;
for (int i = 0; i < n; i++) {
int uu = price[i];
int v = uu % x;
if (v == 0) res += cnt[0];
else res += cnt[x - v];
cnt[v]++;
}
return res;
}
use long instead of int_64
Amazon โ
{
const size_t n = price.size();
map<int, int64_t> cnt;
int64_t res = 0;
for (int i = 0; i < n; i++) {
int uu = price[i];
int v = uu % x;
if (v == 0) res += cnt[0];
else res += cnt[x - v];
cnt[v]++;
}
return res;
}
use long instead of int_64
Amazon โ
Comic Books
Python 3โ
Python 3โ