qodo.ai
Featured
4.9 (

31 ratings

)

2 support issues

  • All
  • Questions
  • Suggestions
  • Problems

Tomas

Feb 12, 2025

It messes up the GitHub dark mode

I have dark mode in GitHub by default. After installing this extension page background becomes white, which in combination with light-gray text make them hard to read.

Snehal Dokepatil

Sep 19, 2024

PsuedoCode Implementation

PsuedoCode Implementation
Your Tutor is using PsuedoCode to explain you looping. He has chosen an array A that consists of n elements and for that he has provided you with a psuedocode written in the following manner:

result = 0
while A is not empty:
B = []
for x in A, y in A:
if x != y: append absolute_value(x - y) to B
A = B
result = result + 1
He has assigned you the task of figuring out 'result' at the end of the program. If the loop is infinite print "INFINITE".

Input Format:

The first line contains a single integer denoting the size of the array.

The second line contains 'n' space separated integers denoting the elements of the array.

Output Format:

Print the value of result and if the loop runs infinitely then print "INFINITE".

Sample Input:

3

1 3 4

Sample Output:

4

Explanation:

After the loop ends first time our A would be [2,3,2,1,3,1]. After the second time the loop ends, you will notice that our array would only contain 1s and 2s. Then at the end of the third iteration it will just contain 1s. The fourth loop will ends and the A is now empty thus we are done with looping. The result is now equal to 4 and that is the output.

Constraints:

1<=n<=10^5

1<=a[i]<=10^4

Language
Java (OpenJDK 13.0.1)

Selection deleted
1
Enter your code here
Stdin

4
1 3 5 7

Stdout


Escalation framework
|
Placement assistance policy
|
Batch change policy

Google apps
Design a Mobile Site
View Site in Mobile | Classic
Share by: