# Persistent Automata Questions and Answers

## Persistent Automata Questions and Answers

Persistent has made some changes in its coding round this year. You will have 2 questions to solve within the duration of about 45 mins. You can code Persistent Automata Questions in languages like C, C++, Java, Python, Ruby, Perl etc.

## How to prepare for Persistent Automata Questions and Test:

• Always Remember there may be some hidden test cases. Try to cover and pass all the given test cases.
• Try to give an optimal solution for the given problem statements which may gain you additional benefit in the Automata Section as well as Technical Interview.
• Try to Solve all the given problems in a specific language instead of using different languages for different problems.
• Read the complete problem statement, then try to structure the optimal code and then go for the coding. Don’t code by reading the problem line by line.
• Also, there is a time limit of 45 minutes. So be prepared with your time management skills.
Coding SectionDetails
No. of Questions2
Time Duration45 mins
Difficulty LevelHigh

We have given below some coding questions with solution to give you an overview of Persistent Automata Questions and Answers. Please go through them while preparing for Persistent Coding Test.

## Persistent Automata Question-1

Ram is a 6 years old boy who loves to play with numeric legos. One day Ram’s mom created a number using those legos and asked ram to tell the number of elements available between two specific numbers ‘alpha1’ and ‘alpha2’. After 15 years when Ram started learning to program, he now wants to write a code to find the number of elements lies between ranges alpha1 and alpha2. If the number is arr and the starting and ending points are alpha1 and alpha2, find the numbers of elements lies in the range.

#### Input:

• Three space-separated integers
1. First is the length of arr.
2. Second is the starting point as alpha1.
3. The third is the endpoint as alpha2.
• N space-separated array elements.

#### Output:

• Space-separated indexes between alpha1 and alpha2.

#### Example:

Input:

9 2 6 1 2 3 4 5 6 7 8 9

Output:

1 2 3 4

## Persistent Automata Question-2

Find the security key to access the bank account in from the encrypted message. The key in the message is the first repeating number from the given message of numbers.

• String

#### Output:

• The first repeating number from the message

Input:

123456654321

Output:

1

## Persistent Automata Question-3

Write a program to calculate the sum of elements of an array that are equal to the integer entered by the user. The inputs will be the size of the array, elements of the array, and an integer. You have to print the sum calculated after adding all the elements that match the integer entered by the user.

#### Input:

1. Length
2. Input number
3. Element

#### Output:

• Sum of elements the same as the value

Input:

8

1 2 3 4 2 5 6 2

2

Output:

6

## Persistent Automata Question-4

For the generation of energy at the atomic center the energy is used to start the plant is in negative sign and the energy generated after the plant started is represented with a positive sign. Our task is to calculate the total number of energy that is generated throughout the day.

#### Input:

• Two inputs –  One for the number of times energy was recorded  as ‘total_reading’ and Second for reading of the energy used or produced ‘arr’.

#### Output:

• Sum of the total energy produced

#### Example:

Input:

8 1 4 -5 6 7 -4 4 -1

Output:

12

## Persistent Automata Question-5

Print the number at the given index of the series 1 1 2 3 5… and so on. Consider the index as the number and print the value

#### Input:

• Single input of the index of the number as ‘number’

#### Output:

• The number at the given index of the series

Input:

10

Output:

55

## Persistent Automata Question-6

The function printPattern(int  num)​ prints elements of an pre inputted array based on the value of input argument num​  ​(num>=​ 0). If the input number num​ is even, the function is expected to print all the even numbers upto num of the array, and in case it’s odd, is expected to print all the odd numbers upto num of the array.

#### Input:

• Num , where 0 <= num <= 10

#### Output:

• All numbers separated with space.

### Example:

Input:

Num = 2

Arr[] = {1,2,3,4,5,6,7,8,9,10}

Output:

the function prints 2(without quotes).

### Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

## Persistent Automata Questions and Answers

Persistent has made some changes in its coding round this year. You will have 2 questions to solve within the duration of about 45 mins. You can code Persistent Automata Questions in languages like C, C++, Java, Python, Ruby, Perl etc.

## What platform do Presistent use to conduct recruitment process?

Persistent use its SHL platform for the assessment

## Which programming language is required to clear Persistent Automata Questions  ?

You can code Persistent Automata Questions in languages like C, C++, Java, Python, Ruby, Perl etc.

• Mohan

For 1st question the output should be 2,3,4,5 ( elements between 2 and 6) but not the indexes of those elements…
Correct ans is printf(“%d”,arr[j]);

• shriyank

In the question 1 output should be elements of array not counting value(j)
print statement should be printf(“%d”,arr[j]);
o/p-2,3,4,5

• jay deep

Hey Shriyank, just have a look at what we have to print in the output.
It is clearly stated that we’ve to print indices not the elements.
Have a Good day 😊