#include<bits/stdc++.h>
using namespace std;
int alphaBitwise(vector<int>& A) {
int N = A.size();
int result = 0;
for (int i = 0; i < 32; i++) {
int count = 0;
for (int num : A) {
if ((num >> i) & 1) {
count++;
}
}
if (count > N / 2) {
result |= (1 << i);
}
}
return result;
}
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int alpha = alphaBitwise(A);
cout << alpha << endl;
return 0;
}
Alpha bitwiseโ
using namespace std;
int alphaBitwise(vector<int>& A) {
int N = A.size();
int result = 0;
for (int i = 0; i < 32; i++) {
int count = 0;
for (int num : A) {
if ((num >> i) & 1) {
count++;
}
}
if (count > N / 2) {
result |= (1 << i);
}
}
return result;
}
int main() {
int N;
cin >> N;
vector<int> A(N);
for (int i = 0; i < N; i++) {
cin >> A[i];
}
int alpha = alphaBitwise(A);
cout << alpha << endl;
return 0;
}
Alpha bitwiseโ
๐1
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
cout<<(n*(n-1)) - n/2 ;
}
Gcd and lcm โ
using namespace std;
int main() {
int n;
cin>>n;
cout<<(n*(n-1)) - n/2 ;
}
Gcd and lcm โ
int calculateMaxLength(vector<int> &values) {
vector<int> longestIncreasingSubsequence;
int currentIndex = 1, size = values.size();
longestIncreasingSubsequence.push_back(values[0]);
while (currentIndex < size) {
if (values[currentIndex] < longestIncreasingSubsequence.back()) {
if (currentIndex == size - 1 || values[currentIndex] + longestIncreasingSubsequence.back() <= values[currentIndex + 1]) {
longestIncreasingSubsequence.back() += values[currentIndex];
currentIndex++;
} else {
values[currentIndex + 1] += values[currentIndex];
currentIndex++;
}
} else {
longestIncreasingSubsequence.push_back(values[currentIndex]);
currentIndex++;
}
}
return longestIncreasingSubsequence.size();
}
Non Decreasing Array โ
vector<int> longestIncreasingSubsequence;
int currentIndex = 1, size = values.size();
longestIncreasingSubsequence.push_back(values[0]);
while (currentIndex < size) {
if (values[currentIndex] < longestIncreasingSubsequence.back()) {
if (currentIndex == size - 1 || values[currentIndex] + longestIncreasingSubsequence.back() <= values[currentIndex + 1]) {
longestIncreasingSubsequence.back() += values[currentIndex];
currentIndex++;
} else {
values[currentIndex + 1] += values[currentIndex];
currentIndex++;
}
} else {
longestIncreasingSubsequence.push_back(values[currentIndex]);
currentIndex++;
}
}
return longestIncreasingSubsequence.size();
}
Non Decreasing Array โ
#include <iostream>
#include <string>
#include <vector>
#include <set>
using namespace std;
void generate_strings(vector<string>& strings, string prefix, int remaining) {
if (remaining == 0) {
strings.push_back(prefix);
return;
}
generate_strings(strings, prefix + '0', remaining - 1);
generate_strings(strings, prefix + '1', remaining - 1);
}
bool is_substring(const string& input_string, const string& substring) {
for (int i = 0; i < input_string.length(); ++i) {
string rotated_string = input_string.substr(i) + input_string.substr(0, i);
if (rotated_string.find(substring) != string::npos) {
return true;
}
}
return false;
}
int count_distinct_strings(const string& str, int N) {
vector<string> strings;
generate_strings(strings, "", N);
set<string> distinct_strings;
for (const string& s : strings) {
if (is_substring(s, str)) {
distinct_strings.insert(s);
}
}
return distinct_strings.size();
}
int main() {
string str;
int N;
cin >> N;
cin >> str;
int count = count_distinct_strings(str, N);
cout << count << endl;
return 0;
}
Look A Like โ
#include <string>
#include <vector>
#include <set>
using namespace std;
void generate_strings(vector<string>& strings, string prefix, int remaining) {
if (remaining == 0) {
strings.push_back(prefix);
return;
}
generate_strings(strings, prefix + '0', remaining - 1);
generate_strings(strings, prefix + '1', remaining - 1);
}
bool is_substring(const string& input_string, const string& substring) {
for (int i = 0; i < input_string.length(); ++i) {
string rotated_string = input_string.substr(i) + input_string.substr(0, i);
if (rotated_string.find(substring) != string::npos) {
return true;
}
}
return false;
}
int count_distinct_strings(const string& str, int N) {
vector<string> strings;
generate_strings(strings, "", N);
set<string> distinct_strings;
for (const string& s : strings) {
if (is_substring(s, str)) {
distinct_strings.insert(s);
}
}
return distinct_strings.size();
}
int main() {
string str;
int N;
cin >> N;
cin >> str;
int count = count_distinct_strings(str, N);
cout << count << endl;
return 0;
}
Look A Like โ
// rat and chesse
#include<bits/stdc++.h>
using namespace std;
int bfs(vector<vector<int>>&grid){
queue<pair<int,int>>q;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[0].size();j++){
if(grid[i][j]==2)q.push({i,j});
}
}
int time=0;
while(!q.empty()){
int k=q.size();
bool found=false;
while(k--){
int r=q.front().first,c=q.front().second;
q.pop();
grid[r][c]=2;
for(int i=0;i<4;i++){
int row=r+dx[i],col=c+dy[i];
if(row>=0&&row<grid.size()&&col>=0&&col<grid[0].size()&&grid[row][col]==1){
q.push({row,col});found=true;
grid[row][col]=2;
}
}
}
if(found)
time++;
}
// check -1
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[0].size();j++){
if(grid[i][j]==1)return -1;
}
}
return time;
}
int main(){
vector<vector<int>>v={{2,1,1},{1,1,0},{0,1,1}};
cout<<bfs(v);
}
#include<bits/stdc++.h>
using namespace std;
int bfs(vector<vector<int>>&grid){
queue<pair<int,int>>q;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[0].size();j++){
if(grid[i][j]==2)q.push({i,j});
}
}
int time=0;
while(!q.empty()){
int k=q.size();
bool found=false;
while(k--){
int r=q.front().first,c=q.front().second;
q.pop();
grid[r][c]=2;
for(int i=0;i<4;i++){
int row=r+dx[i],col=c+dy[i];
if(row>=0&&row<grid.size()&&col>=0&&col<grid[0].size()&&grid[row][col]==1){
q.push({row,col});found=true;
grid[row][col]=2;
}
}
}
if(found)
time++;
}
// check -1
for(int i=0;i<grid.size();i++){
for(int j=0;j<grid[0].size();j++){
if(grid[i][j]==1)return -1;
}
}
return time;
}
int main(){
vector<vector<int>>v={{2,1,1},{1,1,0},{0,1,1}};
cout<<bfs(v);
}
Get the Max productโ
#include<bits/stdc++.h>
using namespace std;
int length(string s){
bool found=false;
int temp=0;
for(int i=0;i<s.size();i++){
if(isdigit(s[i])){
found=true;
temp*=10;
temp+=(s[i]-'0');
}
}
if(found==false){
return s.size();
}
return temp;
}
long long solve(vector<string>v,int n){
vector<int>len;
for(int i=0;i<n;i++){
len.push_back(length(v[i]));
}
int max1=0,max2=0;
for(int i=0;i<n;i++){
if(len[i]>max1){
max2=max1;
max1=len[i];
}
else if(len[i]>max2){
max2=len[i];
}
}
return max1*max2*1ll;
return len[n-1]*len[n-2]*1ll;
}
int main(){
int n;cin>>n;
vector<string>v(n,"");
for(int i=0;i<n;i++)
{
cin>>v[i];
}
cout<<solve(v,n);
}
#include<bits/stdc++.h>
using namespace std;
int length(string s){
bool found=false;
int temp=0;
for(int i=0;i<s.size();i++){
if(isdigit(s[i])){
found=true;
temp*=10;
temp+=(s[i]-'0');
}
}
if(found==false){
return s.size();
}
return temp;
}
long long solve(vector<string>v,int n){
vector<int>len;
for(int i=0;i<n;i++){
len.push_back(length(v[i]));
}
int max1=0,max2=0;
for(int i=0;i<n;i++){
if(len[i]>max1){
max2=max1;
max1=len[i];
}
else if(len[i]>max2){
max2=len[i];
}
}
return max1*max2*1ll;
return len[n-1]*len[n-2]*1ll;
}
int main(){
int n;cin>>n;
vector<string>v(n,"");
for(int i=0;i<n;i++)
{
cin>>v[i];
}
cout<<solve(v,n);
}
#include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
vector<int> v(100005);
for(int i = 0; i < n; i++) cin>>v[i];
int ans = 0;
int i = n-1;
while(i >= 0) {
if(v[i] >= 0) {
ans += v[i]; i--; continue;
}
else {
v[i] *= -1;
int y = v[i], x = 0;
ans += v[i]; i--;
while(i >= 0 && v[i] >= 0) {
x += v[i];
i--;
if(x >= y) break;
}
}
}
cout<<ans;
return 0;
}
Good Sum โ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Linkedin
kirti hirani on LinkedIn: #hiring #engineering #consultadd #engineers
Hi folks,
Join Our Team as an Information Systems Engineer - Exclusive Opportunity for 2023 Batch Graduates!
Position: Information Systems Engineer
Package:โฆ
Join Our Team as an Information Systems Engineer - Exclusive Opportunity for 2023 Batch Graduates!
Position: Information Systems Engineer
Package:โฆ
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Scholarship for Third Year Engineering Students by Micron Technology.
Scholarship worth 80,000 INR โจโจ
Last Date of Application is 30th September โ23
Link to apply : https://uramscholarship.co.in/form.html
Scholarship worth 80,000 INR โจโจ
Last Date of Application is 30th September โ23
Link to apply : https://uramscholarship.co.in/form.html
int MinimumCost(int n, int m, vector<vector<int>>& grid) {
vector<int> ele;
vector<vector<int>> grid_inv(m, vector<int>(n));
for (int j = 0; j < m; j += 1) {
for (int i = 0; i < n; i += 1) {
grid_inv[j][i] = grid[i][j];
}
}
for (int j = 0; j < m; j += 1) {
sort(grid_inv[j].begin(), grid_inv[j].end());
}
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < m; j += 1) {
ele.push_back(grid[i][j]);
}
}
sort(ele.begin(), ele.end());
int sz = ele.size();
int ans = 1e9; // Assuming int limit is sufficient for ans
for (int i = 0; i < ele.size(); i += 1) {
int mx = ele[i];
bool f = 1;
int mn = 1e9; // Assuming int limit is sufficient for mn
for (int j = 0; j < m; j += 1) {
int idx = lower_bound(grid_inv[j].begin(), grid_inv[j].end(), mx) - grid_inv[j].begin();
if (idx >= n || grid_inv[j][idx] > mx) idx--;
if (idx < 0) {
f = 0;
break;
}
mn = min(mn, grid_inv[j][idx]);
}
if (f) ans = min(ans, mx - mn);
}
return ans;
}
Minimum Cost pathโ
vector<int> ele;
vector<vector<int>> grid_inv(m, vector<int>(n));
for (int j = 0; j < m; j += 1) {
for (int i = 0; i < n; i += 1) {
grid_inv[j][i] = grid[i][j];
}
}
for (int j = 0; j < m; j += 1) {
sort(grid_inv[j].begin(), grid_inv[j].end());
}
for (int i = 0; i < n; i += 1) {
for (int j = 0; j < m; j += 1) {
ele.push_back(grid[i][j]);
}
}
sort(ele.begin(), ele.end());
int sz = ele.size();
int ans = 1e9; // Assuming int limit is sufficient for ans
for (int i = 0; i < ele.size(); i += 1) {
int mx = ele[i];
bool f = 1;
int mn = 1e9; // Assuming int limit is sufficient for mn
for (int j = 0; j < m; j += 1) {
int idx = lower_bound(grid_inv[j].begin(), grid_inv[j].end(), mx) - grid_inv[j].begin();
if (idx >= n || grid_inv[j][idx] > mx) idx--;
if (idx < 0) {
f = 0;
break;
}
mn = min(mn, grid_inv[j][idx]);
}
if (f) ans = min(ans, mx - mn);
}
return ans;
}
Minimum Cost pathโ
int solve(string S) {
set<int> decimalValues;
int n = S.length();
for (int i = 1; i < (1 << n); i++) {
int subsequenceDecimal = 0;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
subsequenceDecimal = subsequenceDecimal * 2 + (S[j] - '0');
}
}
decimalValues.insert(subsequenceDecimal);
}
int distinctDecimalValues = decimalValues.size();
int moduloResult = distinctDecimalValues % (int)(1e9 + 7);
return moduloResult;
}
Distinct Subsequenceโ
set<int> decimalValues;
int n = S.length();
for (int i = 1; i < (1 << n); i++) {
int subsequenceDecimal = 0;
for (int j = 0; j < n; j++) {
if (i & (1 << j)) {
subsequenceDecimal = subsequenceDecimal * 2 + (S[j] - '0');
}
}
decimalValues.insert(subsequenceDecimal);
}
int distinctDecimalValues = decimalValues.size();
int moduloResult = distinctDecimalValues % (int)(1e9 + 7);
return moduloResult;
}
Distinct Subsequenceโ
int countKSubsequencesWithMaxBeauty(string s, int k) {
vector<int> count(26);
for (char& c : s)
count[c - 'a']++;
nth_element(count.begin(), count.begin() + 26 - k, count.end());
if (k > 26 || count[26 - k] == 0)
return 0;
long long res = 1, comb = 1, bar = count[26 - k], mod = 1e9 + 7, pend = 0;
for (int& freq : count) {
if (freq > bar) {
k--;
res = res * freq % mod;
}
if (freq == bar)
pend++;
}
for (int i = 0; i < k; ++i) {
comb = comb * (pend - i) / (i + 1);
res = res * bar % mod;
}
return res * comb % mod;
}
GOOGLE SPECIAL-SUBSEQUENCE CODE
vector<int> count(26);
for (char& c : s)
count[c - 'a']++;
nth_element(count.begin(), count.begin() + 26 - k, count.end());
if (k > 26 || count[26 - k] == 0)
return 0;
long long res = 1, comb = 1, bar = count[26 - k], mod = 1e9 + 7, pend = 0;
for (int& freq : count) {
if (freq > bar) {
k--;
res = res * freq % mod;
}
if (freq == bar)
pend++;
}
for (int i = 0; i < k; ++i) {
comb = comb * (pend - i) / (i + 1);
res = res * bar % mod;
}
return res * comb % mod;
}
GOOGLE SPECIAL-SUBSEQUENCE CODE
๐1๐คฎ1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Company Name: IndiGG
Role: Technology Intern
Batch eligible: 2023 and 2024 grads
Apply: https://www.linkedin.com/jobs/view/3726795075
Role: Technology Intern
Batch eligible: 2023 and 2024 grads
Apply: https://www.linkedin.com/jobs/view/3726795075
Linkedin
IndiGG hiring Technology Interns-Backend & Frontend(Drive 30 Sept to 02 Oct 2023) in Bengaluru, Karnataka, India | LinkedIn
Posted 12:44:28 PM. About IndiGGIndiGG is a โnetwork stateโ built around 500M+ Indian Gamers. IndiGGโs mission is toโฆ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)
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Sutherland Walk-In Interview
1st October โ 6th October , 9.30 AM โ 5.30 PM
How to Apply:
Interested candidates are invited to attend a walk-in interview. Please mention โHR Priyaโ at the top of your resume. Donโt forget to bring your resume, a photocopy of your Aadhar card, and your COVID-19 vaccination certificate (2/3 doses).
Walk-in Details:
Date: October 1st โ October 6th
Time: 9:30 AM โ 5:30 PM
Location: Survey No. 201, Lanco Hills Technology Park, Lanco Hills, Sai Vaibhav Layout, Manikonda, Hyderabad, 500089, India.
Contact Information: For inquiries, contact Priya at 9032420290.
1st October โ 6th October , 9.30 AM โ 5.30 PM
How to Apply:
Interested candidates are invited to attend a walk-in interview. Please mention โHR Priyaโ at the top of your resume. Donโt forget to bring your resume, a photocopy of your Aadhar card, and your COVID-19 vaccination certificate (2/3 doses).
Walk-in Details:
Date: October 1st โ October 6th
Time: 9:30 AM โ 5:30 PM
Location: Survey No. 201, Lanco Hills Technology Park, Lanco Hills, Sai Vaibhav Layout, Manikonda, Hyderabad, 500089, India.
Contact Information: For inquiries, contact Priya at 9032420290.
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Egencia
Role: Software Development Engineer II
Type: Freshers
Location: Gurgaon, India
https://jobs.talenlio.com/job/software-development-engineer-ii
Role: Software Development Engineer II
Type: Freshers
Location: Gurgaon, India
https://jobs.talenlio.com/job/software-development-engineer-ii
Talenlio
Software Development Engineer II - Egencia
Amex GBT Egencia is the only proven, global B2B travel tech platform.