This comprehensive guide covers Accenture's coding test preparation, including the complete syllabus, test pattern, marking scheme, and detailed coding questions with solutions in Python, Java, and C. The guide is designed for candidates preparing for Associate Software Engineer (ASE) and Advanced App Engineer positions at Accenture.
The Accenture coding test covers the following topics:
Accenture's coding assessment consists of questions that vary across difficulty levels and topic coverage.
These evaluate your knowledge of basic programming constructs like loops, conditionals, and basic functions. You may be evaluated on converting numbers between different number bases, or solving logic and math questions.
Questions in this category often require knowledge of the fundamentals of data structures (arrays, strings, linked lists) and algorithms (sorting, searching, or recursion). You may be challenged with dynamic programming, backtracking, or a more complex problem-solving format.
Advanced questions may focus on complex algorithms, system design, or object-oriented programming (OOP) concepts. These are less common but may appear for advanced roles or as tie-breakers.
| Attribute | Details |
|---|---|
| Duration | 45 minutes |
| Number of Questions | 2 coding problems |
| Difficulty Level | Easy - Medium |
| Languages Allowed | C, C++, Java, Python |
Commonly Allowed Languages:
For certain positions, or for some coding rounds, you may be able to use a different language, such as C# or JavaScript, although the main language options are C, C++, Java, and Python.
Key Points:
The coding round typically consists of two questions to be solved in 45 minutes. Each question is evaluated based on how many test cases your solution passes. To clear the round, you generally need to:
No, the marking is not negative. It is recommended that you answer both questions and aim to pass as many test cases as possible.
You should aim to pass all test cases for at least one problem and as many as possible for the other. This demonstrates both accuracy and problem-solving ability.
Problem Statement:
The royal baker needs to prepare a special cake. Each ingredient has a specific weight. The baker wants to know the total weight of the ingredients and the heaviest ingredient used.
Input Format:
The weights of the ingredients are given in a list of floating-point numbers.
Output Format:
Two floating-point numbers indicate the weight of the heaviest ingredient and the total weight.
Example:
Python Solution:
def cake_ingredients(weights):
if not weights:
return 0, 0
total_weight = sum(weights)
heaviest = max(weights)
return total_weight, heaviest
print(cake_ingredients([1.2, 0.5, 2.3, 1.8]))
Java Solution:
public class Main {
public static double[] cakeIngredients(double[] weights) {
if (weights.length == 0)
return new double[]{0, 0};
double totalWeight = 0;
double heaviest = weights[0];
for (double weight : weights) {
totalWeight += weight;
if (weight > heaviest)
heaviest = weight;
}
return new double[]{totalWeight, heaviest};
}
public static void main(String[] args) {
double[] results = cakeIngredients(new double[]{1.2, 0.5, 2.3, 1.8});
System.out.println("Total Weight: " + results[0] + ", Heaviest Ingredient: " + results[1]);
}
}
C Solution:
#include <stdio.h>
void cakeIngredients(double weights[], int size, double* totalWeight, double* heaviest) {
if (size == 0) {
*totalWeight = 0;
*heaviest = 0;
return;
}
*totalWeight = 0;
*heaviest = weights[0];
for (int i = 0; i < size; i++) {
*totalWeight += weights[i];
if (weights[i] > *heaviest)
*heaviest = weights[i];
}
}
int main() {
double weights[] = {1.2, 0.5, 2.3, 1.8};
double totalWeight, heaviest;
cakeIngredients(weights, 4, &totalWeight, &heaviest);
printf("Total Weight: %.2f, Heaviest Ingredient: %.2f\n", totalWeight, heaviest);
return 0;
}
Problem Statement:
Inside a magical garden, flowers bloom in a number of colors, and each one has a particular point value. You will find the total points based on what the gardener has picked.
Input Format:
A list of integers representing the points for each flower.
Output Format:
An integer representing the total points earned from the flowers.
Example:
Python Solution:
def total_flower_points(flowers):
total_points = 0
for points in flowers:
total_points += points
return total_points
if __name__ == "__main__":
print(total_flower_points([5, 3, 8, 2]))
Java Solution:
public class Main {
public static int totalFlowerPoints(int[] flowers) {
int totalPoints = 0;
for (int points : flowers) {
totalPoints += points;
}
return totalPoints;
}
public static void main(String[] args) {
System.out.println(totalFlowerPoints(new int[]{5, 3, 8, 2}));
}
}
C Solution:
#include <stdio.h>
int totalFlowerPoints(int flowers[], int size) {
int totalPoints = 0;
for (int i = 0; i < size; i++) {
totalPoints += flowers[i];
}
return totalPoints;
}
int main() {
int flowers[] = {5, 3, 8, 2};
printf("%d\n", totalFlowerPoints(flowers, 4));
return 0;
}
Problem Statement:
A wizard brews a secret potion with different magical ingredients, each having a unique integer ID. Your job is to determine if a particular ID was used in the potion.
Input Format:
A list of integers representing the ingredient IDs and an integer representing the ID to check.
Output Format:
A string indicating whether the ingredient ID is used ("Yes" or "No").
Example:
Python Solution:
def check_ingredient(ingredients, id_to_check):
return "Yes" if id_to_check in ingredients else "No"
print(check_ingredient([101, 102, 103, 104], 102))
Java Solution:
import java.util.Arrays;
public class Main {
public static String checkIngredient(int[] ingredients, int idToCheck) {
return Arrays.stream(ingredients).anyMatch(id -> id == idToCheck) ? "Yes" : "No";
}
public static void main(String[] args) {
System.out.println(checkIngredient(new int[]{101, 102, 103, 104}, 102));
}
}
C Solution:
#include <stdio.h>
const char* checkIngredient(int ingredients[], int size, int idToCheck) {
for (int i = 0; i < size; i++) {
if (ingredients[i] == idToCheck) {
return "Yes";
}
}
return "No";
}
int main() {
int ingredients[] = {101, 102, 103, 104};
printf("%s\n", checkIngredient(ingredients, 4, 102));
return 0;
}
Problem Statement:
A timekeeper has a collection of clocks, each representing a specific hour. Your task is to calculate the total hours represented by the clocks and find the clock showing the highest hour.
Input Format:
A list of integers representing the hours of the clocks.
Output Format:
Two integers: the total hours and the highest hour.
Example:
Python Solution:
def timekeeper_clocks(clocks):
total_hours = sum(clocks)
highest_hour = max(clocks)
return total_hours, highest_hour
print(timekeeper_clocks([3, 7, 5, 9]))
Java Solution:
public class Main {
public static int[] timekeeperClocks(int[] clocks) {
int totalHours = 0;
int highestHour = clocks[0];
for (int hour : clocks) {
totalHours += hour;
if (hour > highestHour)
highestHour = hour;
}
return new int[]{totalHours, highestHour};
}
public static void main(String[] args) {
int[] result = timekeeperClocks(new int[]{3, 7, 5, 9});
System.out.println("(" + result[0] + ", " + result[1] + ")");
}
}
C Solution:
#include <stdio.h>
void timekeeperClocks(int clocks[], int size, int* totalHours, int* highestHour) {
*totalHours = 0;
*highestHour = clocks[0];
for (int i = 0; i < size; i++) {
*totalHours += clocks[i];
if (clocks[i] > *highestHour)
*highestHour = clocks[i];
}
}
int main() {
int clocks[] = {3, 7, 5, 9};
int totalHours, highestHour;
timekeeperClocks(clocks, 4, &totalHours, &highestHour);
printf("Total Hours: %d, Highest Hour: %d\n", totalHours, highestHour);
return 0;
}
This set of questions is intended for testing your skills with arrays, strings, and basic algorithms that require logic and problem-solving.
Problem Statement:
In a race, each participant's finish time is recorded. You need to find out who finished first and how long it took them. Additionally, you need to find the average finish time of all participants.
Input Format:
A list of floating-point numbers representing finish times.
Output Format:
Two floating-point numbers: the first-place time and the average time.
Example:
Python Solution:
def race_results(times):
if not times:
return None, 0
first_place_time = min(times)
average_time = sum(times) / len(times)
return first_place_time, average_time
print(race_results([12.5, 10.0, 11.2, 13.3]))
Java Solution:
public class Main {
public static double[] raceResults(double[] times) {
if (times.length == 0)
return new double[]{-1, 0};
double firstPlaceTime = times[0];
double totalTime = 0;
for (double time : times) {
if (time < firstPlaceTime)
firstPlaceTime = time;
totalTime += time;
}
double averageTime = totalTime / times.length;
return new double[]{firstPlaceTime, averageTime};
}
public static void main(String[] args) {
double[] results = raceResults(new double[]{12.5, 10.0, 11.2, 13.3});
System.out.println("First Place Time: " + results[0] + ", Average Time: " + results[1]);
}
}
C Solution:
#include <stdio.h>
void raceResults(double times[], int size, double* firstPlace, double* average) {
if (size == 0) {
*firstPlace = -1;
*average = 0;
return;
}
*firstPlace = times[0];
double totalTime = 0;
for (int i = 0; i < size; i++) {
if (times[i] < *firstPlace)
*firstPlace = times[i];
totalTime += times[i];
}
*average = totalTime / size;
}
int main() {
double times[] = {12.5, 10.0, 11.2, 13.3};
double firstPlace, average;
raceResults(times, 4, &firstPlace, &average);
printf("First Place Time: %.2f, Average Time: %.2f\n", firstPlace, average);
return 0;
}
Problem Statement:
A time traveller collects artifacts from different years. Each artifact has a year associated with it. Your task is to find the range of years from the earliest to the latest artifact collected.
Input Format:
A list of integers representing the years.
Output Format:
An integer representing the range of years (latest year - earliest year).
Example:
Python Solution:
def year_range(artifacts):
return max(artifacts) - min(artifacts)
print(year_range([1995, 2001, 1985, 2010]))
Java Solution:
public class Main {
public static int yearRange(int[] artifacts) {
int minYear = artifacts[0];
int maxYear = artifacts[0];
for (int year : artifacts) {
if (year < minYear)
minYear = year;
if (year > maxYear)
maxYear = year;
}
return maxYear - minYear;
}
public static void main(String[] args) {
System.out.println(yearRange(new int[]{1995, 2001, 1985, 2010}));
}
}
C Solution:
#include <stdio.h>
int yearRange(int artifacts[], int size) {
int minYear = artifacts[0];
int maxYear = artifacts[0];
for (int i = 1; i < size; i++) {
if (artifacts[i] < minYear)
minYear = artifacts[i];
if (artifacts[i] > maxYear)
maxYear = artifacts[i];
}
return maxYear - minYear;
}
int main() {
int artifacts[] = {1995, 2001, 1985, 2010};
printf("%d\n", yearRange(artifacts, 4));
return 0;
}
Problem Statement:
In a mysterious library, each book has a unique ID, and some books are quite old. Your task is to find the ID of the oldest book and the average ID of all the books.
Input Format:
A list of integers as series I.D.s for each book.
Output Format:
Two integers: the ID of the oldest book and the average ID (rounded down).
Example:
Python Solution:
def book_info(books):
oldest = min(books)
average = sum(books) // len(books)
return oldest, average
print(book_info([1001, 1002, 999, 1003]))
Java Solution:
public class Main {
public static int[] bookInfo(int[] books) {
int oldest = books[0];
int total = 0;
for (int id : books) {
if (id < oldest)
oldest = id;
total += id;
}
int average = total / books.length;
return new int[]{oldest, average};
}
public static void main(String[] args) {
int[] result = bookInfo(new int[]{1001, 1002, 999, 1003});
System.out.println("(" + result[0] + ", " + result[1] + ")");
}
}
C Solution:
#include <stdio.h>
void bookInfo(int books[], int size, int* oldest, int* average) {
*oldest = books[0];
int total = 0;
for (int i = 0; i < size; i++) {
if (books[i] < *oldest)
*oldest = books[i];
total += books[i];
}
*average = total / size;
}
int main() {
int books[] = {1001, 1002, 999, 1003};
int oldest, average;
bookInfo(books, 4, &oldest, &average);
printf("Oldest ID: %d, Average ID: %d\n", oldest, average);
return 0;
}
Problem Statement:
A dragon hoards treasures in different forms, each with a specific value. Your task is to calculate the total value of the treasures and find the highest value among them.
Input Format:
A list of integers representing the values of the treasures.
Output Format:
Two integers: the total value and the highest value.
Example:
Python Solution:
def dragon_hoard(treasures):
total_value = sum(treasures)
highest_value = max(treasures)
return total_value, highest_value
print(dragon_hoard([200, 500, 1000, 300]))
Java Solution:
public class Main {
public static int[] dragonHoard(int[] treasures) {
int totalValue = 0;
int highestValue = treasures[0];
for (int value : treasures) {
totalValue += value;
if (value > highestValue)
highestValue = value;
}
return new int[]{totalValue, highestValue};
}
public static void main(String[] args) {
int[] result = dragonHoard(new int[]{200, 500, 1000, 300});
System.out.println("(" + result[0] + ", " + result[1] + ")");
}
}
C Solution:
#include <stdio.h>
void dragonHoard(int treasures[], int size, int* totalValue, int* highestValue) {
*totalValue = 0;
*highestValue = treasures[0];
for (int i = 0; i < size; i++) {
*totalValue += treasures[i];
if (treasures[i] > *highestValue)
*highestValue = treasures[i];
}
}
int main() {
int treasures[] = {200, 500, 1000, 300};
int totalValue, highestValue;
dragonHoard(treasures, 4, &totalValue, &highestValue);
printf("Total Value: %d, Highest Value: %d\n", totalValue, highestValue);
return 0;
}
These challenges are substantially more complex, encompassing a selection of combinations, dynamic programming, or sequence analysis challenges.
Problem Statement:
In a magical forest, there is an animal, and each animal is identified with a unique identifier (ID). Few animals have decided to pair based on their ID. Your task is to find all the unique pairs of animal IDs possible.
Input Format:
A list of integers, which represent animal ids.
Output Format:
A row of unique pairs of animal IDs.
Example:
Python Solution:
def unique_pairs(animal_ids):
pairs = []
for i in range(len(animal_ids)):
for j in range(i + 1, len(animal_ids)):
pairs.append((animal_ids[i], animal_ids[j]))
return pairs
print(unique_pairs([1, 2, 3]))
Java Solution:
import java.util.ArrayList;
import java.util.List;
public class Main {
public static List<int[]> uniquePairs(int[] animalIds) {
List<int[]> pairs = new ArrayList<>();
for (int i = 0; i < animalIds.length; i++) {
for (int j = i + 1; j < animalIds.length; j++) {
pairs.add(new int[]{animalIds[i], animalIds[j]});
}
}
return pairs;
}
public static void main(String[] args) {
List<int[]> result = uniquePairs(new int[]{1, 2, 3});
for (int[] pair : result) {
System.out.println("Pair: " + pair[0] + ", " + pair[1]);
}
}
}
C Solution:
#include <stdio.h>
void uniquePairs(int animalIds[], int size) {
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
printf("Pair: %d, %d\n", animalIds[i], animalIds[j]);
}
}
}
int main() {
int animalIds[] = {1, 2, 3};
uniquePairs(animalIds, 3);
return 0;
}
Problem Statement:
In a village, there are treasure chests at different locations. Each chest has some number of coins, and some treasure chests are cursed. Cursed chests give negative coins, in contrast to ordinary ones. The goal is to figure out the most profit you can make by taking a consecutive series of treasure chests.
Input Format:
A list of integers representing the coins in each chest.
Output Format:
An integer representing the maximum sum of coins from consecutive chests.
Example:
Python Solution:
def max_treasure(chests):
max_sum = current_sum = 0
for coins in chests:
current_sum += coins
if current_sum < 0:
current_sum = 0
max_sum = max(max_sum, current_sum)
return max_sum
print(max_treasure([2, -3, 4, -1, 2, 1, -5, 4]))
Java Solution:
public class Main {
public static int maxTreasure(int[] chests) {
int maxSum = 0, currentSum = 0;
for (int coins : chests) {
currentSum += coins;
if (currentSum < 0) currentSum = 0;
maxSum = Math.max(maxSum, currentSum);
}
return maxSum;
}
public static void main(String[] args) {
System.out.println(maxTreasure(new int[]{2, -3, 4, -1, 2, 1, -5, 4}));
}
}
C Solution:
#include <stdio.h>
int maxTreasure(int chests[], int size) {
int maxSum = 0, currentSum = 0;
for (int i = 0; i < size; i++) {
currentSum += chests[i];
if (currentSum < 0) currentSum = 0;
if (currentSum > maxSum) maxSum = currentSum;
}
return maxSum;
}
int main() {
int chests[] = {2, -3, 4, -1, 2, 1, -5, 4};
printf("%d\n", maxTreasure(chests, 8));
return 0;
}
Problem Statement:
A "weird number" is defined as a number that is not divisible by a given integer K, but the sum of its digits is divisible by K. Your task is to find the first weird number in the array. If none exists, return -1.
Input Format:
Output Format:
The first weird number, or -1 in the absence of any.
Example:
Python Solution:
def weird_number(arr, k):
for num in arr:
if num % k != 0 and sum(int(d) for d in str(num)) % k == 0:
return num
return -1
print(weird_number([12, 34, 56, 78], 3))
Java Solution:
public class Main {
public static int weirdNumber(int[] arr, int k) {
for (int num : arr) {
int sumDigits = 0, temp = num;
while (temp > 0) {
sumDigits += temp % 10;
temp /= 10;
}
if (num % k != 0 && sumDigits % k == 0)
return num;
}
return -1;
}
public static void main(String[] args) {
int[] arr = {12, 34, 56, 78};
System.out.println(weirdNumber(arr, 3));
}
}
C Solution:
#include <stdio.h>
int sumDigits(int num) {
int sum = 0;
while (num > 0) {
sum += num % 10;
num /= 10;
}
return sum;
}
int weirdNumber(int arr[], int size, int k) {
for (int i = 0; i < size; i++) {
if (arr[i] % k != 0 && sumDigits(arr[i]) % k == 0)
return arr[i];
}
return -1;
}
int main() {
int arr[] = {12, 34, 56, 78};
printf("%d\n", weirdNumber(arr, 4, 3));
return 0;
}
Problem Statement:
Given an array of integers, you need to find the longest length of a subsequence such that the sum of that subsequence is divisible by a number K.
Input Format:
Output Format:
The maximum length of a subsequence whose sum is evenly divisible by K. Returns 0 if there are no such subsequences.
Example:
Python Solution:
def longest_subseq_divisible(arr, k):
n = len(arr)
dp = [0] * k
for num in arr:
temp = dp[:]
for r in range(k):
new_rem = (r + num) % k
temp[new_rem] = max(temp[new_rem], dp[r] + 1)
temp[num % k] = max(temp[num % k], 1)
dp = temp
return dp[0]
print(longest_subseq_divisible([1, 2, 3, 4, 5], 3))
Java Solution:
public class Main {
public static int longestSubseqDivisible(int[] arr, int k) {
int[] dp = new int[k];
for (int num : arr) {
int[] temp = dp.clone();
for (int r = 0; r < k; r++) {
int newRem = (r + num) % k;
temp[newRem] = Math.max(temp[newRem], dp[r] + 1);
}
temp[num % k] = Math.max(temp[num % k], 1);
dp = temp;
}
return dp[0];
}
public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5};
System.out.println(longestSubseqDivisible(arr, 3));
}
}
C Solution:
#include <stdio.h>
int max(int a, int b) {
return (a > b) ? a : b;
}
int longestSubseqDivisible(int arr[], int n, int k) {
int dp[k];
for (int i = 0; i < k; i++) dp[i] = 0;
for (int i = 0; i < n; i++) {
int temp[k];
for (int j = 0; j < k; j++) temp[j] = dp[j];
for (int r = 0; r < k; r++) {
int newRem = (r + arr[i]) % k;
temp[newRem] = max(temp[newRem], dp[r] + 1);
}
temp[arr[i] % k] = max(temp[arr[i] % k], 1);
for (int j = 0; j < k; j++) dp[j] = temp[j];
}
return dp[0];
}
int main() {
int arr[] = {1, 2, 3, 4, 5};
printf("%d\n", longestSubseqDivisible(arr, 5, 3));
return 0;
}
A successful action in Accenture's coding assessment isn't simply memorising the answers. It is built around solid programming fundamentals, through solid reasoning/problem solving, and through practice. By getting familiar with the variety of questions, from easy to challenging, and strengthening your knowledge of data structures, algorithms, and coding techniques, you set yourself up to perform confidently, even under time pressure.
By implementing these strategies and practicing systematically, you will not only clear the coding round but also be a self-assured and able candidate for your dream role at Accenture.
Pseudo-code is a simple way to describe an algorithm using the structure of programming languages without worrying about syntax. It helps assess your logical thinking and problem-solving skills.
Accenture ASE coding questions usually focus on programming basics and may include topics related to automation and testing, along with general coding challenges.
Although Accenture does introduce new questions, you can expect to see the same concept or a variation of previous years' questions. Practicing past questions is useful, but rather than memorize solutions, focus on concepts instead.
The difficulty level is generally moderate to high. Most candidates can expect one question of medium difficulty and one that may be more challenging. Strong fundamentals and consistent practice are key to handling both.
The test typically consists of two coding questions to be solved in 45 minutes. Python, Java, C, and C++ are among the many programming languages available to you. The assessment is non-adaptive, and you must write code from scratch.
The Cognitive Assessment evaluates your aptitude, logical reasoning, and problem-solving abilities. It is usually a separate section from the coding round and must be cleared to advance in the hiring process.
The structure and question types are generally similar for both on-campus and off-campus placements. However, the interview process or platform used may vary slightly.
Most questions focus on core programming concepts, arrays, strings, and basic data structures. However, for advanced roles, you may encounter questions on algorithms, OOP, or system design.
Your code is automatically tested against sample and hidden test cases. You need to pass all test cases for at least one question and as many as possible for the other to maximize your chances of selection.
Manage your time wisely. If you're stuck on a question, move on to the next question and come back to it if there's time. You should plan to complete one question and partly complete a second question.
No, outside help or resources cannot be used. Cheating and/or plagiarism would result in disqualification.
Successful candidates are typically invited to further technical and HR interviews, where problem-solving skills, technical knowledge, and communication abilities are assessed.