Accenture Hack Diva Demo Round Coding Question 2026 (With Solutions)

Accenture Hack Diva Demo Round Coding Question 2026 | Accenture Hack Diva Demo Round Coding Question & Answers | Accenture Hack Diva Demo Round Coding Question With Solutions

Accenture Hack Diva Demo Round Coding Question 2026 : Aspirants who pass in the Online Test will qualify for the coding test process. The coding test will be conducted for the process to check the candidate’s capability. The coding questions will be asked in any language. In the below section, we have provided the Java, C, C++, and Python Coding Questions with Solutions. With the clear Explanation, we have provided all the details here. Solve the Frequently Asked coding test Questions to help with your study.

Before entering the coding test, aspirants can start their preparation by downloading or viewing the practice questions. Here we have provided the study material for the coding test. So, aspirants who are going to attend this hiring process kindly check out the Accenture Hack Diva Demo Round Coding Questions & Answers before attending the process. More details like Accenture Hack Diva Demo Round Model Coding Questions For Freshers, etc. available on its website

Accenture Hack Diva Demo Round Coding Exam Solved Questions

It is very important for all the contenders to before good before the Test. We have provided the sample Accenture Hack Diva Demo Round Coding Questions & Answers for your preparation process. With the help of this preparation good on the coding test & score good marks. If you qualify in this round only you may continue to attend the selection process, so read the article properly to get detailed information about the Accenture Hack Diva Demo Round Previous Coding Questions

Accenture Hack Diva Demo Round Coding Question

Q) Write a program to calculate and return the sum of absolute difference between the adjacent number in an array of positive integers from the position entered by the user.

Note : You are expected to write code in the findTotalSum function only which receive three positional arguments:

1st : number of elements in the array
2nd : array
3rd : position from where the sum is to be calculated

Example

Input
input 1 : 7
input 2 : 11 22 12 24 13 26 14
input 3 : 5

Output
25

Explanation

The first parameter 7 is the size of the array. Next is an array of integers and input 5 is the position from where you have to calculate the Total Sum. The output  is 25 as per calculation below.
| 26-13 | = 13
| 14-26 | =  12
Total Sum = 13 + 12 = 25

Here is the code:

#include <stdio.h>
#include <stdlib.h>
int findTotalSum(int n, int arr[], int start)
{
    int difference, sum=0;
    for(int i=start-1; i<n-1; i++)
    {
        difference = abs(arr[i]-arr[i+1]);
        sum = sum + difference;
    }
    return sum;
}
int main()
{
    int n;
    int start;
    scanf("%d",&n);
    int array[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&array[i]);
    }
    scanf("%d",&start);
    int result = findTotalSum(n, array, start);
    printf("\n%d",result);
    return 0;
}

Q) Write a program to return the difference between the count of odd numbers and even numbers.

You are expected to write code in the countOddEvenDifference function only which will receive the first parameter as the number of items in the array and second parameter as the array itself. you are not required to take input from the console.

Example
Finding the difference between the count of odd and even numbers from a list of 5  number

Input
input 1 : 8
input 2 : 10 20 30 40 55 66 77 83

Output
-2

Explanation
The first paramter (8) is the szie of the array. Next is an array of integers. The calculation of difference between count sum of odd and even numbers is as follows:

3 (count of odd numbers) – 5 (count of even numbers) = -2

Here is the code:

#include <stdio.h>
int countOddEvenDifference(int n, int arr[])
{
    int odd = 0, even = 0;
    for(int i=0; i<n; i++)
    {
        if(arr[i]%2==0)
        {
            even = even+1;
        }
        else
        {
            odd = odd+1;
        }   
    }
    return odd - even;
}
int main()
{
    int n;
    scanf("%d",&n);
    int array[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d",&array[i]);
    }
    int result = countOddEvenDifference(n, array);
    printf("%d",result);
    return 0;
}

Question) Rohan and his team are participating in the Treasure Hunt event of college in which in each step they have to solve one problem to get a clue about the Treasure location. Rohan’s team has performed very well and reached the final step where they have to provide a code of a problem to get a final clue about treasure .

Given a string s, they need to find the longest palindromic subsequence’s length in s.
A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.

The string contains only lowercase letters.

Write a program to help Rohan’s team that takes in input as String x and returns the length of the longest palindromic subsequence of x.

Input Specification:

input1: string input

Output Specification:

Return the length of the longest palindromic subsequence

Example 1:

Input: s = “bbbab”
Output: 4
Explanation: One possible longest palindromic subsequence is “bbbb”.

Example 2:

Input: s = “cbbd”
Output: 2
Explanation: One possible longest palindromic subsequence is “bb”.

C++ PROGRAM

#include<iostream>
#include<cstring>
using namespace std;

int max (int x, int y) 
{
    return (x > y)? x : y; 
}

int lps(char *str)
{
    int n = strlen(str);
    int i, j, cl;
    int L[n][n]; 

    for (i = 0; i < n; i++)
	    L[i][i] = 1;

    for (cl = 2; cl <= n; cl++)
	{
		for (i = 0; i < n-cl+1; i++)
		{
		    j = i + cl-1;
		    if (str[i] == str[j] && cl == 2)
		        L[i][j] = 2;
		    else if (str[i] == str[j])
		        L[i][j] = L[i+1][j-1] + 2;
		    else L[i][j] = max(L[i][j-1], L[i+1][j]);
		}
	}
	return L[0][n-1];
}

int main()
{
    char seq[20];
    cin >> seq;
	int n = strlen(seq);
	printf("%d", lps(seq));
	getchar();
	return 0;
}

JAVA PROGRAM

import java.util.*;
public class Main
{
	static int max (int x, int y) 
	{
	    return (x > y)? x : y; 
	    
	}

	static int lps(String seq)
	{
	    int n = seq.length();
	    int i, j, cl;
    	    int L[][] = new int[n][n];
	
    	    for (i = 0; i < n; i++)
	    	L[i][i] = 1;
		
		for (cl = 2; cl <= n; cl++)
		{
			for (i = 0; i < n-cl+1; i++)
			{
				j = i+cl-1;
				if (seq.charAt(i) == seq.charAt(j) && cl == 2)
    				L[i][j] = 2;
				else if (seq.charAt(i) == seq.charAt(j))
	    			L[i][j] = L[i+1][j-1] + 2;
				else
		    		L[i][j] = max(L[i][j-1], L[i+1][j]);
			}
		}
		return L[0][n-1];
	}
	
	public static void main(String args[])
	{
	        Scanner sc = new Scanner(System.in);
		String seq = sc.next();
		int n = seq.length();
		System.out.println(""+ lps(seq));
	}
}

PYTHON PROGRAM

s = input()
n = len(s)
rev = s[::-1]
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

for i in range(1, n+1):
    for j in range(1, n+1):
        if s[i-1] == rev[j-1]:
            dp[i][j] = 1 + dp[i-1][j-1]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i][j-1])

print(dp[n][n])

Questions: A chef has n orders lined up. The waiting time penalty before an order starts getting processed is k. And for each order, a corresponding processing time t is given (in minutes) along with its order id. The earning per order is c times the time taken to process the order. Find out the profits earned for each order from 1 to n and print them in order of the input. The order is free if the profits are negative for that order i.e. the profits are max(0, profit).

The following rules are used for processing the orders:

  1. Pick the order which arrives first. The chef can process only one order at a time.
  2. Among the orders already arrived, pick the one with the least processing time.

Input Format:

First the number of test cases T is given. Then T test cases follow.

Each test case consists of n (the number of orders),c (the cost per minute it takes to process any order, which is the same for all orders), and k (the waiting time penalty per minute, the chef faces once an order has arrived and is there in the “waiting to be processed queue”).

Then in the following n lines, an order with its arrival time and the processing time is given.

The order id of the first of these n lines is 1, the order id of the 2nd order is 2, and so on till the nth line has the order id n.

NOTE: The input may or may not be sorted by the arrival time i.e. order 3 may arrive earlier than order 2 and so on.

Output Format: For each test case, print in a single line the profits earned for orders 1 to n, respectively.

Constraints:

1<=T<=10 ; 1<=n<=10^5 ; 1<=order arrival time, order processing time <= 10^9 ; 1<=k<=100 ; 1<=c<=10^4 ; Time limit: 1 second per test case

Example :

Input:

1
3 10 16
1 2
2 3
3 1

Explanation:

The number of test cases T = 1. A number of orders n = 3. Processing cost per order per minute i.e. c = 10. Penalty cost for an order already arrived but in the waiting queue per minute of waiting i.e. k = 1. Then the list of orders follows. Order 1 arrives at time t=1. the chef does nothing from t=0 to t=1.

Since he has to pick up the order which arrived first his profit earned for order 1 would be processing time*c — k*waiting time. Since the order was processed immediately as it came, the waiting time would be 0 for order 1. Hence, profit of order 1 = 2*10 — 16*0= 20. Now the time t=1+2=3. Therefore both orders 2 and 3 have arrived and are in the waiting queue.

But the chef chooses order 3 to be processed first since it has less processing time. Therefore profit for order 3 is 1*10-16*0=10, as order 3 was processed the moment it came. Now the time t=3+1=4 and the last order 2 is taken up which has been waiting for 4-2=2 minutes. Therefore the profit earned for order 2 = 3*10 — 16*2= 30 — 32 = -2. Therefore the order is free or profit = 0.

Output: 20 0 10

Q2:

Solution:

#include<bits/stdc++.h>

using namespace std;

typedef long long int ll;

typedef vector<ll> vi;

#define fo(i,s,e_ex) for(i=s;i<e_ex;i++)

#define pbb push_back

#define all(x) x.begin(),x.end()

struct task{

ll idx,at,bt;

};

bool comp(task p,task q){

if(p.at==q.at){

return p.bt<q.bt;

}

return p.at<q.at;

}

bool Compare(task a, task b){

if(a.bt==b.bt){

return a.idx>b.idx;

}

return a.bt>b.bt;

}

void solve(ll caseno){

ll i,j,n,k,d,t=0;

cin>>n>>k>>d;

vector<task> arr;

vector<ll> ans(n);

fo(i,0,n){

ll a,b;

cin>>a>>b;

task t;

t.idx=i;t.at=a;t.bt=b;

arr.pbb(t);

}

sort(all(arr),comp);

priority_queue<task, std::vector<task>, decltype(&Compare)> pq(Compare);

i=0;

while((!pq.empty()) || i<n){

if(pq.empty()){

pq.push(arr[i]);

t=arr[i].at;

i++;

}

task curr = pq.top();pq.pop();

ll wait = t-curr.at;

t+=curr.bt;

ll cost = curr.bt*k – wait*d;

cost = max(cost,0ll);

ans[curr.idx] = cost;

while(i<n && arr[i].at<=t){

pq.push(arr[i]);

i++;

}

}

for(auto v:ans) cout<<v<<‘ ‘;

cout<<endl;

}

int main(){

ios_base::sync_with_stdio(false);

cin.tie(0);cout.tie(0);

ll t=1;

cin>>t;

for(ll i=1;i<=t;i++){

solve(i);

}

return 0;

}

JOB ALERT ON INSTAGRAM FOLLOW NOW>>
JOB ALERT ON TELEGRAM JOIN NOW>>

Follow regularly our Dailyrecruitment.in site to get upcoming all up-to-date information.

Govt Jobs by Qualifications

Education & Vacancies Salary Apply Link
10th Pass Govt Jobs - 5,000 Vacancies Rs. 5,200 - 63,200 Apply Now
12th Pass Govt Jobs - 18,000+ Vacancies Rs. 5,200 - 92,300 Apply Now
ITI Pass Jobs - 3,500 Vacancies Rs. 5,200 - 35,000 Apply Now
Any Graduate Jobs - 19,100 Vacancies Rs. 5,200 - 92,300 Apply Now
Central Govt Jobs Rs. 5,200 - 17,000 Apply Now
Bank Jobs - 1,000 Vacancies Rs. 5,200 - 29,200 Apply Now
Diploma Jobs - 9,300 Vacancies Rs. 5,200 - 35,000 Apply Now
BTech/BE Jobs - 18,000 Vacancies Rs. 15,000 - 1,00,000 Apply Now
Data Entry Jobs - 1,300 Vacancies Rs. 5,200 - 29,200 Apply Now
Private Jobs Rs. 10,000 - 67,700 Apply Now