Accenture Recent Codingquestions
Accenture Recent Codingquestions
org/lucky-numbers/
7) And other is
We have two arrays
E and J, E array have N size and J array have N-1 size and we have a devil energy as a integer
number.
Initially the energy is 0 then
In every hour we have to gain energy from the E array where each index represents different
cities.if the energy is enough to make the jump from one city to next then then subtract the
jump energy that comes from J array then now onwards add that city energy to our energy
variable.
When our energy is greater than or equal to devil energy return the number of hrs required
to kill that hrs.
The array is in non- decreasing order.
Input format
3 20
578
10 11
Output:
7 hrs
8) GCD,and stair case problem are repeatededly asked in slots so focus on them also
Coding:-
C++ code to find the total number of pairs of a,b such that the gcd(a,b)=x where 1<a<b<=l:
int gcd(int a, int b) {
while (b) {
a = b;
b = a % b;
}
return a;
}
int count_pairs(int x, int l) {
int count = 0;
for (int a = 2; a <= l; a++) {
for (int b = a + 1; b <= l; b++) {
if (gcd(a, b) == x) {
count++;
}
}
} return count;
}
int main() {
int x, l;
cin >> x >> l;
cout << count_pairs(x, l) << endl;
return 0;
}
int right_count(string s) {
int count = 0;
for (int i = 0; i < s.length(); i++) {
for (int j = i + 1; j < s.length(); j++) {
if (s[i] == s[j]) {
count++;
}
}
}
return count;
}
14) Most of the questions are repeating, so who all have next on campus placements please go
through
1. Chocolate distribution
2. Perfume problem
3. Class room arrangement (factorial)
4. Password checker
Sol :
15)
Sol :
17) https://www.codingninjas.com/studio/problem-details/boredom_920547
18) Ek array tha usme kuch subarray element ko sum krke array ke elements se replace Krna tha
taki array increasing order me ho jaye
19)
20)
21)
22) alice is planning to organize a contest with 4 players in each team .there are two types of
player name experienced and fresheres .to make the contest unbiased alice wants to have a
team in such a way that each team must contain atleast 1 experienced and 1 freshers .you
are given N number of experienced and M number of freshers.Your task is determine the
maximum number of team formation possible.NOTE: no member can join more than one
team. Input format:*the first line contain the two separated integer N and M.Ouput
format :print the number that represents the maximum number of team formation possible.
TESTCASE INPUT N=5,M=5 OUPUT is 2
23)
Sol :
Other sol : int main(){
string ans="tshcat",sample="abcdefghstuvwxyzijklmnopqr";
int k=3;
for(int j=0;j<k-1;j++){
for(int i=1;i<k;i++){
if(sample.find(ans[i])<sample.find(ans[i-1])){
swap(ans[i],ans[i-1]);
cout<<ans;
return 0;
}
24)
Sol :
25)
26)
27)
28)
Other sol: int MinSquares(int n) {
if (n == 0) {
return 0;
minCount = min(minCount,Count);
return minCount;
}
int main() {
int n = 13;
return 0;
}
29)
30)
#include <iostream>
#include <vector>
int topper1 = 0;
int topper2 = 0;
int remove = 0;
if (remove > 2)
return remove - 2;
return remove;
}
int main() {
std::cout << "Enter marks of students" << std::endl;
int n;
std::cin >> n;
std::vector<int> arr(n);
return 0;
}
31)
32)