#include <iostream>
#include <vector>
#include <set>
using namespace std;
int getSmallestArea(vector<vector<int>>& grid) {
int rows = grid.size();
if (rows == 0) return 0;
int cols = grid[0].size();
if (cols == 0) return 0;
set<int> rowsSet, colsSet;
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
if (grid[i][j] == 1) {
rowsSet.insert(i);
colsSet.insert(j);
}
}
}
int width = colsSet.empty() ? 0 : *colsSet.rbegin() - *colsSet.begin() + 1;
int height = rowsSet.empty() ? 0 : *rowsSet.rbegin() - *rowsSet.begin() + 1;
return width * height;
}
shipping space
Salesforce
Telegram:- @allcoding1
#include <vector>
#include <set>
using namespace std;
int getSmallestArea(vector<vector<int>>& grid) {
int rows = grid.size();
if (rows == 0) return 0;
int cols = grid[0].size();
if (cols == 0) return 0;
set<int> rowsSet, colsSet;
for (int i = 0; i < rows; ++i) {
for (int j = 0; j < cols; ++j) {
if (grid[i][j] == 1) {
rowsSet.insert(i);
colsSet.insert(j);
}
}
}
int width = colsSet.empty() ? 0 : *colsSet.rbegin() - *colsSet.begin() + 1;
int height = rowsSet.empty() ? 0 : *rowsSet.rbegin() - *rowsSet.begin() + 1;
return width * height;
}
shipping space
Salesforce
Telegram:- @allcoding1
π1
import heapq
def reduce_sum(lst):
heapq.heapify(lst)
s = 0
while len(lst) > 1:
first = heapq.heappop(lst)
second = heapq.heappop(lst)
s += first + second
heapq.heappush(lst, first + second)
return s
Reduce the Array
Salesforce
Telegram:- @allcoding1
def reduce_sum(lst):
heapq.heapify(lst)
s = 0
while len(lst) > 1:
first = heapq.heappop(lst)
second = heapq.heappop(lst)
s += first + second
heapq.heappush(lst, first + second)
return s
Reduce the Array
Salesforce
Telegram:- @allcoding1
#include <iostream>
#include <vector>
#include <algorithm>
int getPotentialOfWinner(std::vector<int>& potential, long long k) {
int n = potential.size();
int x = potential[0];
int m = 0;
for (int i = 1; i < n; i++) {
if (m != k) {
if (x > potential[i]) {
m++;
} else {
x = potential[i];
m = 1;
}
}
}
return x;
}
int main() {
std::vector<int> potentials = {3, 2, 1, 4};
long long k = 2;
std::cout << getPotentialOfWinner(potentials, k) << std::endl;
return 0;
}
Potential winner code
Telegram:- @allcoding1
#include <vector>
#include <algorithm>
int getPotentialOfWinner(std::vector<int>& potential, long long k) {
int n = potential.size();
int x = potential[0];
int m = 0;
for (int i = 1; i < n; i++) {
if (m != k) {
if (x > potential[i]) {
m++;
} else {
x = potential[i];
m = 1;
}
}
}
return x;
}
int main() {
std::vector<int> potentials = {3, 2, 1, 4};
long long k = 2;
std::cout << getPotentialOfWinner(potentials, k) << std::endl;
return 0;
}
Potential winner code
Telegram:- @allcoding1
π2
int minimumKeypresses(string s) {
unordered_map<char, int> counts;
for (char ch : s) {
counts[ch]++;
}
vector<int> frequencies;
for (const auto& kvp : counts) {
frequencies.push_back(kvp.second);
}
sort(frequencies.begin(), frequencies.end(), greater<int>());
vector<int> remain {9, 9, 9};
int i = 0, total = 0;
for (int count : frequencies) {
total += count * (i + 1);
remain[i]--;
if (remain[i] == 0) {
i++;
}
}
return total;
}
Amazon
Telegram:- @allcoding1
unordered_map<char, int> counts;
for (char ch : s) {
counts[ch]++;
}
vector<int> frequencies;
for (const auto& kvp : counts) {
frequencies.push_back(kvp.second);
}
sort(frequencies.begin(), frequencies.end(), greater<int>());
vector<int> remain {9, 9, 9};
int i = 0, total = 0;
for (int count : frequencies) {
total += count * (i + 1);
remain[i]--;
if (remain[i] == 0) {
i++;
}
}
return total;
}
Amazon
Telegram:- @allcoding1
β€1π1
def processExecution(power, minPower, maxPower):
result = []
for min_p, max_p in zip(minPower, maxPower):
count = sum(1 for p in power if min_p <= p <= max_p)
power_sum = sum(p for p in power if min_p <= p <= max_p)
result.append((count, power_sum))
return result
Amazon
Telegram:- @allcoding1
result = []
for min_p, max_p in zip(minPower, maxPower):
count = sum(1 for p in power if min_p <= p <= max_p)
power_sum = sum(p for p in power if min_p <= p <= max_p)
result.append((count, power_sum))
return result
Amazon
Telegram:- @allcoding1
β€3π1
TCS FREE NQT - Biggest Mass Hiring
Graduation Year: 2024
Eligibility: BTech / BE / MTech / ME / MCA / MSc / MS
Experience: Freshers
Salary:
Ninja - 3.36 LPA
Digital - 7 LPA
Prime - 9 LPA for UG and 11.5 LPA for PG
Apply now:- www.allcoding1.com
Registration End Date: 10 April 2024
Test Date: 26th April Onwards
Telegram:- @allcoding1
Graduation Year: 2024
Eligibility: BTech / BE / MTech / ME / MCA / MSc / MS
Experience: Freshers
Salary:
Ninja - 3.36 LPA
Digital - 7 LPA
Prime - 9 LPA for UG and 11.5 LPA for PG
Apply now:- www.allcoding1.com
Registration End Date: 10 April 2024
Test Date: 26th April Onwards
Telegram:- @allcoding1
π4
π―Indian Army recruitment for Engineers - male unmarried and below 27 years of age.
Batch : 2024, 2023, 2022 and previous passout batches.
Position : Lieutenant ( Pay Range : 56k-1.77L)
Apply Now:-
https://www.allcoding1.com/2024/04/indian-army.html
Batch : 2024, 2023, 2022 and previous passout batches.
Position : Lieutenant ( Pay Range : 56k-1.77L)
Apply Now:-
https://www.allcoding1.com/2024/04/indian-army.html
π3
π―Aera Hiring Automation Engineer Intern
Graduation Year: 2023 / 2024
Eligibility: Having a degree in Computer Science, Information Technology, or a related field; graduated in 2023 or after
Location: Pune
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
Graduation Year: 2023 / 2024
Eligibility: Having a degree in Computer Science, Information Technology, or a related field; graduated in 2023 or after
Location: Pune
Apply Now:- www.allcoding1.com
Telegram:- @allcoding1
π―Qualcomm Hiring Engineering Interns
Eligibility: Bachelor's or Master's Degree in Electrical Engineering, Computer Science Engineering, Communication Engineering, Electronics & Communications Engineering
1. Software Engineering Intern:
Graduation Year: 2024
2. Hardware Engineering Intern:
Graduation Year: 2025
Have Knowledge in PLL, LNA, OpAmp, CMOS, ADC/DAC, Cadence, SpectreRF, or Layout is required in RF/Analog/Mixed Signal IC Design
Location: Telangana, Bangalore, Chennai, Noida
Apply :- www.allcoding1.com
Telegram:- @allcoding1
Eligibility: Bachelor's or Master's Degree in Electrical Engineering, Computer Science Engineering, Communication Engineering, Electronics & Communications Engineering
1. Software Engineering Intern:
Graduation Year: 2024
2. Hardware Engineering Intern:
Graduation Year: 2025
Have Knowledge in PLL, LNA, OpAmp, CMOS, ADC/DAC, Cadence, SpectreRF, or Layout is required in RF/Analog/Mixed Signal IC Design
Location: Telangana, Bangalore, Chennai, Noida
Apply :- www.allcoding1.com
Telegram:- @allcoding1
π10π1
π―Agoda SDE Tech Internship 2024
Graduation Year: 2025 / 2026
Eligibility: Ongoing pursuit of a Bachelorβs or Masterβs Degree in Computer Science or a related field.
Internship period: July β Dec 2024
Interview process:
Registration closes: 21st April 2024
Hacker rank test starts: 26th April 2024
In-office interview date: 3rd May 2024
Location: Gurugram, Haryana
Apply Link: https://careersatagoda.com/job/5417820-tech-internship-2024-india-based-gurgaon-office/
Telegram:- @allcoding1
Graduation Year: 2025 / 2026
Eligibility: Ongoing pursuit of a Bachelorβs or Masterβs Degree in Computer Science or a related field.
Internship period: July β Dec 2024
Interview process:
Registration closes: 21st April 2024
Hacker rank test starts: 26th April 2024
In-office interview date: 3rd May 2024
Location: Gurugram, Haryana
Apply Link: https://careersatagoda.com/job/5417820-tech-internship-2024-india-based-gurgaon-office/
Telegram:- @allcoding1
π3
#include <iostream>
#include <string>
using namespace std;
int smallest_possible_number(const string& S) {
if (S.size() == 1 && S[0] == '0') {
return -1;
}
if (S.find('1') == string::npos) {
return -1;
}
int number = 1;
int n = S.size();
for (int i = n - 1; i >= 0; --i) {
if (S[i] == '1') {
if (number % (i + 1) != 0) {
number *= (i + 1);
}
} else {
while (number % (i + 1) == 0) {
number += 1;
}
}
}
return number;
}
Base Conversion
Telegram:- @allcoding1
#include <string>
using namespace std;
int smallest_possible_number(const string& S) {
if (S.size() == 1 && S[0] == '0') {
return -1;
}
if (S.find('1') == string::npos) {
return -1;
}
int number = 1;
int n = S.size();
for (int i = n - 1; i >= 0; --i) {
if (S[i] == '1') {
if (number % (i + 1) != 0) {
number *= (i + 1);
}
} else {
while (number % (i + 1) == 0) {
number += 1;
}
}
}
return number;
}
Base Conversion
Telegram:- @allcoding1
π2
#include<bits/stdc++.h>
using namespace std;
int main(){
string a,b,c; cin>>a>>b>>c;
vector<int>cnt(26,0);
for(auto ele: a){
cnt[ele-'A']++;
}
for(auto ele: b){
cnt[ele-'A']++;
}
for(auto ele: c){
cnt[ele-'A']--;
}
bool flag=true;
for(auto ele: cnt){
if(ele<0) flag=false;
}
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
Magnetic Letters
Telegram:- @allcoding1
using namespace std;
int main(){
string a,b,c; cin>>a>>b>>c;
vector<int>cnt(26,0);
for(auto ele: a){
cnt[ele-'A']++;
}
for(auto ele: b){
cnt[ele-'A']++;
}
for(auto ele: c){
cnt[ele-'A']--;
}
bool flag=true;
for(auto ele: cnt){
if(ele<0) flag=false;
}
if(flag) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
Magnetic Letters
Telegram:- @allcoding1
π2
private static double[] calculateMovingAverage(int[] array, int K) {
double[] smoothedArray = new double[array.length - K + 1];
double sum = 0;
for (int i = 0; i < K; i++) {
sum += array[i];
}
for (int i = 0; i <= array.length - K; i++) {
if (i > 0) {
sum = sum - array[i - 1] + array[i + K - 1];
}
smoothedArray[i] = sum / K;
}
return smoothedArray;
}
Moving Averages
Telegram:- @allcoding1
double[] smoothedArray = new double[array.length - K + 1];
double sum = 0;
for (int i = 0; i < K; i++) {
sum += array[i];
}
for (int i = 0; i <= array.length - K; i++) {
if (i > 0) {
sum = sum - array[i - 1] + array[i + K - 1];
}
smoothedArray[i] = sum / K;
}
return smoothedArray;
}
Moving Averages
Telegram:- @allcoding1
π5
#include <iostream>
#include <vector>
using namespace std;
vector<int> HeightProblem(int n, vector<int>& arr) {
vector<int> ans(n);
for (int i = 0; i < n; ++i) {
int height = arr[i];
int closestLeftHeight = -1;
for (int j = i - 1; j >= 0; --j) {
if (arr[j] < height) {
closestLeftHeight = arr[j];
break;
}
}
ans[i] = closestLeftHeight;
}
return ans;
}
Height problem
@allcoding1
#include <vector>
using namespace std;
vector<int> HeightProblem(int n, vector<int>& arr) {
vector<int> ans(n);
for (int i = 0; i < n; ++i) {
int height = arr[i];
int closestLeftHeight = -1;
for (int j = i - 1; j >= 0; --j) {
if (arr[j] < height) {
closestLeftHeight = arr[j];
break;
}
}
ans[i] = closestLeftHeight;
}
return ans;
}
Height problem
@allcoding1
π2
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll solve(vector<int>a)
{
set<int>s(a.begin(),a.end());
ll mex=0;
while (s.count(mex)) mex++;
ll ans=distance(s.lower_bound(mex),s.end());
if(ans==a.size()) return -2;
return ans;
}
int main() {
int n; cin>>n;
vector<int>arr(n);
for(int i=0;i<n;i++) cin>>arr[i];
cout<<solve(arr);
return 0;
}
Mex Number
@allcoding1
#define ll long long
using namespace std;
ll solve(vector<int>a)
{
set<int>s(a.begin(),a.end());
ll mex=0;
while (s.count(mex)) mex++;
ll ans=distance(s.lower_bound(mex),s.end());
if(ans==a.size()) return -2;
return ans;
}
int main() {
int n; cin>>n;
vector<int>arr(n);
for(int i=0;i<n;i++) cin>>arr[i];
cout<<solve(arr);
return 0;
}
Mex Number
@allcoding1
π1