def findMinimumIdleness(s, k):
def ci(t):
m, c = 0, 1
for i in range(1, len(t)):
if t[i] == t[i-1]:
c += 1
else:
m = max(m, c)
c = 1
return max(m, c)
def dfs(t, r):
if r == 0:
return ci(t)
m = ci(t)
for i in range(len(t)):
m = min(m, dfs(t[:i] + ('b' if t[i] == 'a' else 'a') + t[i+1:], r - 1))
return m
return dfs(s, k)
LinkedIn(FTE) โ
vector<int> findCompletePrefixes(vector<string> names, vector<string> queries){
vector<int> res;
for(string q : queries){
int count = 0;
for(string s : names){
if(s.size() >= q.size() + 1 && s.compare(0, q.size(), q) == 0){
count++;
}
}
res.push_back(count);
}
return res;
}
Amdocs โ
vector<int> res;
for(string q : queries){
int count = 0;
for(string s : names){
if(s.size() >= q.size() + 1 && s.compare(0, q.size(), q) == 0){
count++;
}
}
res.push_back(count);
}
return res;
}
Amdocs โ
#include <bits/stdc++.h>
using namespace std;
void f(vector<int> &A, vector<int> &B) {
vector<int> c(B.size(), -1);
vector<int> preSum(A.size(), 0);
preSum[0] = A[0];
for(int i = 1; i < A.size(); i++) {
preSum[i] = preSum[i-1] + A[i];
}
for(int i = 0; i < B.size(); i++) {
int val = B[i];
int x = val / preSum[A.size() - 1];
int y = val % preSum[A.size() - 1];
if (y == 0) {
c[i] = x * A.size();
continue;
}
int cnt = 0;
for(int j = 0; j < A.size(); j++) {
if (A[j] >= y) {
cnt = j + 1;
break;
}
}
int res = (x * A.size()) + cnt;
if (res > 0) {
c[i] = res;
}
}
for(auto x : c) {
cout << x << " ";
}
}
int main() {
vector<int> A{7, -15, 19, -15, -11, 17, 5};
vector<int> B{6, 30, -17, 12};
f(A, B);
return 0;
}
Read Books nckd โ
using namespace std;
void f(vector<int> &A, vector<int> &B) {
vector<int> c(B.size(), -1);
vector<int> preSum(A.size(), 0);
preSum[0] = A[0];
for(int i = 1; i < A.size(); i++) {
preSum[i] = preSum[i-1] + A[i];
}
for(int i = 0; i < B.size(); i++) {
int val = B[i];
int x = val / preSum[A.size() - 1];
int y = val % preSum[A.size() - 1];
if (y == 0) {
c[i] = x * A.size();
continue;
}
int cnt = 0;
for(int j = 0; j < A.size(); j++) {
if (A[j] >= y) {
cnt = j + 1;
break;
}
}
int res = (x * A.size()) + cnt;
if (res > 0) {
c[i] = res;
}
}
for(auto x : c) {
cout << x << " ";
}
}
int main() {
vector<int> A{7, -15, 19, -15, -11, 17, 5};
vector<int> B{6, 30, -17, 12};
f(A, B);
return 0;
}
Read Books nckd โ
WITH ranked_stocks AS (
SELECT
s.id,
s.name,
mc.closing_date,
mc.closing_price,
LAG(mc.closing_price) OVER (PARTITION BY s.id ORDER BY mc.closing_date) AS prev_closing_price,
ROW_NUMBER() OVER (PARTITION BY s.id ORDER BY mc.closing_date) AS row_num
FROM stocks s
JOIN monthly_closing mc ON s.id = mc.stock_id
)
SELECT
id,
name,
closing_date,
closing_price,
CASE
WHEN row_num = 1 THEN 0.00
ELSE ROUND(prev_closing_price - closing_price, 2)
END AS price_diff
FROM ranked_stocks
ORDER BY id, closing_date
Meesho (BA) โ
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
vector<int> candies(10);
for (int i = 0; i < 10; ++i) {
cin >> candies[i];
}
int cumulative_sum = 0;
int best_sum = 0;
for (int i = 0; i < 10; ++i) {
cumulative_sum += candies[i];
if (abs(100 - cumulative_sum) < abs(100 - best_sum)) {
best_sum = cumulative_sum;
}
else if (abs(100 - cumulative_sum) == abs(100 - best_sum) && cumulative_sum < best_sum) {
best_sum = cumulative_sum;
}
if (cumulative_sum >= 100) {
break;
}
}
cout << best_sum << endl;
return 0;
}
Deloitte โ
#include <iostream>
#include <string>
#include <unordered_set>
using namespace std;
int countPunctuations(const string& str) {
unordered_set<char> punctuations = {'(', ')', '[', ']', ':', '_', ';', '\'', '!', '?', '"', '-', '{', '}', '/', '\\', '.'};
int count = 0;
for (char ch : str) {
if (punctuations.find(ch) != punctuations.end()) {
count++;
}
}
return count;
}
int main() {
string input;
getline(cin, input);
int punctuationCount = countPunctuations(input);
cout <<punctuationCount << endl;
return 0;
}
Deloitte โ
int solve(int input1, int input2[]) {Magical gems โ
int n = input1;
vector<int>v(n);
for (int i = 0; i < n; ++i)
{
v[i] = input2[i];
}
sort(v.begin(), v.end(), greater<int>());
vector<long long>suf(n);
for (int i = n - 1; i >= 0; --i)
{
if (i == n - 1)suf[i] = v[i];
else suf[i] += suf[i + 1] + v[i];
}
long long res = LLONG_MIN;
long long sm = 0;
for (int i = 0; i < n; ++i)
{
long long temp = (sm * (i)) + suf[i];
res = max(res, temp);
sm += v[i];
}
res = max(res, sm * n);
return res;
}
Sigmoid
โค1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
VMware Summer Internship 2025 ๐
Attention TPOs and Placement Officers! Share this exciting opportunity with your students and alumni!Work with VMware and dive into virtualization technologies!Key Details:
Company: VMware
Role: Software Engineering Intern
Stipend: INR 1,25,000/- per month
Internship Timeline: June - August 2025
Apply By: October 30, 2024
๐ Apply Here: [VMware Summer Internship](https://lnkd.in/gfcM3JmF)
VMware Summer InternshipThis internship is a fantastic opportunity for students to gain hands-on experience in a leading technology company, working on cutting-edge projects and technologies.
Attention TPOs and Placement Officers! Share this exciting opportunity with your students and alumni!Work with VMware and dive into virtualization technologies!Key Details:
Company: VMware
Role: Software Engineering Intern
Stipend: INR 1,25,000/- per month
Internship Timeline: June - August 2025
Apply By: October 30, 2024
๐ Apply Here: [VMware Summer Internship](https://lnkd.in/gfcM3JmF)
VMware Summer InternshipThis internship is a fantastic opportunity for students to gain hands-on experience in a leading technology company, working on cutting-edge projects and technologies.
lnkd.in
LinkedIn
This link will take you to a page thatโs not on LinkedIn
๐1
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;
int rescueKingGeorge(int input1, int input2, vector<vector<int>>& palace) {
pair<int, int> entrance, prison;
for (int i = 0; i < input1; i++) {
for (int j = 0; j < input2; j++) {
if (palace[i][j] == 1) entrance = {i, j};
if (palace[i][j] == 2) prison = {i, j};
}
}
vector<pair<int, int>> directions = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
queue<tuple<int, int, int>> q;
q.push({entrance.first, entrance.second, 1});
vector<vector<bool>> visited(input1, vector<bool>(input2, false));
visited[entrance.first][entrance.second] = true;
while (!q.empty()) {
auto [row, col, dist] = q.front();
q.pop();
if (row == prison.first && col == prison.second) {
return dist;
}
for (auto [dr, dc] : directions) {
int newRow = row + dr;
int newCol = col + dc;
if (newRow >= 0 && newRow < input1 && newCol >= 0 && newCol < input2 &&
!visited[newRow][newCol] && palace[newRow][newCol] != -1) {
visited[newRow][newCol] = true;
q.push({newRow, newCol, dist + 1});
}
}
}
return -1;
}
King georges
Sigmoid โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool solve(int power, const vector<int>& benches, const vector<int>& lampPosts) {
int n = benches.size();
int m = lampPosts.size();
int j = 0;
for (int i = 0; i < n; ++i) {
while (j < m && lampPosts[j] + power < benches[i]) {
++j;
}
if (j >= m || lampPosts[j] - power > benches[i]) {
return false;
}
}
return true;
}
int findMinPower(int numBenches, int numLampPosts, vector<int>& benches, vector<int>& lampPosts) {
sort(benches.begin(), benches.end());
sort(lampPosts.begin(), lampPosts.end());
int low = 0;
int high = max(benches.back(), lampPosts.back());
while (low < high) {
int mid = (low + high) / 2;
if (solve(mid, benches, lampPosts)) {
high = mid;
} else {
low = mid + 1;
}
}
return low;
}
illuminate the park
Sigmoidโ
long getMaximumEfficiency(vector<int> capacity, vector<int> numServers) {
int n = capacity.size();
int k = numServers.size();
sort(capacity.begin(), capacity.end());
sort(numServers.rbegin(), numServers.rend());
long maxEfficiency = 0;
int left = 0;
int right = n - 1;
for (int i = 0; i < k; i++) {
int batchSize = numServers[i];
int minCapacity = capacity[left];
int maxCapacity = capacity[right];
maxEfficiency += maxCapacity - minCapacity;
left += batchSize - 1;
right--;
}
return maxEfficiency;
}
DELL (Intern) โ
int n = capacity.size();
int k = numServers.size();
sort(capacity.begin(), capacity.end());
sort(numServers.rbegin(), numServers.rend());
long maxEfficiency = 0;
int left = 0;
int right = n - 1;
for (int i = 0; i < k; i++) {
int batchSize = numServers[i];
int minCapacity = capacity[left];
int maxCapacity = capacity[right];
maxEfficiency += maxCapacity - minCapacity;
left += batchSize - 1;
right--;
}
return maxEfficiency;
}
DELL (Intern) โ
function findMostEngagingPost(posts) {
let maxScore = -1;
let mostEngagingPostId = '';
posts.forEach(post => {
let score = post.likes * 2 + post.shares * 3 + post.comments;
if (score > maxScore || (score === maxScore && !mostEngagingPostId)) {
maxScore = score;
mostEngagingPostId = post.id;
}
});
return mostEngagingPostId;
}
DELL (Intern) โ
Social Media Post Analyzer
let maxScore = -1;
let mostEngagingPostId = '';
posts.forEach(post => {
let score = post.likes * 2 + post.shares * 3 + post.comments;
if (score > maxScore || (score === maxScore && !mostEngagingPostId)) {
maxScore = score;
mostEngagingPostId = post.id;
}
});
return mostEngagingPostId;
}
DELL (Intern) โ
Social Media Post Analyzer
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
๐Ficode Software Solutions Private Limited
Role: DevOps Engineer
๐ Location: Mohali
๐๏ธ Working: 5 Days a week
๐ Employment Type: Full-Time
โ๏ธShare your Resume/CV at career@ficode.com
Role: DevOps Engineer
๐ Location: Mohali
๐๏ธ Working: 5 Days a week
๐ Employment Type: Full-Time
โ๏ธShare your Resume/CV at career@ficode.com
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int findKthHighestDiamonds(string houses, int M, int K) {
vector<int> diamondCounts;
int n = houses.size();
if (M > n) {
return -1;
}
int currentDiamonds = 0;
for (int i = 0; i < M; ++i) {
if (houses[i] == '1') {
currentDiamonds++;
}
}
diamondCounts.push_back(currentDiamonds);
for (int i = M; i < n; ++i) {
if (houses[i - M] == '1') {
currentDiamonds--;
}
if (houses[i] == '1') {
currentDiamonds++;
}
diamondCounts.push_back(currentDiamonds);
}
sort(diamondCounts.begin(), diamondCounts.end(), greater<int>());
if (K > diamondCounts.size()) {
return -1;
}
return diamondCounts[K - 1];
}
Dimaond Thief
Sigmoid โ
๐1
#include <iostream>
#include <string>
using namespace std;
char lastOneStanding(string S, int K) {
string concatenatedString = "";
for (int i = 0; i < K; i++) {
concatenatedString += S;
}
int removeFromStart = 1;
while (concatenatedString.length() > 1) {
string newString = "";
int len = concatenatedString.length();
if (removeFromStart) {
for (int i = 1; i < len; i += 2) {
newString += concatenatedString[i];
}
} else {
for (int i = len - 2; i >= 0; i -= 2) {
newString = concatenatedString[i] + newString;
}
}
concatenatedString = newString;
removeFromStart = 1 - removeFromStart;
}
return concatenatedString[0];
}
Last one standingโ