๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
import java.util.*;
import java.io.*;
public class Main {
static class Segment {
int L;
int R;
int cost;
Segment(int L, int R, int cost){
this.L = L;
this.R = R;
this.cost = cost;
}
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
sc.nextInt(); // Read the '3' and ignore
Segment[] segments = new Segment[N];
for(int i=0;i<N;i++) {
int L = sc.nextInt();
int R = sc.nextInt();
int cost = sc.nextInt();
segments[i] = new Segment(L, R, cost);
}
Segment[] sortedByL = segments.clone();
Arrays.sort(sortedByL, new Comparator<Segment>() {
public int compare(Segment a, Segment b){
if(a.L != b.L) return Integer.compare(a.L, b.L);
return Integer.compare(a.R, b.R);
}
});
Segment[] sortedByR = segments.clone();
Arrays.sort(sortedByR, new Comparator<Segment>() {
public int compare(Segment a, Segment b){
if(a.R != b.R) return Integer.compare(a.R, b.R);
return Integer.compare(a.L, b.L);
}
});
long minCost = Long.MAX_VALUE;
long minProduct = Long.MAX_VALUE;
int r_ptr = 0;
for(int i=0;i<N;i++) {
Segment current = sortedByL[i];
while(r_ptr < N && sortedByR[r_ptr].R < current.L){
if(sortedByR[r_ptr].cost < minCost){
minCost = sortedByR[r_ptr].cost;
}
r_ptr++;
}
if(minCost != Long.MAX_VALUE){
long product = minCost * (long)current.cost;
if(product < minProduct){
minProduct = product;
}
}
}
if(minProduct != Long.MAX_VALUE){
System.out.println(minProduct);
}
else{
System.out.println(-1);
}
}
}
Zeta โ
int best=0;
int dfs(TreeNode* root) {
if(root==NULL)return -1;
int left = dfs(root->left);
int right = dfs(root->right);
int res = root->val;
if(left*right>=0 && left+right>=0) res+=left+right;
best = max(best,res);
return res;
}
int maxPerfectSubtree(TreeNode* root) {
solve(root);
return best;
}
American Express โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Interested candidates forward your resume to chosenconsultanthr@gmail.com
Contact:9790438392.
Contact:9790438392.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Experience: 0-1 years
Salary: โน6.00 LPA
About Us:
Hummingbird Web Solutions Pvt Ltd specializes in Adobe Commerce services, building top-tier e-commerce solutions worldwide. We offer a supportive and growth-oriented work environment.
Role Highlights:
โข Collaborate with engineering, product, and design teams on client websites
โข Code with JavaScript, ReactJS, PHP, RequireJS, KnockOutJS, AlpineJS, and more
โข Contribute to daily deployments, task management, and release support
โข Share insights to foster innovation within the team
Eligibility:
โGraduated in 2024 in CS, IT, Electronics, or related fields
Coding profile on LeetCode, CodeChef, or Codeforces
* Strong communication skills
Join us at Hummingbird Web Solutions! Apply now if you're ready to make an impact.
Kindly submit the given form to apply with us Link
https://lnkd.in/dBKCUsKd
Salary: โน6.00 LPA
About Us:
Hummingbird Web Solutions Pvt Ltd specializes in Adobe Commerce services, building top-tier e-commerce solutions worldwide. We offer a supportive and growth-oriented work environment.
Role Highlights:
โข Collaborate with engineering, product, and design teams on client websites
โข Code with JavaScript, ReactJS, PHP, RequireJS, KnockOutJS, AlpineJS, and more
โข Contribute to daily deployments, task management, and release support
โข Share insights to foster innovation within the team
Eligibility:
โGraduated in 2024 in CS, IT, Electronics, or related fields
Coding profile on LeetCode, CodeChef, or Codeforces
* Strong communication skills
Join us at Hummingbird Web Solutions! Apply now if you're ready to make an impact.
Kindly submit the given form to apply with us Link
https://lnkd.in/dBKCUsKd
lnkd.in
LinkedIn
This link will take you to a page thatโs not on LinkedIn
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
int main() {
int N;
cin >> N;
vector<int> squareFreeDivisorCount(N + 1, 0);
long long count = 0;
for (int i = 1; i <= N; ++i) {
for (int j = i; j <= N; j += i) {
int product = i * j;
int root = sqrt(product);
if (root * root == product) {
if (i == j)
count = (count + 1) % MOD;
else
count = (count + 2) % MOD;
}
}
}
cout << count << endl;
return 0;
}
Square investment โ
I'm rooting for your success more than you do...โฅ๏ธ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
def getInaccurateProcesses(processOrder, executionOrder):
class FenwickTree:
def __init__(self, size):
self.size = size
self.tree = [0] * (size + 2)
def update(self, index, delta=1):
while index <= self.size:
self.tree[index] += delta
index += index & -index
def query(self, index):
res = 0
while index > 0:
res += self.tree[index]
index -= index & -index
return res
def range_query(self, left, right):
if left > right:
return 0
return self.query(right) - self.query(left -1)
n = len(processOrder)
pid = {}
for idx, process in enumerate(processOrder):
pid[process] = idx
ft = FenwickTree(n)
inaccurate =0
for process in executionOrder:
index = pid[process]
fti = index +1
count = ft.query(fti -1)
if count != index:
inaccurate +=1
ft.update(fti)
return inaccurate
Amazon โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
#include <bits/stdc++.h> using namespace std; struct Edge { int u, v, c; bool operator<(const Edge& other) const { return c < other.c; } }; int find(vector<int>& parent, int u) { if (parent[u] != u) parent[u] = find(parent, parent[u]);โฆ
#include <bits/stdc++.h>
using namespace std;
class DSU {
vector<int> parent, rank;
public:
DSU(int n) {
parent.resize(n + 1);
rank.resize(n + 1, 0);
for (int i = 0; i <= n; i++) {
parent[i] = i;
}
}
int find(int u) {
if (u != parent[u]) {
parent[u] = find(parent[u]);
}
return parent[u];
}
void unite(int u, int v) {
int root_u = find(u);
int root_v = find(v);
if (root_u != root_v) {
if (rank[root_u] > rank[root_v]) {
parent[root_v] = root_u;
} else if (rank[root_u] < rank[root_v]) {
parent[root_u] = root_v;
} else {
parent[root_v] = root_u;
rank[root_u]++;
}
}
}
};
int solve(int n, vector<vector<int>>& edges) {
sort(edges.begin(), edges.end(), [](vector<int>& a, vector<int>& b) {
return a[2] > b[2];
});
DSU dsu(n);
int mst_weight = 0;
int total_weight = 0;
for (const auto& edge : edges) {
total_weight += edge[2];
}
for (const auto& edge : edges) {
int u = edge[0], v = edge[1], w = edge[2];
if (dsu.find(u) != dsu.find(v)) {
dsu.unite(u, v);
mst_weight += w;
}
}
return total_weight - mst_weight;
}
int main() {
int t;
cin >> t;
while (t--){
int n;
cin >> n;
vector<vector<int>> edges(n - 1);
for (int i = 0; i < n - 1; i++) {
int u, v, w;
cin >> u >> v >> w;
edges[i] = {u, v, w};
}
cout << solve(n, edges) << endl;
}
return 0;
}
Break and Add โ
import math
def ss(arr):
n = len(arr)
if n == 1:
return 0
a = [0] * n
b = [0] * n
a[0] = arr[0]
for i in range(1, n):
a[i] = math.gcd(a[i - 1], arr[i])
b[n - 1] = arr[n - 1]
for i in range(n - 2, -1, -1):
b[i] = math.gcd(b[i + 1], arr[i])
m = 0
for i in range(n):
if i == 0:
q = b[1]
elif i == n - 1:
q = a[n - 2]
else:
q = math.gcd(a[i - 1], b[i + 1])
m = max(m, q)
return m
Score Maximize โ
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long help(vector<long long>& a, long long l, long long n, long long max_price) {
for (long long i = 0; i < n; i++)
a[i] = (i + 1) * l + a[i];
sort(a.begin(), a.end());
long long sum = 0;
for (long long i = 0; i < l; i++) {
sum += a[i];
}
return sum <= max_price;
}
int getMaxSubsequenceLen(vector<int> arr, long long max_sum) {
long long n = arr.size();
vector<long long> a(n);
for (long long i = 0; i < n; i++) {
a[i] = static_cast<long long>(arr[i]);
}
long long ans = 0;
long long l = 0, r = n;
while (l <= r) {
long long mid = (l + r) / 2;
if (help(a, mid, n, max_sum)) {
ans = mid;
l = mid + 1;
} else {
r = mid - 1;
}
}
return ans+1;
}
DE Shaw โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Bottomline is hiring Associate Software Engineer
For 2023, 2024 grads
Location: Multiple
๐ปApply:
https://boards.greenhouse.io/bottomlinetechnologies/jobs/7666351002
For 2023, 2024 grads
Location: Multiple
๐ปApply:
https://boards.greenhouse.io/bottomlinetechnologies/jobs/7666351002
job-boards.greenhouse.io
Bottomline
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Contra is Hiring for a Frontend Engineer
Experience: 0 - 1 year's
Pay: $100 - $110/hr
Apply now: https://contra.com/opportunity/UQk2c6m6-frontend-engineer
Experience: 0 - 1 year's
Pay: $100 - $110/hr
Apply now: https://contra.com/opportunity/UQk2c6m6-frontend-engineer
Contra
Frontend Engineer
See more opportunities from companies like Contra on Contra
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Blackhawk Network is hiring for Software Engineer - Full-stack (0-2 years)
Experience: 0 - 1 year's
Expected Salary: 12-18 LPA
Apply here: https://www.linkedin.com/jobs/view/4040365442/
Experience: 0 - 1 year's
Expected Salary: 12-18 LPA
Apply here: https://www.linkedin.com/jobs/view/4040365442/
Linkedin
Blackhawk Network hiring Software Engineer - Full-stack in Bengaluru, Karnataka, India | LinkedIn
Posted 9:05:53 AM. About Blackhawk Network: Today, through BHNโs single global platform, businesses of all kinds canโฆSee this and similar jobs on LinkedIn.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company: Google
Role: Associate Product Manager
Batch : 2024/2025 from a degree related to PM, CS, Maths or Data Science.
The application starts on 28th of October.
Apply : https://www.google.com/about/careers/applications/jobs/results/124204114060944070-associate-product-manager-university-graduate-2025-start
Role: Associate Product Manager
Batch : 2024/2025 from a degree related to PM, CS, Maths or Data Science.
The application starts on 28th of October.
Apply : https://www.google.com/about/careers/applications/jobs/results/124204114060944070-associate-product-manager-university-graduate-2025-start
#include <bits/stdc++.h>
using namespace std;
string nextBeautifulString(string s, int n, int k) {
for (int i = n - 1; i >= 0; --i) {
if (s[i] < 'a' + k - 1) {
s[i]++;
fill(s.begin() + i + 1, s.end(), 'a');
for (int j = 1; j < n; ++j) {
if (s[j] == s[j - 1] (j > 1 && s[j] == s[j - 2])) {
if (s[j] < 'a' + k - 1) {
s[j]++;
fill(s.begin() + j + 1, s.end(), 'a');
} else {
return "-1";
}
}
}
bool valid = true;
for (int j = 1; j < n; ++j) {
if (s[j] == s[j - 1] (j > 1 && s[j] == s[j - 2])) {
valid = false;
break;
}
}
if (valid) return s;
else return "-1";
}
}
return "-1";
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k;
string s;
cin >> n >> k >> s;
cout << nextBeautifulString(s, n, k) << endl;
}
return 0;
}
Beautiful Strings
Google โ