#include <iostream>
#include <string>
using namespace std;
bool chk(int m, int n, int k, const string& o) {
long long c = 0;
int lst = 0;
for (int i = 0; i < n; ++i) {
if (o[i] == '1') {
int cur = i + 1;
c += (cur - lst - 1) / m;
lst = cur;
}
}
c += (n + 1 - lst - 1) / m;
return c <= k;
}
int solve(int n, int k, string o) {
int l = 1, r = n + 1;
int ans = r;
while (l <= r) {
int m = l + (r - l) / 2;
if (chk(m, n, k, o)) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
if (cin >> n >> k) {
string o;
cin >> o;
cout << solve(n, k, o) << "\n";
}
return 0;
}
Infosys β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DN @Codemaster004
#include <string>
using namespace std;
bool chk(int m, int n, int k, const string& o) {
long long c = 0;
int lst = 0;
for (int i = 0; i < n; ++i) {
if (o[i] == '1') {
int cur = i + 1;
c += (cur - lst - 1) / m;
lst = cur;
}
}
c += (n + 1 - lst - 1) / m;
return c <= k;
}
int solve(int n, int k, string o) {
int l = 1, r = n + 1;
int ans = r;
while (l <= r) {
int m = l + (r - l) / 2;
if (chk(m, n, k, o)) {
ans = m;
r = m - 1;
} else {
l = m + 1;
}
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
if (cin >> n >> k) {
string o;
cin >> o;
cout << solve(n, k, o) << "\n";
}
return 0;
}
Infosys β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DN @Codemaster004
CODING SOLUTION - Placement Jobs & Materials
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long solve(int n, vector<vector<int>>& g) {
if (n == 0) return 0;
vector<vector<long long>> dp(n, vector<long long>(n, -2e18));
dp[0][0] = g[0][0];
for (int s = 1; s <= 2 * n - 2; ++s) {
vector<vector<long long>> ndp(n, vector<long long>(n, -2e18));
int mn = max(0, s - n + 1);
int mx = min(s, n - 1);
for (int x1 = mn; x1 <= mx; ++x1) {
for (int x2 = mn; x2 <= mx; ++x2) {
int y1 = s - x1;
int y2 = s - x2;
long long prv = -2e18;
if (x1 > 0 && x2 > 0) prv = max(prv, dp[x1 - 1][x2 - 1]);
if (x1 > 0 && y2 > 0) prv = max(prv, dp[x1 - 1][x2]);
if (y1 > 0 && x2 > 0) prv = max(prv, dp[x1][x2 - 1]);
if (y1 > 0 && y2 > 0) prv = max(prv, dp[x1][x2]);
if (prv != -2e18) {
long long val = g[x1][y1];
if (x1 != x2) val += g[x2][y2];
ndp[x1][x2] = prv + val;
}
}
}
dp = ndp;
}
return dp[n - 1][n - 1];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
if (cin >> n) {
vector<vector<int>> g(n, vector<int>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> g[i][j];
}
}
auto result = solve(n, g);
cout << result << "\n";
}
return 0;
}
Infosys β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DM @Codemaster004
#include <vector>
#include <algorithm>
using namespace std;
long long solve(int n, vector<vector<int>>& g) {
if (n == 0) return 0;
vector<vector<long long>> dp(n, vector<long long>(n, -2e18));
dp[0][0] = g[0][0];
for (int s = 1; s <= 2 * n - 2; ++s) {
vector<vector<long long>> ndp(n, vector<long long>(n, -2e18));
int mn = max(0, s - n + 1);
int mx = min(s, n - 1);
for (int x1 = mn; x1 <= mx; ++x1) {
for (int x2 = mn; x2 <= mx; ++x2) {
int y1 = s - x1;
int y2 = s - x2;
long long prv = -2e18;
if (x1 > 0 && x2 > 0) prv = max(prv, dp[x1 - 1][x2 - 1]);
if (x1 > 0 && y2 > 0) prv = max(prv, dp[x1 - 1][x2]);
if (y1 > 0 && x2 > 0) prv = max(prv, dp[x1][x2 - 1]);
if (y1 > 0 && y2 > 0) prv = max(prv, dp[x1][x2]);
if (prv != -2e18) {
long long val = g[x1][y1];
if (x1 != x2) val += g[x2][y2];
ndp[x1][x2] = prv + val;
}
}
}
dp = ndp;
}
return dp[n - 1][n - 1];
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
if (cin >> n) {
vector<vector<int>> g(n, vector<int>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> g[i][j];
}
}
auto result = solve(n, g);
cout << result << "\n";
}
return 0;
}
Infosys β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DM @Codemaster004
CODING SOLUTION - Placement Jobs & Materials
Photo
#include <bits/stdc++.h>
using namespace std;
struct St {
long long s;
int c;
bool operator<(const St& o) const {
if (s != o.s) return s < o.s;
return c < o.c;
}
};
St mx(St a, St b) {
return a < b ? b : a;
}
St get_mx(const vector<int>& a, long long lam) {
int n = a.size();
St d0 = {0, 0};
St d1 = {-(long long)a[0] - lam, 1};
for (int i = 1; i < n; ++i) {
St n0 = mx(d0, d1);
long long v = -(long long)a[i];
St n1_ext = {d1.s + v, d1.c};
St n1_str = {d0.s + v - lam, d0.c + 1};
St n1 = mx(n1_ext, n1_str);
d0 = n0;
d1 = n1;
}
return mx(d0, d1);
}
long long solve(int n, int k, vector<int>& a) {
long long base = 0;
for (int i = 0; i < n; ++i) {
base += a[i];
}
St r0 = get_mx(a, 0);
long long best = 0;
if (r0.c <= k) {
best = r0.s;
} else {
long long l = 0, r = 2e14;
while (l <= r) {
long long mid = l + (r - l) / 2;
St cur = get_mx(a, mid);
if (cur.c >= k) {
best = cur.s + mid * k;
l = mid + 1;
} else {
r = mid - 1;
}
}
}
return base + 2 * best;
}
INFOSYS β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DM @Codemaster004
using namespace std;
struct St {
long long s;
int c;
bool operator<(const St& o) const {
if (s != o.s) return s < o.s;
return c < o.c;
}
};
St mx(St a, St b) {
return a < b ? b : a;
}
St get_mx(const vector<int>& a, long long lam) {
int n = a.size();
St d0 = {0, 0};
St d1 = {-(long long)a[0] - lam, 1};
for (int i = 1; i < n; ++i) {
St n0 = mx(d0, d1);
long long v = -(long long)a[i];
St n1_ext = {d1.s + v, d1.c};
St n1_str = {d0.s + v - lam, d0.c + 1};
St n1 = mx(n1_ext, n1_str);
d0 = n0;
d1 = n1;
}
return mx(d0, d1);
}
long long solve(int n, int k, vector<int>& a) {
long long base = 0;
for (int i = 0; i < n; ++i) {
base += a[i];
}
St r0 = get_mx(a, 0);
long long best = 0;
if (r0.c <= k) {
best = r0.s;
} else {
long long l = 0, r = 2e14;
while (l <= r) {
long long mid = l + (r - l) / 2;
St cur = get_mx(a, mid);
if (cur.c >= k) {
best = cur.s + mid * k;
l = mid + 1;
} else {
r = mid - 1;
}
}
}
return base + 2 * best;
}
INFOSYS β
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ DM @Codemaster004
Forwarded from OFF CAMPUS JOBS INDIA
π₯ Amazon is Hiring! π₯
π» Role:
Software Dev Engineer - 1 (SDE-1) - Bengaluru
π Eligibility:
2024 / 2025 batch
Bachelorβs degree
1+ YOE (Years of Experience)
π Key Requirements:
Experience in at least 1 programming language
Job Id: 10432823
π Click below to apply:
π Application Link : https://www.amazon.jobs/en/jobs/10432823/software-development-engineer-i-finops-fp-a
π» Role:
Software Dev Engineer - 1 (SDE-1) - Bengaluru
π Eligibility:
2024 / 2025 batch
Bachelorβs degree
1+ YOE (Years of Experience)
π Key Requirements:
Experience in at least 1 programming language
Job Id: 10432823
π Click below to apply:
π Application Link : https://www.amazon.jobs/en/jobs/10432823/software-development-engineer-i-finops-fp-a
Forwarded from OFF CAMPUS JOBS INDIA
π₯ Infosys is Hiring! π₯
π» Role:
Digital Specialist Engineer (DSE) & Specialist Programmer (SP)
Location: PAN India
π Eligibility:
2024, 2025 & 2026 Batch
BE / B.Tech, ME / M.Tech, MCA, M.Sc
Experience: Freshers
π Key Requirements:
Salary package ranges from βΉ6.25 LPA β βΉ21 LPA
Apply as soon as possible
π Click below to apply:
π Application Link : https://surveys.infosysapps.com/r/a/SPOffCampusregistration_apr26
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π© DM: @codemaster004
π» Role:
Digital Specialist Engineer (DSE) & Specialist Programmer (SP)
Location: PAN India
π Eligibility:
2024, 2025 & 2026 Batch
BE / B.Tech, ME / M.Tech, MCA, M.Sc
Experience: Freshers
π Key Requirements:
Salary package ranges from βΉ6.25 LPA β βΉ21 LPA
Apply as soon as possible
π Click below to apply:
π Application Link : https://surveys.infosysapps.com/r/a/SPOffCampusregistration_apr26
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π© DM: @codemaster004
π¨ Electrifex is Hiring! π¨
π» Role:
* Software Engineer
π Eligibility:
* Batch : 2020/21/22/23/24/25/26
* Bachelor's degree
π Key Requirements:
* Direct Test (No Resume Shortlisting)
* Selection Process: Online Quiz (30 Min), Coding Test, 2 Technical Interviews, and HR Interview
* CTC: βΉ6 Lakhs to βΉ8 Lakhs per year
π Click below to apply:
π Application Link : https://talents.electrifex.com/
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ Join our channel: @Codemaster004
π» Role:
* Software Engineer
π Eligibility:
* Batch : 2020/21/22/23/24/25/26
* Bachelor's degree
π Key Requirements:
* Direct Test (No Resume Shortlisting)
* Selection Process: Online Quiz (30 Min), Coding Test, 2 Technical Interviews, and HR Interview
* CTC: βΉ6 Lakhs to βΉ8 Lakhs per year
π Click below to apply:
π Application Link : https://talents.electrifex.com/
π» Live Coding Test | Projects | Interviews | OA & Hackathons Help
π’ Join our channel: @Codemaster004