#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 โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: Palo Alto Network
Role: Software Engineer
Batch eligible: 2025 grads
Apply: https://jobs.paloaltonetworks.com/en/job/-/-/47263/71837933584
Role: Software Engineer
Batch eligible: 2025 grads
Apply: https://jobs.paloaltonetworks.com/en/job/-/-/47263/71837933584
Paloaltonetworks
Explore Careers and Jobs in Cybersecurity at Palo Alto Networks
Palo Alto Networks is the global cybersecurity leader enabling secure digital transformation. Search our jobs to uncover your career in our global network.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
ACL Digital (An Alten Group Company) is hiring Freshers for Chennai Location.
Qualification - B.Tech/B.E-(CS, ECE, EEE) only
Experience 0-1 year
Mandatory skills - C, C++,embedded, linux, unit testing
Good to have - Python
Academics - above 70%
Interested candidates can share your resume to nishi.r@acldigital.com
Qualification - B.Tech/B.E-(CS, ECE, EEE) only
Experience 0-1 year
Mandatory skills - C, C++,embedded, linux, unit testing
Good to have - Python
Academics - above 70%
Interested candidates can share your resume to nishi.r@acldigital.com
int cleanupDataset(string dataset, int x, int y){
vector<int> F(26, 0);
for(char ch : dataset) F[ch - 'a']++;
int ans = 0;
if(x <= y){
int cnt = 0;
for(int num : F) ans += x * (num >> 1) , cnt += num & 1;
ans += y * (cnt >> 1);
}
else{
priority_queue<int> pq;
for(int num : F) if(num) pq.push(num);
while(pq.size() > 1){
int x1 = pq.top(); pq.pop();
int x2 = pq.top(); pq.pop();
int rem = min(x1, x2);
ans += y * rem;
if(max(x1, x2) - rem) pq.push(max(x1 , x2) - rem);
}
if(pq.size()){
int rem = pq.top(); pq.pop();
ans += x * (rem >> 1);
}
}
return ans;
}
Amazon โ
def findminimumvariance(n, height):
freq = {}
mini = float('inf')
for i in range(n):
if height[i] in freq:
s = freq[height[i]]
sub = i - s + 1
fir = height[s]
cnt = height[s:i + 1].count(fir)
var = sub - cnt
mini = min(mini, var)
freq[height[i]] = i
if mini == float('inf'):
return 0
return mini
Amazon โ
freq = {}
mini = float('inf')
for i in range(n):
if height[i] in freq:
s = freq[height[i]]
sub = i - s + 1
fir = height[s]
cnt = height[s:i + 1].count(fir)
var = sub - cnt
mini = min(mini, var)
freq[height[i]] = i
if mini == float('inf'):
return 0
return mini
Amazon โ
def getMaxEqualIndices(inv1, inv2):
n = len(inv1)
sinv1 = sum(inv1)
sinv2 = sorted(inv2)
prefixSum = [0] * (n + 1)
for i in range(n):
prefixSum[i + 1] = prefixSum[i] + sinv2[i]
left = 0
right = n
while left < right:
mid = (left + right + 1) // 2
if mid < n:
if prefixSum[mid] <= sinv1:
left = mid
else:
right = mid - 1
else:
if prefixSum[mid] == sinv1:
left = mid
else:
right = mid - 1
return left
Amazon โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
News Corp is hiring for Graduate Engineer Trainee
Experience: 0 - 1 year's
Apply here: https://dowjones.wd1.myworkdayjobs.com/News_Corp_Careers/job/Bangalore/Graduate-Engineer-Trainee_Job_Req_43522
Experience: 0 - 1 year's
Apply here: https://dowjones.wd1.myworkdayjobs.com/News_Corp_Careers/job/Bangalore/Graduate-Engineer-Trainee_Job_Req_43522