int countSetBits(int n) {
int count = 0;
while (n) {
count += n & 1;
n >>= 1;
}
return count;
}
int countSubsetsWithSumSetBitsEqualToK(const vector<int>& arr, int k) {
int n = arr.size();
int subsetCount = 0;
int totalSubsets = 1 << n;
for (int i = 0; i < totalSubsets; ++i) {
int subsetSum = 0;
for (int j = 0; j < n; ++j) {
if (i & (1 << j)) {
subsetSum += arr[j];
}
}
if (countSetBits(subsetSum) == k) {
++subsetCount;
}
}
return subsetCount;
}
Hack on Amazon โ
int count = 0;
while (n) {
count += n & 1;
n >>= 1;
}
return count;
}
int countSubsetsWithSumSetBitsEqualToK(const vector<int>& arr, int k) {
int n = arr.size();
int subsetCount = 0;
int totalSubsets = 1 << n;
for (int i = 0; i < totalSubsets; ++i) {
int subsetSum = 0;
for (int j = 0; j < n; ++j) {
if (i & (1 << j)) {
subsetSum += arr[j];
}
}
if (countSetBits(subsetSum) == k) {
++subsetCount;
}
}
return subsetCount;
}
Hack on Amazon โ
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
int calculate_operations(std::vector<int>& arr, int target) {
int operations = 0;
for (int num : arr) {
operations += std::abs(num - target);
}
return operations;
}
int main() {
int N;
std::cin >> N;
std::vector<int> A(N);
for (int i = 0; i < N; ++i) {
std::cin >> A[i];
}
std::sort(A.begin(), A.end());
int median = A[N / 2];
int min_operations = calculate_operations(A, median);
for (int i = 0; i < N; ++i) {
int original_value = A[i];
A[i] = median;
int operations_with_free_move = calculate_operations(A, median);
min_operations = std::min(min_operations, operations_with_free_move);
A[i] = original_value;
}
std::cout << min_operations << std::endl;
return 0;
}
Hack on Amazon โ
#include <vector>
#include <algorithm>
#include <cmath>
int calculate_operations(std::vector<int>& arr, int target) {
int operations = 0;
for (int num : arr) {
operations += std::abs(num - target);
}
return operations;
}
int main() {
int N;
std::cin >> N;
std::vector<int> A(N);
for (int i = 0; i < N; ++i) {
std::cin >> A[i];
}
std::sort(A.begin(), A.end());
int median = A[N / 2];
int min_operations = calculate_operations(A, median);
for (int i = 0; i < N; ++i) {
int original_value = A[i];
A[i] = median;
int operations_with_free_move = calculate_operations(A, median);
min_operations = std::min(min_operations, operations_with_free_move);
A[i] = original_value;
}
std::cout << min_operations << std::endl;
return 0;
}
Hack on Amazon โ
๐๐ฆ ๐๐น๐ด๐ผ ๐ป ๐ ใ๐๐ผ๐บ๐ฝ๐ฒ๐๐ถ๐๐ถ๐๐ฒ ๐ฃ๐ฟ๐ผ๐ด๐ฟ๐ฎ๐บ๐บ๐ถ๐ป๐ดใ
Photo
#include <iostream>
#include <vector>
using namespace std;
struct Edge {
int to;
bool visited;
};
void dfs(int node, vector<vector<Edge>>& tree, vector<bool>& visited) {
visited[node] = true;
for (auto& edge : tree[node]) {
if (!visited[edge.to]) {
if (!edge.visited) {
edge.visited = true;
for (auto& reverseEdge : tree[edge.to]) {
if (reverseEdge.to == node) {
reverseEdge.visited = true;
break;
}
}
dfs(edge.to, tree, visited);
}
}
}
}
int main() {
int N;
cin >> N;
vector<vector<Edge>> tree(N + 1);
for (int i = 0; i < N - 1; ++i) {
int u, v, c;
cin >> u >> v >> c;
tree[u].push_back({v, c == 1});
tree[v].push_back({u, c == 1});
}
vector<bool> visited(N + 1, false);
int carCount = 0;
for (int i = 2; i <= N; ++i) {
if (!visited[i]) {
for (auto& edge : tree[i]) {
if (edge.to == 1 && !edge.visited) {
edge.visited = true;
for (auto& reverseEdge : tree[1]) {
if (reverseEdge.to == i) {
reverseEdge.visited = true;
break;
}
}
carCount++;
dfs(i, tree, visited);
break;
}
}
}
}
cout << carCount << endl;
return 0;
}
Hack on Amazon โ
#include <vector>
using namespace std;
struct Edge {
int to;
bool visited;
};
void dfs(int node, vector<vector<Edge>>& tree, vector<bool>& visited) {
visited[node] = true;
for (auto& edge : tree[node]) {
if (!visited[edge.to]) {
if (!edge.visited) {
edge.visited = true;
for (auto& reverseEdge : tree[edge.to]) {
if (reverseEdge.to == node) {
reverseEdge.visited = true;
break;
}
}
dfs(edge.to, tree, visited);
}
}
}
}
int main() {
int N;
cin >> N;
vector<vector<Edge>> tree(N + 1);
for (int i = 0; i < N - 1; ++i) {
int u, v, c;
cin >> u >> v >> c;
tree[u].push_back({v, c == 1});
tree[v].push_back({u, c == 1});
}
vector<bool> visited(N + 1, false);
int carCount = 0;
for (int i = 2; i <= N; ++i) {
if (!visited[i]) {
for (auto& edge : tree[i]) {
if (edge.to == 1 && !edge.visited) {
edge.visited = true;
for (auto& reverseEdge : tree[1]) {
if (reverseEdge.to == i) {
reverseEdge.visited = true;
break;
}
}
carCount++;
dfs(i, tree, visited);
break;
}
}
}
}
cout << carCount << endl;
return 0;
}
Hack on Amazon โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Free Certification Courses
1) JavaScript Fundamentals
2) SQL
3) Git and GitHub
4) HTML and CSS
5) Basic projects
6) OOPs (Newly added)
This are the 5 courses which are available for free, and when you will join corporate this are the basic requirements.
Link: https://bit.ly/4avpEUz
Limited time ke liye hai, enroll as soon as possible (Isse pehle paid krde) ๐ค๐ค
1) JavaScript Fundamentals
2) SQL
3) Git and GitHub
4) HTML and CSS
5) Basic projects
6) OOPs (Newly added)
This are the 5 courses which are available for free, and when you will join corporate this are the basic requirements.
Link: https://bit.ly/4avpEUz
Limited time ke liye hai, enroll as soon as possible (Isse pehle paid krde) ๐ค๐ค
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
// int t;
// cin >> t;
// while(t--){
int n ;
cin >> n ;
vector<int> vec(n);
for(int i = 0 ;i < n ; ++i){
cin >> vec[i];
}
sort(vec.begin(),vec.end());
for(auto it : vec)
cout << it << " ";
cout << "\n";
// }
}
Hack on Amazon โ
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int totalCoins = 0;
int i = 1;
while (true) {
int coins = N / i;
if (coins < 1) {
break;
}
totalCoins += coins;
i++;
}
cout << totalCoins << endl;
return 0;
}
Hack on Amazon โ
using namespace std;
int main() {
int N;
cin >> N;
int totalCoins = 0;
int i = 1;
while (true) {
int coins = N / i;
if (coins < 1) {
break;
}
totalCoins += coins;
i++;
}
cout << totalCoins << endl;
return 0;
}
Hack on Amazon โ
๐1
#include <iostream>
using namespace std;
const int MOD = 1e9 + 7;
long long binomialCoefficient(int n, int k) {
if (k > n - k) {
k = n - k;
}
long long res = 1;
for (int i = 0; i < k; ++i) {
res = (res * (n - i)) % MOD;
res /= (i + 1);
}
return res % MOD;
}
int countDistinctSequences(int x, int y) {
return binomialCoefficient(y - 1, x - 1);
}
int main() {
int x, y;
cin >> x >> y;
int result = countDistinctSequences(x, y);
cout << result << endl;
return 0;
}
Hacks on Amazon โ
using namespace std;
const int MOD = 1e9 + 7;
long long binomialCoefficient(int n, int k) {
if (k > n - k) {
k = n - k;
}
long long res = 1;
for (int i = 0; i < k; ++i) {
res = (res * (n - i)) % MOD;
res /= (i + 1);
}
return res % MOD;
}
int countDistinctSequences(int x, int y) {
return binomialCoefficient(y - 1, x - 1);
}
int main() {
int x, y;
cin >> x >> y;
int result = countDistinctSequences(x, y);
cout << result << endl;
return 0;
}
Hacks on Amazon โ
๐2
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string lexicographicallySmallest(string P, string Q) {
int N = P.size();
for (int i = 0; i < N; ++i) {
if (P[i] == Q[i]) {
char replacement = 'a';
while (replacement == P[i] || replacement == Q[i]) {
replacement++;
}
P[i] = replacement;
}
}
return P;
}
int main() {
int N;
string P, Q;
cin >> N >> P >> Q;
string result = lexicographicallySmallest(P, Q);
cout << result << endl;
return 0;
}
Hacks on Amazon โ
#include <string>
#include <algorithm>
using namespace std;
string lexicographicallySmallest(string P, string Q) {
int N = P.size();
for (int i = 0; i < N; ++i) {
if (P[i] == Q[i]) {
char replacement = 'a';
while (replacement == P[i] || replacement == Q[i]) {
replacement++;
}
P[i] = replacement;
}
}
return P;
}
int main() {
int N;
string P, Q;
cin >> N >> P >> Q;
string result = lexicographicallySmallest(P, Q);
cout << result << endl;
return 0;
}
Hacks on Amazon โ
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Vance is hiring Backend Engineer
Location - Bangalore
For 2023, 2022, 2021 grads
https://jobs.ashbyhq.com/Vance/0f36d788-0863-412f-a619-5774d0a15fdd/application?utm_source=r9bA27AdXn
Location - Bangalore
For 2023, 2022, 2021 grads
https://jobs.ashbyhq.com/Vance/0f36d788-0863-412f-a619-5774d0a15fdd/application?utm_source=r9bA27AdXn
Ashbyhq
Backend Engineer
๐ Vance seeks Backend Engineers! Innovate in fintech with Java Spring Boot. Bangalore-based role with growth opportunities. #BackendEngineer #Hiring #Fintech
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Castellum Labs is hiring Python Developer Intern
Location - Hyderabad
For 2024 grads
Check out this job at Castellum Labs: https://www.linkedin.com/jobs/view/3936686440
Location - Hyderabad
For 2024 grads
Check out this job at Castellum Labs: https://www.linkedin.com/jobs/view/3936686440
Linkedin
Castellum Labs hiring Python Developer Internship/Trainee in Hyderabad, Telangana, India | LinkedIn
Posted 9:11:01 AM. Company DescriptionCastellum Labs is a next-generation cybersecurity technology venture based inโฆ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)
Kaplan is hiring Associate Software Engineer
For 2023, 2022 grads
https://ghc.wd1.myworkdayjobs.com/Kaplan_Careers/job/Bangalore-KA-India/Associate-Software-Engineer--Hybrid-_JR238196
For 2023, 2022 grads
https://ghc.wd1.myworkdayjobs.com/Kaplan_Careers/job/Bangalore-KA-India/Associate-Software-Engineer--Hybrid-_JR238196
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Deloitte is looking for potential candidates in Risk Consulting Profile
Hiring for Analyst/Senior Analyst positions
Educational Qualifications- Graduate
Work Experience- 0-2 years
Skills-
โขStrong writing skills- Excellent command over written English
โขAbility to work independently with minimal supervision
โขHigh standard of accuracy and eye for detail
โขExcellent time management skill
If interested, kindly share your updated CV with sakshide21@gmail.com with subject as - RA_Analyst/ Senior Analyst
Hiring for Analyst/Senior Analyst positions
Educational Qualifications- Graduate
Work Experience- 0-2 years
Skills-
โขStrong writing skills- Excellent command over written English
โขAbility to work independently with minimal supervision
โขHigh standard of accuracy and eye for detail
โขExcellent time management skill
If interested, kindly share your updated CV with sakshide21@gmail.com with subject as - RA_Analyst/ Senior Analyst
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
SPHERE.IO IS HIRING!!!
https://www.linkedin.com/company/spehre-io/
Contact the HR for further processing
https://www.linkedin.com/in/asmita-santra-238364226?
Or Email the cv at : asmitasantra04@gmail.com
BCOM, M.COM, B.SC,M.SC, BA, MA CAN APPLY
NON IT DOMAIN CANDIDATES
NO B.TECH, M.TECH, BCA, MCA
*ABOUT COMPANY:-*
Spehre is a platform for building a comprehensive professional profile. Its AI rating system evaluates the educational background, work experience, and skillset of users to create a unique rating that reflects their qualifications and capabilities. Recruiters can use Spehre to match job requirements with Spehre-rated candidates, streamlining the hiring process.
*CRITERIA*:-
Under Graduates/ Graduates/ Freshers
*DURATION* :- 2 months (remote internship)
*ON COMPLETION* :-
- Various Certificates
- Performance Based Stipend (up to 10k)
- Letter of Recommendation
- PPO (if you perform well)
https://www.linkedin.com/company/spehre-io/
Contact the HR for further processing
https://www.linkedin.com/in/asmita-santra-238364226?
Or Email the cv at : asmitasantra04@gmail.com
BCOM, M.COM, B.SC,M.SC, BA, MA CAN APPLY
NON IT DOMAIN CANDIDATES
NO B.TECH, M.TECH, BCA, MCA
*ABOUT COMPANY:-*
Spehre is a platform for building a comprehensive professional profile. Its AI rating system evaluates the educational background, work experience, and skillset of users to create a unique rating that reflects their qualifications and capabilities. Recruiters can use Spehre to match job requirements with Spehre-rated candidates, streamlining the hiring process.
*CRITERIA*:-
Under Graduates/ Graduates/ Freshers
*DURATION* :- 2 months (remote internship)
*ON COMPLETION* :-
- Various Certificates
- Performance Based Stipend (up to 10k)
- Letter of Recommendation
- PPO (if you perform well)
๐1
Forwarded from OffCampus Jobs | OnCampus Jobs | Daily Jobs Updates | Lastest Jobs | All Jobs | CSE Jobs | Fresher Jobs โฅ (Dushyant)
Magically Genius is hiring Backend Developer Intern
Remote opportunity
Check out this job at Magically Genius: https://www.linkedin.com/jobs/view/3936903266
For 2024, 2025, 2026 grads
Remote opportunity
Check out this job at Magically Genius: https://www.linkedin.com/jobs/view/3936903266
For 2024, 2025, 2026 grads
Linkedin
Magically Genius hiring Back End Developer intern in India | LinkedIn
Posted 6:07:00 PM. Role DescriptionThis is a full-time remote role for a back-end developer intern at Magicallyโฆ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)
Infosys is hiring for Chartered Accountants with 0-4 years of post qualification experience for various finance functions.
Job location : Bangalore
If interested share your resume at : Nikhil.shetty04@infosys.com
Job location : Bangalore
If interested share your resume at : Nikhil.shetty04@infosys.com