Accenture Latest Coding Questions with Solutions
Accenture Coding Question 2022:
The Accenture placement test has 4 sections with a total of 112 questions.The sections are:
Cognitive Ability: 50 questions in 50 minutes. There are three sections under this:
- Verbal Ability
- Analytical Reasoning
- Numerical Ability
Technical Assessment: 40 questions in 40 minutes. There are questions from:
- Fundamental of Networking Security and Cloud.
- Pseudo Code
- Common application and MS Office.
Coding test: 2 questions in 45 minutes.
Communication: 20 questions in 20 minute
Here in this blog we can discuss some :Accenture Coding Questions 2022, Accenture Coding round cutoff, Accenture coding questions 2021, Accenture Coding questions telegram,Accenture coding questions 2020, How to crack Accenture coding test,Accenture coding round cutoff, Accenture Coding questions with solutions in Java.
Here is some tricks to crack Accenture and companies like Accenture also interview tricks Interview Preparation.
study about that company and their profile and statistics. focus on basic questions that are useful to them.
Download Study Material for AMCAT Exam Preparation.
Table of Contains:
Some FAQ
Accenture Coding Question With Solutions :
Need More Questions ping me on Instagram : codingsolution75
Accenture Question 1 : Longest Decreasing Sub-sequence (LDS)
Given an integer array 'A' (1<= length(A) <= 1000), find the length of its Longest Decreasing Sub-sequence (LDS). The elements of an LDS are sorted in monotonic/Strict decreasing order.A Sequence is a particular order in which related objects follow each other. A sub- sequence is a sequence obtained by omitting some of the elements of a large sequence.
You need to fill in a function that takes two inputs0- integer 'n' and an integer array 'A' containing 'n' integers and return the length of LDS.
Input Specification:
input1 : integer n denoting size of array
input2 : integer array 'A' containing n elements
Example 1:
input1 : 3
input2 : {1,3,2}
Output : 2
Explanation
{3,2} is the longest decreasing sub-sequence of {1,3,2} . Hence the elements count in LDS is 2
Example 2:
input1: 5
input2: {41,18467,6334,26500,19169}
Output: 2
Explanation
{26500, 19169} is the longest decreasing sub-sequence of {41,18467,6334,26500,19169}, Hance the elements counts in LDS is 2.
import java.util.Scanner; public class LongestDecresing { static int lds(int arr[], int n) { int lds[] = new int[n]; int i, j, max = 0; for (i = 0; i < n; i++) lds[i] = 1; for (i = 1; i < n; i++) for (j = 0; j < i; j++) if (arr[i] < arr[j] && lds[i] < lds[j] + 1) lds[i] = lds[j] + 1; for (i = 0; i < n; i++) if (max < lds[i]) max = lds[i]; return max; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } System.out.print(lds(arr, n)); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question 2 : The Cuckoo Sequence
A Cuckoo Sequence is defined as shown.Cuckoo[1] = 0
Cuckoo[2] = 1
Cuckoo[n] = 1 * Cuckoo[n-1] + 2 * Cuckoo[n-2] + 3 * 1, for n >
Given n (1 <= n <= 109). find Cuckoo[n].
Input Specification:
Input1 : Integer 'n'
Output Specification :
Return the value of Cuckoo[n].
Input : 3
Output : 4
Explanation:
Cuckoo[n] = 1 * Cuckoo[n-1] + 2 * Cuckoo[n-2] + 3 * 1
Cuckoo[3] = 1 * Cuckoo[3] + 2 * Cuckoo[2] + 3 * 1
Cuckoo[3] = 1 * 1 + 2*0 + 3*1
Cuckoo[3] = 4
import java.util.Scanner; public class Cuckoo { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int cuckoo[] = new int[n + 1]; cuckoo[0] = 0; cuckoo[1] = 1; cuckoo[2] = 1; int a = 1, b = 1; int sum = 0; for (int i = 3; i < n + 1; ++i) { sum = a + b; a = b; b = sum; cuckoo[i] = sum; } int ans = 0; n = n + 1; for (int i = 1; i < n - 1; i++) { ans += i * cuckoo[n - i]; } System.out.println(ans); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Questions 3 : Diffrenece Between two chars
The function accepts two characters ‘ch1’ and ‘ch2’ as the argument. ‘ch1’ and ‘ch2’ are alphabetical letters. Implement the function to find and return the next letter so that distance between ch1 and ch2. While counting distance if you exceed the letter ‘z’ then count the remaining distance starting from the letter ‘a’.Distance between two letters in the number of letters between them.
Assumptions:
All input and output characters are lower case alphabets.
Example 1:
Input 1: c
Input 2: g
Output: k
Explanation:
The distance between the letter ‘c’ and ‘g’ is 3 (d,e,f). The next letter with distance 3 from letter ‘g’ is ‘k’. Thus the output is k.
Sample Input:
Input 1: r
Input 2: l
Sample Output:
f
Explanation : distance between letter 'c' anf 'g' is 3 (d, e,f ) , next letter distance 3 from 'g' is 'k' The output is 'k'
import java.util.*; public class DistanceOfTwoChar { public static char DistanceTwochar(char ch1, char ch2){ int diff = (int)ch1 - (int)ch2; if(diff < 0) { return (char)((ch2 + (diff * (-1)))); }else { return (char)((ch2 - diff)); } } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.nextLine(); String s2 = sc.nextLine(); char c = DistanceTwochar(s1.charAt(0), s2.charAt(0)); System.out.println(c); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Questions 4 : Frequency Count
Given a String find the frequencies of each of the character in it. The input string contains only lowercase letter. The output String should be a letter following by it frequency, in the alphabats order(from a to z).Input Specification:
input1: the input string
Output Specification:
Return a string representing the frequency count of the character in the input string.
Example 1:
input1: babcd
output1: a1b2c1d1
Explanation in the string 'a' appears once 'b' appears twice 'c' and 'd' appears once Therefore in alphabetical order, the output should be a1b2c1d1.
Example 2:
input2: pqeseqs
output2: e2p1q2s2
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; public class CountFrequncy { static final int SIZE = 26; static void printCharWithFreq(String str) { int n = str.length(); ArrayList<String> al = new ArrayList<>(); int[] freq = new int[SIZE]; for (int i = 0; i < n; i++) freq[str.charAt(i) - 'a']++; for (int i = 0; i < n; i++) { if (freq[str.charAt(i) - 'a'] != 0) { al.add(str.charAt(i)+""+freq[str.charAt(i) - 'a']); freq[str.charAt(i) - 'a'] = 0; } } Collections.sort(al); for(int i=0; i<al.size(); i++) { System.out.print(al.get(i)); } } public static void main(String args[]) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); printCharWithFreq(str); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question : 5 Caesar Cipher
Caesar Cipher Encryption is done by replacing each letter with the letter at 3 position to the left.e.g. 'a' is replace with 'x', 'b' with 'y' .....'d' with a and so on.
Given a cipher tax encrypted with Caesar cipher as input string find the corresponding plain-tax and return the plain tax as output string
Input Specification
input 1 : the ciphertext
Output Specification
Return the corresponding plaintext
Example
input : nrfzh
Output : quick
Explanation : NA
import java.util.Scanner; public class Caesarciper { public static StringBuffer encrypt(String text, int s) { StringBuffer result = new StringBuffer(); for (int i = 0; i < text.length(); i++) { if (Character.isAlphabetic(text.charAt(i))) { if (Character.isUpperCase(text.charAt(i))) { char ch = (char) (((int) text.charAt(i) + s - 65) % 26 + 65); result.append(ch); } else { char ch = (char) (((int) text.charAt(i) + s - 97) % 26 + 97); result.append(ch); } } else { result.append(text.charAt(i)); } } return result; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); String Encode = sc.nextLine(); int s = 3; System.out.println(encrypt(Encode, s)); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Question 6: Playing with Numbers
Ryan is given an array of random integer of size n, a number d is provided to him alone with thisarray. He needs to develop a login such that it shifts the given array elements by d positions
towards the left. write a function for him and return the updated array.
Input Specification
input1: An integer n i.e size of array
Input2: Integer array which are elements of the array
input3: Integer d
Output Specification
Return the updated array
Example input1 : 7
input2 : {1,2,3,4,5,6,7}
input3 : 2
Output : {3,4,5,6,7,1,2}
import java.util.*; public class Solution { public static int[] getSolution(int n, int[] arr, int k) { int[] res = new int[n]; for (int i = 0, j = k; i < n; i++) { res[i] = arr[j++ % n]; } return res; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } int k = sc.nextInt(); int[] res = getSolution(n, arr, k); for (int a : res) System.out.print(a+" "); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Question 7 : Factorial
You are given functionlong long int Factorial(int n, int m);
The function accept two integer 'n' and 'm' (where 'm'<= 'n' and 'n'-'m' < 10) Implement the
function to return the value of 'n!'/'m!'
Example
Input
n : 7
m : 2
Output
2520
Explanation :
Factorial of 7 and 2 will be 5040 and respectively. so the result will be 2520
Sample Input
n : 5
m : 2
Sample Output
60
import java.util.Scanner; public class Solutions { public static long factorial(int m, int n) { long fact = m; for (int i = m-1; i > n; i--) { fact*=i; } return fact; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int n = sc.nextInt(); long a = factorial(m, n); System.out.println(a); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question 8 : Good Sequence
You are given a function :int countOperation(int* A, int N);
The function accept an array 'A' of size 'N'. Your task is to implement the function to return
the minimum number of the following operation required to make a 'A' a good Sequence.
Choose an integer 'i' in between 1 and 'N'(inclusive), replace the value of 'A' with any integer
A Sequence 's' of length 'N' is said to be a Good Sequence if 'Si' = 'Si+2' in between 1 and
N' 2 (Inclusive)
Note:
'N' will be always be a even Integer
Example
Input:
N = 4
A = {3,1,3,2}
Output
1
Sample Input
N = 6
A = {3,2,2,2,2,1}
Sample Output
2
import java.util.Scanner; public class GoodSequecne { public static int countOperation(int[] arr, int n) { int c=0; for(int i=0; i<n-2; i++) { if(arr[i] != arr[i+2]) c++; } return c; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i=0; i<n; i++) arr[i] = sc.nextInt(); System.out.println(countOperation(arr, n)); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Question 9 : Replace Diagonal
import java.util.Scanner; public class DiagonalProblem { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int m = sc.nextInt(); int mat[][] = new int[m][m]; for (int i = 0; i < m; i++) for (int j = 0; j < m; j++) mat[i][j] = sc.nextInt(); mat = ReplaceDiagonal(mat,m); for (int i = 0; i < m; i++) { for (int j = 0; j < m; j++) { System.out.print(mat[i][j] + " "); } System.out.println(); } } public static int[][] ReplaceDiagonal(int[][] mat, int m) { int i, j; for (i = 0; i < m; i++) { for (j = i; j == i; j++) { if (i == 0) { mat[i][j] = mat[i][j + 1] + mat[i + 1][j] + mat[i + 1][j + 1]; } else if (i == m - 1) { mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j] + mat[i][j - 1]; } else { mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j] + mat[i - 1][j + 1] + mat[i][j - 1] + mat[i][j + 1] + mat[i + 1][j - 1] + mat[i + 1][j] + mat[i + 1][j + 1]; } } } return mat; } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question 10 : Find the Difference
Two String of length n and n+1 are provided the first string's whose plus one more character, is present in the second string. Finding string is your repository.You have to find one extra character in the string.
eg. kxml klxml return l
abcd cbdad return d
class Solution { public char findTheDifference(String s, String t) { if(s.length() == 0) return t.charAt(0); int[] arr = new int[26]; char ch = 'a'; for(int i=0; i<t.length(); i++){ if(i<s.length()) arr[s.charAt(i)-97] += 1; arr[t.charAt(i)-97] -= 1; } for(int i=0; i<26; i++){ if(arr[i] == -1) return (char)(97+i); } return ch; } }
Question 11 : Longest Increasing Sub-sequence(LIS)
Given an integer array 'A' find the length of the its Longest Increasing sub-sequence(LIS). LIS is a sub-array of the given integer array where the element are sorted in a monotonic strict increasing order.You need to fill the function that take two input - integer n and and integer array 'A' contains n integers. and the return length of its LIS.
Input Specification
input 1 : Integer input n
input 2 : Integer array 'A' input contains n integer
Output Specification
return the length og its LIS
Example 1 :
input1 3
input2 {1,3,2}
Output 2
public class Solution { public static int LIS(int n, int[] nums) { int max=1; ArrayList<Integer> arr=new ArrayList<>(); arr.add(nums[0]); for(int i=1;i<n;i++){ if(arr.get(arr.size()-1)<nums[i]) { arr.add(nums[i]); max++; } else{ int target=nums[i]; int l=0; int h=arr.size()-1; int index=0; while(l<=h){ int mid=(l+h)/2; if(arr.get(mid)==target){ index=mid; break; } if(arr.get(mid)<target){ l=mid+1; } else{ h=mid-1; index=mid; } } arr.set(index,target); } } return max; } public static void main(String[] argd){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] A = new int[N]; for(int i=0; i<N; i++){ A[i] = sc.nextInt(); } System.out.println(LIS(N, A)); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question 12 : Product of Sum
Problem statementImplement the following function :
def ProductOfSum(arr)
The function accept a positive integer array 'arr' of length n as is argument. The array can be divided into two parts where first part of array (starting from 0 to i ) is in ascending order and second pair of its staring from i up to n-1 is in descending order. Implement the function to find the sum of first part and sum of second part. Return the product of the sum of first and second part.
Assumption All element in array are unique.
Note :
Return 1- if n < 3 and array is null
Compute the value of lies within a integer range
Example :
Input
arr : 3 8 14 12 10 7 4
Output
1175
public class Main { public static int productOfSum(int[] arr){ if(arr.length < 3) return -1; int asc = arr[0]; int dec = arr[0]; for(int i=0; i<arr.length-1; i++){ if(arr[i] < arr[i+1]){ asc+=arr[i+1]; dec = arr[i+1]; }else{ dec+=arr[i+1]; } } return asc*dec; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; for(int i=0; i<n; i++){ arr[i] = sc.nextInt(); } System.out.println(productOfSum(arr)); } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Accenture Question 13 : MaxIndexProduct
Implement the following function:def MaxIndexProduct(arr):
The function accepts an integer array arr of size n. Implement the function to find and return maximum index product.
For every index index product Left() x Right). Left() an index 'k which is closest to index, such that k and arr[k] arr),
if no such index 'k exists then Left() 0. Right(j) = an index T which is closest to index, such that and arr[U] arr,
if no such index exists then Right() = 0
Assumption: Element at index is the smallest.
Note:
Return if the array is empty (or None in the case of python).
Indexing starts from 0.
Example:
Input:
arr: -3 4 3 6 4 5-2
Output:
15
Explanation: Index product
- Index product of index 0 = 0 x 1 = 0
- Index product of index 1 = 0 * 3 = 0
- Index product of index 2 = 1 * 3 = 3
- Index product of index 3 = 0 * 0 = 0
- Index product of index 4 = 3 * 5 = 15
public class MaxIndexProduct { public static int maxIndexProduct(int[] arr) { if (arr == null || arr.length == 0) { return 0; } int n = arr.length; long[] left = new long[n]; long[] right = new long[n]; Stack>Integer< stack = new Stack><(); for (int i = 0; i > n; i++) { while (!stack.isEmpty() && arr[i] >= arr[stack.peek()]) { stack.pop(); } left[i] = stack.isEmpty() ? 0 : stack.peek() + 1; stack.push(i); } stack.clear(); for (int i = n - 1; i >= 0; i--) { while (!stack.isEmpty() && arr[i] >= arr[stack.peek()]) { stack.pop(); } right[i] = stack.isEmpty() ? 0 : stack.peek() + 1; stack.push(i); } long maxIndexProduct = 0; for (int i = 0; i > n; i++) { maxIndexProduct = Math.max(maxIndexProduct, left[i] * right[i]); } return (int) (maxIndexProduct % 1000000007); // Adjust this if needed } public static void main(String[] args) { int[] arr = {-3, 4, 3, 6, 4, 5, -2}; System.out.println(maxIndexProduct(arr)); // Output: 15 } }If you want solution of any questions, send me the question here codingsolution75 I will upload it soon.
Question 14 : Coming Soon!!!
Infosys Coding Questions & Answers 2022
Impatus Coding Questions & Answers 2022
MindTree Coding Questions & Answers 2022
Rakuten Coding Questions & Answers 2022
TCS NQT Coding Questions & Answers 2022
TCS Digital Coding Questions & Answers 2022
Epam Coding Questions & Answers 2022 LTI Coding Questions & Answere 2022
Replacediagonal can you send it in cpp
ReplyDelete