Accenture Previous Year Coding
Questions
Accenture Previous Year Coding Questions
Most Asked Accenture Coding Questions
Arrays & Matrices
1. Sum of Second Smallest Element at Odd Positions and Largest at Even
Positions
○ Problem: Given an array, calculate the sum of the second-smallest
element from odd positions and the largest element from even positions.
○ Example: Input [3, 2, 1, 7, 5, 4], Output: 7
2. Find Product of Two Smallest Numbers in Array Whose Sum is Less Than
Given Sum
○ Problem: Given a sum and an array, find the product of the two smallest
numbers whose sum is less than the given sum.
○ Example: Input sum=9, arr=[5,4,2,3,9,1,7], Output: 2
3. Find Second Largest Number in Array of 1000 Integers
○ Problem: Given an array of 1000 integers, find the second-largest number
(return -1 if none exists).
○ Example: Input num1=3, num2=[2,1,2], Output: 1
4. Find All Unique Pairs of Animal IDs
○ Problem: Given a list of integers representing animal IDs, find all unique
pairs.
○ Example: Input [1, 2, 3], Output: [(1, 2), (1, 3), (2, 3)]
5. Find Maximum Sum of Coins from Consecutive Treasure Chests
○ Problem: Given a list of integers representing coins in treasure chests
(some negative), find the maximum sum from consecutive chests.
○ Example: Input [2, -3, 4, -1, 2, 1, -5, 4], Output: 6
6. Calculate Total Weight and Heaviest Ingredient for a Cake
○ Problem: Given a list of floating-point numbers representing ingredient
weights, calculate the total weight and the heaviest ingredient.
○ Example: Input [1.2, 0.5, 2.3, 1.8], Output: (5.8, 2.3)
7. Find ID of Oldest Book and Average ID of All Books
○ Problem: Given a list of integers representing book IDs, find the oldest
book ID and the average ID (rounded down).
○ Example: Input [1001, 1002, 999, 1003], Output: (999, 1001)
8. Calculate Total Value and Highest Value of Dragon's Treasures
○ Problem: Given a list of integers representing treasure values, calculate
the total value and the highest value.
○ Example: Input [200, 500, 1000, 300], Output: (2000, 1000)
9. Check if a Specific Ingredient ID is Used in a Potion
○ Problem: Given a list of integers representing ingredient IDs and a target
ID, check if the target ID is used in the potion.
○ Example: Input [101, 102, 103, 104], 102, Output: "Yes"
10.Calculate Total Hours and Highest Hour from Clocks
○ Problem: Given a list of integers representing hours on clocks, calculate
the total hours and the highest hour.
○ Example: Input [3, 7, 5, 9], Output: (24, 9)
11.Find the Second Smallest Element in an Array
○ Problem: Find the second smallest element in the given array
12.Sum of Even and Odd Elements in an Array
○ Problem: Calculate sum of even and odd elements separately
13.Reverse the Array and Print Odd and Even Positions
○ Problem: Reverse array and print elements at even and odd positions
14.Sum of Second Largest from Even Positions and Second Smallest from
Odd Positions
○ Problem: Given an array, calculate the sum of the second-largest element
from even positions and the second-smallest from odd positions
15.Find Maximum Value and Index in Array
○ Problem: Given an array, find the maximum value and its index.
○ Example: Input [23, 45, 82, 27, 66, 12, 78, 13, 71, 86], Output: (86, 9)
16.Matrix Division and Sum of Second Largest
○ Problem: Perform matrix division and find the sum of the second-largest
elements in each row
Strings
17.Password Checker
○ Problem: Check if a string is a valid password based on criteria (e.g.,
length, numbers, capitals, no spaces/slashes).
○ Example: Input "aA1_67", Output: 1; "a987 abC012", Output: 0
18.Move Hyphen
○ Problem: Move hyphens in a string to specific positions based on rules
19.Replace Character
○ Problem: Replace specific characters in a string with another character
20.Operation Choices
○ Problem: Perform operations on a string based on user-defined choices
21.Shorten Word with Middle Character Count
○ Problem: Given a word, return the first letter, the count of middle
characters, and the last letter
22.Vowel Permutation
○ Problem: Given a string, print all possible permutations of vowels present
in the string
Number Problems
23.Calculate Difference of Sum of Numbers
○ Problem: Given integers m and n, calculate the difference between the
sum of numbers from 1 to n not divisible by m and the sum of numbers
divisible by m.
○ Example: Input m=6, n=30, Output: 285
24.Count Number of Carry Operations When Adding Two Numbers
○ Problem: Given two numbers, count the number of carry operations when
adding them digit by digit.
○ Example: Input num1=451, num2=349, Output: 2
25.Calculate Total Coins Adam Gives to Charity
○ Problem: Given x, calculate the total coins Adam gives as i^2 from day 1
to x.
○ Example: Input: 2, Output: 5
26.Find Sum of Divisors for Given Integer N
○ Problem: Given an integer N, find the sum of all its divisors.
○ Example: Input: 6, Output: 12
27.Sum of Binary Digits
○ Problem: Convert a number N to binary and return the sum of its binary
digits (number of 1's)
28.Prime Numbers Between 1 and N
○ Problem: Print all prime numbers between 1 and N
29.Check Leap Year
○ Problem: Check if a given year is a leap year
30.Rat Count House
○ Problem: Involves calculating food consumption for rats across houses
31.Difference of Sum
○ Problem: Involves calculating differences between sums based on
divisibility
32.Product Smallest Pair
○ Problem: Likely involves finding the product of the smallest pair in an
array
33.Decimal to N-Base Notation
○ Problem: Convert a decimal number to a given base (N)
34.Number of Carries
○ Problem: Count the number of carry operations when adding two
numbers
35.Max Exponents
○ Problem: Likely involves finding maximum exponents in a number or
expression
36.Calculate Sum of Numbers Divisible by 3 and 5
○ Problem: Calculate the sum of numbers divisible by 3 and 5 within a
range
37.Display Table and Sum of Multiples
○ Problem: Involves displaying a table and summing multiples
38.Print Palindrome Numbers
○ Problem: Print all palindrome numbers within a given range
39.Sum of Distance Between Three Points
○ Problem: Likely involves calculating distances between points
40.Autobiographical Number
○ Problem: Check if a number is autobiographical (each digit indicates its
count in the number)
Most Asked Accenture Coding
Questions
Most Asked Accenture Coding Questions
Array & Number Problems
1. Find the Second Smallest Element in an Array
2. Largest Element in an Array
3. Sum of Numbers Divisible by 3 and 5
4. Difference Between Sum of Square Roots of Even and Odd Numbers
5. Find the Missing Number in an Array
6. Count the Occurrences of a Given Element in an Array
7. Return Sum of Elements Divisible by Input
8. Nearest Smaller Integer
9. Minimum Possible Sum of Any Two Consecutive Integers
10.Geometric Progression
11.Prime Numbers Between 1 and N
12.Sum of Even and Odd Elements in an Array
13.Reverse the Array and Print Odd and Even Positions
14.Maximum Chocolates
String Manipulation
1. Reverse the Number
2. Reverse the String
3. Check if Palindrome (Number & String)
4. Replace 'a' with 'b' and Vice Versa in a String
5. Reverse the Order of Words in a String
6. Return the Indexing of Second String
7. Count of Strings with No Duplicate Characters
8. Return Non-Repetitive Consecutive Characters String
9. Shorten Word with Middle Character Count
10.Vowel Permutation
Miscellaneous
1. Sum of Binary Digits
2. Print Floyd's Triangle
3. Check Leap Year
4. Print Winning Team of a Football Match
2024 Actual Coding questions
2024 Accenture Actual Coding questions
19 Sep Accenture Coding Question
1. Given a 5*5 matrix. Of binary format only having one 1 find minimum number of swap
to have the 1 in the center
2. Given 2 strings having both uppercase and lowercase characters. Irrespective of the
case, determine the lexicographically smaller string return -1 if the first string is smaller
return 1 if the second string is smaller and 0 if both are equal .
3. First Recurring Character in the Given String like (abaccb) answer will be a .
4. Floyd triangle
5. find the first smallcase character present in a string that repeats twice.
17 Sep Accenture Coding Question
1- Left sum and right sum they gave an array and an index we have to find the
left array elements sum o and right array elements sum of the given index and
return the difference
2- Two arrays are given one with craving factor of children and other with number
of icecreams, we have to find maximum number of children satisfied with the ice
cream
11 Sep Accenture Coding Question
q1)int n=5
int arr[] {2,5,6,8,9}
if even index even number add++
if odd index odd numer add++
print add
q2) celebrity problem
0010
0010
0000
0010
-------------------------------
q3)vowels string manipulations
if vowel in a string b/w two consonats remove
---------------------------------------------------------------
q4) temperature sum
739. Daily Temperatures
Example 1:
Input: temperatures = [73,74,75,71,69,72,76,73]
Output: [1,1,4,2,1,1,0,0]
Example 2:
Input: temperatures = [30,40,50,60]
Output: [1,1,1,0]
Example 3:
Input: temperatures = [30,60,90]
Output: [1,1,0]
q5)prime indices:
I/P:
n=7
array: {2,4,5,7,8,9,10}
num=48
find factors of num= 2^4 . 3^1.........
O/P so print sum=4*arr[2]+1*arr[3]........
10 Sep Accenture Coding Question
Today was my Accenture technical + coding round
Coding question
Q1. Check the number of a character occurrence in a string.
Solution link
Q2. Nth term of a special fibonacci series.
Solution Link
9 Sep Accenture Coding Question
1- Write a Python program to read n strings, count their frequencies, and print the string with the
highest frequency. If there is a tie, print the first string that reaches that frequency.
Basically this was a scenario based question where they gave like there is 2 football team which
one wins more times we have to print that team as an output.
Example:
Input: 5
Input: A,B,B,A,A
Output: A
2. Print even number at even index and odd number at odd index
3. Assign cookies (leetcode)
Accenture on-campus drive - 9 Sept 24
Q1 : Given two strings A and B,
If the difference between the count of white space in String A and String B is even return a string
"Even{with the actual difference between the two counts}"
Else return a string "Odd{with the actual difference between the two counts}"
Q2.
Given f(0) = 1, f(1) = 1
Find f(n) where f(n) = f(n-1)*f(n-1) + f(n-2)*f(n-2)
Return answer mod 47.
6 Sept Accenture Coding Question
1- Problem Statement:
You are given a decimal number N. Your task is to
convert it to binary and return the sum of its digits.
Input:
N = 10
Output:2
Explanation:The binary representation of 10 is 1010. The sum of digits is 1+ 0 + 1 + 0 = 2.
2- Write a Python program that reads n-integers from user input, removes any duplicate values, and
then outputs the second largest & second smallest unique integer.
Input:
6
312341
Output:
3
2
6th August On campus
1- Given an array with 'N' elements, you are expected to find the
sum of the values that are present in prime indexes of the array.
Note that the array index starts with 0 i.e. the position (index) on the first array element is 0, the
position of the next array element is 1 and so on.
• Input:
。 arr = [10, 20, 30, 40, 50, 60, 70, 80, 90]
。 N = len(arr)
• Explanation: The array indexes are: [0, 1, 2, 3, 4, 5, 6, 7, 8]. The prime indexes are: 2, 3, 5, 7.
The elements at these indexes are: [30, 40, 60, 80].
The sum of these elements is: 30 +40 +60 +80 = 210.
Output: 210
2- You are given a string S and your task is to find and return the count of permutation formed
by fixing the positions of the vowels present in the string.
Note:
• Ensure the result is non-negative. If there are no consonants then return O.
Input: ABC
A. BC > b
Output: 2
3- Even Odd
Jack has an array A of length N. He wants to label whether
the number in the array is even or odd. Your task is to help
him find and return a string with labels even or odd in
sequence according to which the numbers appear in the
Array.
.
Input Specification:
input1: An integer array A, representing the array of
numbers
input2: A integer N, representing the length of array
Output Specification:
Return a string with labels even or odd in sequence
according to which the numbers appear in the array.
4- Rotate an Array
You are given an array and an integer k, where is a non-negative
integer. Your task is to rotate the array to the right by k steps.
Write a Program that takes an array of integers, the number of
elements in the array, and an integer as input and rotates the
array to the right by k steps.
Example:
n=7
nums = [1,2,3,4,5,6,7)
k=3 rotate(nums, n, k)
#nums after rotation: [5,6,7,1,2,3,4]
4th September Coding Questions
1- You are given a string array S that contains the names of some files along with their versions.
Your task is to find and return an integer value representing the latest version out of all the flies
that are correctly named in the array.
A file is considered correct if it follows the format of the file named as "File_X" (where X
represents the file version number). Return -1 if there are no correct files in the array
Input 1: A string array S, representing the names of the files
Input2: An Integer value representing the size of the array Output:
Return an integer value
2- Character Count
You are given a string S of length N. Your friend wants to know the number of times his favorite letter
C occurs in the string. Your task is to help your friend find and return an integer value representing
the number of times a character occurs in a particular string.
Note: All the characters in the strings are in lowercase.
Input Specification:
input1: A string S
input2: An integer N, representing the length of string
input3: A character C
Output Specification:
Return an integer value representing the number of times a character occurs in a particular string.
Recent Accenture Coding Question
You are given array A, having some dividends further, you are given 3 numbers D, Q and R. A
dividend can be found using a rule that states:
• Dividend = Divisor x Quotient + Remainder
Your task is to find and return an integer value representing the index of the dividend if present
in array.
If dividend not found return -1.
Sum XOR
You are given an array A of length N. Your task is to find and return an 6finteger value
representing the difference between the sum of elements at odd index and XOR of elements at
even index.
Input Specification:
input1: An integer N, representing the length of array
input2: An integer array A
Output Specification:
Return an integer value representing the difference between the sum of elements at odd index
and XOR of elements at even index.
Example 1:
input1 : 6
input2: (10,5,6,3,7,2}
Output: -1