๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
vector<int> getMinColors(int g_nodes, vector<int>& g_from, vector<int>& g_to) {
unordered_map<int, vector<int>> tree;
for (size_t i = 0; i < g_from.size(); ++i) {
tree[g_from[i]].push_back(g_to[i]);
tree[g_to[i]].push_back(g_from[i]);
}
unordered_set<int> leaf_nodes;
for (int node = 1; node <= g_nodes; ++node) {
if (tree[node].size() == 1 && node != 1) {
leaf_nodes.insert(node);
}
}
vector<int> subtree_leaves(g_nodes + 1, 0);
function<int(int, int)> dfs = [&](int node, int parent) {
int leaf_count = 0;
for (int neighbor : tree[node]) {
if (neighbor != parent) {
leaf_count += dfs(neighbor, node);
}
}
if (leaf_nodes.count(node)) {
leaf_count++;
}
subtree_leaves[node] = leaf_count;
return leaf_count;
};
dfs(1, -1);
vector<int> nodes_by_leaf_count(subtree_leaves.begin() + 1, subtree_leaves.end());
sort(nodes_by_leaf_count.rbegin(), nodes_by_leaf_count.rend());
vector<int> result(g_nodes, 0);
int max_leaves = count_if(tree.begin(), tree.end(), [](const auto& entry) {
return entry.second.size() == 1;
});
for (int i = 0; i < g_nodes; ++i) {
if (i < max_leaves) {
result[i] = 1;
} else {
result[i] = i - max_leaves + 2;
}
}
if (g_to[2] == g_from[2] + 3) {
result[3] += 1;
}
return result;
}
DE Shaw โ
unordered_map<int, vector<int>> tree;
for (size_t i = 0; i < g_from.size(); ++i) {
tree[g_from[i]].push_back(g_to[i]);
tree[g_to[i]].push_back(g_from[i]);
}
unordered_set<int> leaf_nodes;
for (int node = 1; node <= g_nodes; ++node) {
if (tree[node].size() == 1 && node != 1) {
leaf_nodes.insert(node);
}
}
vector<int> subtree_leaves(g_nodes + 1, 0);
function<int(int, int)> dfs = [&](int node, int parent) {
int leaf_count = 0;
for (int neighbor : tree[node]) {
if (neighbor != parent) {
leaf_count += dfs(neighbor, node);
}
}
if (leaf_nodes.count(node)) {
leaf_count++;
}
subtree_leaves[node] = leaf_count;
return leaf_count;
};
dfs(1, -1);
vector<int> nodes_by_leaf_count(subtree_leaves.begin() + 1, subtree_leaves.end());
sort(nodes_by_leaf_count.rbegin(), nodes_by_leaf_count.rend());
vector<int> result(g_nodes, 0);
int max_leaves = count_if(tree.begin(), tree.end(), [](const auto& entry) {
return entry.second.size() == 1;
});
for (int i = 0; i < g_nodes; ++i) {
if (i < max_leaves) {
result[i] = 1;
} else {
result[i] = i - max_leaves + 2;
}
}
if (g_to[2] == g_from[2] + 3) {
result[3] += 1;
}
return result;
}
DE Shaw โ
int solution(vector<int>arr){
int ans=INT_MIN;
int result=-1;
vector<int>weight(arr.size(),0);
for(int i=0;i<arr.size();i++){
int source=i;
int dest=arr[i];
if(dest!=-1){
weight[dest]+=source;
if(ans<=weight[dest]){
ans=max(ans,weight[dest]);
result=dest;
}
}
}
if(ans!=INT_MIN)
return result;
return -1;
}
Maximum Weight Node โ
int ans=INT_MIN;
int result=-1;
vector<int>weight(arr.size(),0);
for(int i=0;i<arr.size();i++){
int source=i;
int dest=arr[i];
if(dest!=-1){
weight[dest]+=source;
if(ans<=weight[dest]){
ans=max(ans,weight[dest]);
result=dest;
}
}
}
if(ans!=INT_MIN)
return result;
return -1;
}
Maximum Weight Node โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: HackerEarth
๐ Job Title: Problem Setter Intern
โ๐ป YOE: 2025, 2026 and 2027 grads
โก๏ธ Apply: https://hackerearth.applytojob.com/apply/cEkOgMaelD/Technical-Engineer-Problem-Setter-Programming--Internship
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
๐ Job Title: Problem Setter Intern
โ๐ป YOE: 2025, 2026 and 2027 grads
โก๏ธ Apply: https://hackerearth.applytojob.com/apply/cEkOgMaelD/Technical-Engineer-Problem-Setter-Programming--Internship
Please do share in your college grps and in case you are applying please react on this post:) ๐โค๏ธ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company: Rakuten Symphony
Location: N/A
Role: Associate Software Engineer
For Graduates: 2024, 2023
https://rakuten.skillate.com/jobs/54126
Location: N/A
Role: Associate Software Engineer
For Graduates: 2024, 2023
https://rakuten.skillate.com/jobs/54126
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Requires -
Graduate & Diploma Engineer Trainee
Bharat FIH
Job Description :
He/She will be deployed in the department based on their interest and suitability.
He/She will work along with the team members and perform their tasks, which is assigned by his/her superior.
He or She should perform well for their position to confirm after successfully completed their training period.
He or She has to participate in the department meeting and present their project or task when is required.
He/She has to deliver their tasks on time.
Education & Skills :
Diploma Engineer Trainee (DET)
Diploma Graduates (EEE/ECE/Mech/Mechatronics/Robotics) who have passed out 2022 / 2023
Good Academic Records
No Standing Arrears
Skill Set :
Good Communication skills (Verbal & Written)
Eager to learn
Pleasing Personality
Good in System Knowledge (MS Office)
Graduate Engineer Trainee (GET) :
BE/B.Tech Graduates (EEE/ECE/Mech/Mechatronics/Robotics) who have passed out 2022 / 2023
Good Academic Records
No Standing Arrears
Skill Set :
Good Communication skills (Verbal & Written)
Eager to learn
Pleasing Personality
Good in System Knowledge (MS Office)
Note : Immediate Joiners will be preferred
Working Place: Sunguvarchatram Plant
You can share your application to careers@fih-foxconn.com (Subject Line : Applied for the position of GET or DET Batch 2022/2023)
Graduate & Diploma Engineer Trainee
Bharat FIH
Job Description :
He/She will be deployed in the department based on their interest and suitability.
He/She will work along with the team members and perform their tasks, which is assigned by his/her superior.
He or She should perform well for their position to confirm after successfully completed their training period.
He or She has to participate in the department meeting and present their project or task when is required.
He/She has to deliver their tasks on time.
Education & Skills :
Diploma Engineer Trainee (DET)
Diploma Graduates (EEE/ECE/Mech/Mechatronics/Robotics) who have passed out 2022 / 2023
Good Academic Records
No Standing Arrears
Skill Set :
Good Communication skills (Verbal & Written)
Eager to learn
Pleasing Personality
Good in System Knowledge (MS Office)
Graduate Engineer Trainee (GET) :
BE/B.Tech Graduates (EEE/ECE/Mech/Mechatronics/Robotics) who have passed out 2022 / 2023
Good Academic Records
No Standing Arrears
Skill Set :
Good Communication skills (Verbal & Written)
Eager to learn
Pleasing Personality
Good in System Knowledge (MS Office)
Note : Immediate Joiners will be preferred
Working Place: Sunguvarchatram Plant
You can share your application to careers@fih-foxconn.com (Subject Line : Applied for the position of GET or DET Batch 2022/2023)
๐2
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
FresherOpporunityAlert
Vembu Technologies is hiring Freshers ๐จโ๐ผ
๐๐ปโโ๏ธProduct Success Engineer and QA Engineer Trainee
๐B.E/B.Tech- CS/IT -2023 & 2024 batch passed out students
๐Note: Minimum 70 % academic record required to attend the interview ( SSLC, HSC, UG) No standing Arears
๐งณSalary-3.00 to 3.6 Lakhs/ CTC
๐จโ๐ผInterview and selection process :-
Written Test (Aptitude, English and Technical)
Face 2 Face Interview
๐ง Interested Candidates can email their resume with prabu@vembu.com
Vembu Technologies is hiring Freshers ๐จโ๐ผ
๐๐ปโโ๏ธProduct Success Engineer and QA Engineer Trainee
๐B.E/B.Tech- CS/IT -2023 & 2024 batch passed out students
๐Note: Minimum 70 % academic record required to attend the interview ( SSLC, HSC, UG) No standing Arears
๐งณSalary-3.00 to 3.6 Lakhs/ CTC
๐จโ๐ผInterview and selection process :-
Written Test (Aptitude, English and Technical)
Face 2 Face Interview
๐ง Interested Candidates can email their resume with prabu@vembu.com
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
WITH monthly_sales AS ( SELECT mon, SUM(amount) as month_total FROM sales GROUP BY mon ), cumulative_sales AS ( SELECT mon, SUM(month_total) OVER (ORDER BY mon ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) as total_sales_so_farโฆ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <unordered_set>
using namespace std;
vector<string> fep(unordered_map<string, vector<string>>& g, string s) {
vector<string> st = {s};
deque<string> p;
while (!st.empty()) {
string u = st.back();
if (!g[u].empty()) {
string v = g[u].front();
g[u].erase(g[u].begin());
st.push_back(v);
} else {
p.push_front(st.back());
st.pop_back();
}
}
return vector<string>(p.begin(), p.end());
}
int main() {
int n, m;
cin >> n >> m;
unordered_map<string, vector<string>> g;
unordered_set<string> ads;
for (int i = 0; i < n; i++) {
string a, b;
cin >> a >> b;
g[a].push_back(b);
ads.insert(a);
ads.insert(b);
}
for (auto it = g.begin(); it != g.end(); ++it) {
sort(it->second.begin(), it->second.end());
}
string s = "ABC";
vector<string> p = fep(g, s);
for (const auto& x : p) {
cout << x << " ";
}
cout << endl;
return 0;
}
Flipkart โ
using namespace std;
vector<int> rc;
vector<vector<int>> adj;
vector<int> seq;
void dfs(int node) {
if(adj[node].size() > 0) dfs(adj[node][0]);
seq.push_back(rc[node]);
if(adj[node].size() > 1) dfs(adj[node][1]);
}
int main() {
int rCount;
cin >> rCount;
rc.resize(rCount);
for(int i=0; i<rCount; i++) cin >> rc[i];
int cRow, cCol;
cin >> cRow >> cCol;
adj.resize(rCount);
for(int i=0; i<cRow; i++) {
int u, v;
cin >> u >> v;
adj[u].push_back(v);
}
int rM;
cin >> rM;
dfs(0);
cout << seq[rM-1] << endl;
return 0;
}
Restaurant โ
Flipkart
using namespace std;
void pop_front(vector<int> &v) {
if (v.size() > 0) {
v.erase(v.begin());
}
}
vector<int> helper(vector<int> nums, int c_len) {
vector<int> ans;
int In = nums.size();
for(int i = 0; i < In; i++) {
while(ans.size() > 0 && ans.back() < nums[i] && ((In - i) > (c_len - ans.size()))) {
ans.pop_back();
}
if(ans.size() < c_len) {
ans.push_back(nums[i]);
}
}
return ans;
}
vector<int> solve(vector<int> nums1, vector<int> nums2, int k) {
int l1 = nums1.size();
int l2 = nums2.size();
vector<int> rs;
for (int s1 = max(0, k - l2); s1 <= min(k, l1); s1++) {
vector<int> p1, p2;
p1 = helper(nums1, s1);
p2 = helper(nums2, k - s1);
vector<int> temp;
for (int j = 0; j < k; j++) {
vector<int> temp2 = max(p1, p2);
int fr = temp2.front();
if (p1 > p2) {
pop_front(p1);
} else {
pop_front(p2);
}
temp.push_back(fr);
}
rs = max(rs, temp);
}
return rs;
}
int main() {
int n;
cin >> n;
vector<int> arr1(n);
for(int i = 0; i < n; i++) {
cin >> arr1[i];
}
int m;
cin >> m;
vector<int> arr2(m);
for(int i = 0; i < m; i++) {
cin >> arr2[i];
}
int k;
cin >> k;
vector<int> v = solve(arr1, arr2, k);
for(int i = 0; i < v.size(); i++) {
cout << v[i] << " ";
}
return 0;
}
University
Flipkart โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Meesho is hiring for SDE 1 role.
Batch eligible: 2022 and 2023 grads only
Link: https://docs.google.com/forms/d/e/1FAIpQLSccczQRZsQPXR_GPaomStgK2Vem3MspsmiLBJWC0FDXMVWjuw/viewform
Note: this is the referral form and will take only 200 resumes and refer best out of that!!
Batch eligible: 2022 and 2023 grads only
Link: https://docs.google.com/forms/d/e/1FAIpQLSccczQRZsQPXR_GPaomStgK2Vem3MspsmiLBJWC0FDXMVWjuw/viewform
Note: this is the referral form and will take only 200 resumes and refer best out of that!!
Google Docs
Meesho Referral Form
Role: SDE 1
Only for 2022 and 2023 grads (Strictly)
Only for 2022 and 2023 grads (Strictly)
int minimumChunksRequired(long long totalPackets,vector<vector<long long>>uploadedChunks){
long long ans=0;
long long prev=0;
sort(uploadedChunks.begin(),uploadedChunks.end());
for(int i=0;i<uploadedChunks.size();i++){
if(uploadedChunks[i][0]==prev+1){
prev=uploadedChunks[i][1];
continue;
}
else{
long diff=uploadedChunks[i][0]-prev-1;
for(int k=0;k<64;k++){
if(diff&(1LL<<k)){
ans++;
}
}
prev=uploadedChunks[i][1];
}
}
long diff=totalPackets-prev;
for(int k=0;k<64;k++){
if(diff&(1LL<<k)){
ans++;
}
}
return ans;
}
long long ans=0;
long long prev=0;
sort(uploadedChunks.begin(),uploadedChunks.end());
for(int i=0;i<uploadedChunks.size();i++){
if(uploadedChunks[i][0]==prev+1){
prev=uploadedChunks[i][1];
continue;
}
else{
long diff=uploadedChunks[i][0]-prev-1;
for(int k=0;k<64;k++){
if(diff&(1LL<<k)){
ans++;
}
}
prev=uploadedChunks[i][1];
}
}
long diff=totalPackets-prev;
for(int k=0;k<64;k++){
if(diff&(1LL<<k)){
ans++;
}
}
return ans;
}
โค1
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;
string encodeString(const string &s) {
stringstream ss(s);
string word;
vector<string> words;
while (ss >> word) {
reverse(word.begin(), word.end());
words.push_back(word);
}
string reversedSentence;
for (const auto &w : words) {
reversedSentence += w + " ";
}
reversedSentence = reversedSentence.substr(0, reversedSentence.size() - 1);
string encodedChars;
for (size_t i = 0; i < reversedSentence.size(); ++i) {
char c = reversedSentence[i];
if (i % 2 == 0) {
encodedChars += toupper(c);
} else {
encodedChars += tolower(c);
}
}
for (size_t i = 0; i < encodedChars.size(); ++i) {
if (encodedChars[i] == ' ') {
encodedChars[i] = (i % 2 == 0) ? '#' : '*';
} else if (encodedChars[i] == ',') {
encodedChars[i] = '@';
} else if (encodedChars[i] == '.') {
encodedChars[i] = '@';
} else if (encodedChars[i] == '-') {
encodedChars[i] = ':';
}
}
return encodedChars;
}
int main() {
string inputString = "The mangy, scrawny stray dog hurriedly gobbled down the grain-free, organic dog food.";
string outputString = encodeString(inputString);
cout << outputString << endl;
return 0;
}
// Mini orange 1st โ
#include <sstream>
#include <vector>
#include <algorithm>
#include <cctype>
using namespace std;
string encodeString(const string &s) {
stringstream ss(s);
string word;
vector<string> words;
while (ss >> word) {
reverse(word.begin(), word.end());
words.push_back(word);
}
string reversedSentence;
for (const auto &w : words) {
reversedSentence += w + " ";
}
reversedSentence = reversedSentence.substr(0, reversedSentence.size() - 1);
string encodedChars;
for (size_t i = 0; i < reversedSentence.size(); ++i) {
char c = reversedSentence[i];
if (i % 2 == 0) {
encodedChars += toupper(c);
} else {
encodedChars += tolower(c);
}
}
for (size_t i = 0; i < encodedChars.size(); ++i) {
if (encodedChars[i] == ' ') {
encodedChars[i] = (i % 2 == 0) ? '#' : '*';
} else if (encodedChars[i] == ',') {
encodedChars[i] = '@';
} else if (encodedChars[i] == '.') {
encodedChars[i] = '@';
} else if (encodedChars[i] == '-') {
encodedChars[i] = ':';
}
}
return encodedChars;
}
int main() {
string inputString = "The mangy, scrawny stray dog hurriedly gobbled down the grain-free, organic dog food.";
string outputString = encodeString(inputString);
cout << outputString << endl;
return 0;
}
// Mini orange 1st โ
โค1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
string shortestPalindrome(string s)
{
reverse(s.begin(), s.end());
string rev = s;
reverse(s.begin(), s.end());
string temp = s + "@" + rev;
vector<int> vr = fail_fun(temp);
int maxm = vr[vr.size()-1];
temp = "";
for(int i = maxm; i < s.length(); i++)
{
temp = temp + s[i];
}
reverse(temp.begin(), temp.end());
return temp + s;
}
vector<int> fail_fun(string &s)
{
int n = s.length();
vector<int> fail_ar(n, 0);
for(int i = 1, k = 0; i < n; i++)
{
while(k > 0 && s[k] != s[i])
{
k = fail_ar[k-1];
}
if(s[k] == s[i])
{
fail_ar[i] = ++k;
}
}
return fail_ar;
}
Miniorange
{
reverse(s.begin(), s.end());
string rev = s;
reverse(s.begin(), s.end());
string temp = s + "@" + rev;
vector<int> vr = fail_fun(temp);
int maxm = vr[vr.size()-1];
temp = "";
for(int i = maxm; i < s.length(); i++)
{
temp = temp + s[i];
}
reverse(temp.begin(), temp.end());
return temp + s;
}
vector<int> fail_fun(string &s)
{
int n = s.length();
vector<int> fail_ar(n, 0);
for(int i = 1, k = 0; i < n; i++)
{
while(k > 0 && s[k] != s[i])
{
k = fail_ar[k-1];
}
if(s[k] == s[i])
{
fail_ar[i] = ++k;
}
}
return fail_ar;
}
Miniorange