You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For this lesson, I am supposed to "compute the second maximal value contained in an array, i.e. the value that becomes the maximum if you remove every instance of the current maximum from the array." As I understand it, that means that if the array has more than one instance of its maximum value, my code must ignore all of them, returning the next largest number. But when I am graded, the system is asking me to NOT ignore a second instance of the maximum value.
The array of numbers is: {22,24,1,14,-13,25,1,25,18}. Per the instructions, my code ignores both 25's and returns 24. But the PLM is saying that the expected answer is 25. This is not consistent with the instructions given in the mission statement.
Here is my code:
public int max2Value(int[] tab) {
int first = tab[0];
int second = Integer.MIN_VALUE;
for (int i = 1; i < tab.length; i++) {
if (tab[i] > first) {
second = first;
first = tab[i];
}
if (tab[i] >= second && tab[i] < first) {
second = tab[i];
}
}
return second;
}
--------------------[ Technical Information ]--------------------
(This can help us fixing your problem, please don't erase)
Lesson: welcome
Exercise: welcome.lessons.welcome.array.search.SecondMaxValue
Programming Language: Java
Locale: English (United States)
Java version: 11.0.1 (VM: OpenJDK 64-Bit Server VM; version: 11.0.1+13-Ubuntu-3ubuntu3.18.10.1)
OS: Linux (version: 4.18.0-15-generic; arch: amd64)
PLM version: 2.7 (20170901)
Public user ID: PLM6e527c892fb4e499ce3404b433efcb1eb7f70feb
The text was updated successfully, but these errors were encountered:
For this lesson, I am supposed to "compute the second maximal value contained in an array, i.e. the value that becomes the maximum if you remove every instance of the current maximum from the array." As I understand it, that means that if the array has more than one instance of its maximum value, my code must ignore all of them, returning the next largest number. But when I am graded, the system is asking me to NOT ignore a second instance of the maximum value.
The array of numbers is: {22,24,1,14,-13,25,1,25,18}. Per the instructions, my code ignores both 25's and returns 24. But the PLM is saying that the expected answer is 25. This is not consistent with the instructions given in the mission statement.
Here is my code:
public int max2Value(int[] tab) {
int first = tab[0];
int second = Integer.MIN_VALUE;
for (int i = 1; i < tab.length; i++) {
if (tab[i] > first) {
second = first;
first = tab[i];
}
if (tab[i] >= second && tab[i] < first) {
second = tab[i];
}
}
return second;
}
--------------------[ Technical Information ]--------------------
(This can help us fixing your problem, please don't erase)
Lesson: welcome
Exercise: welcome.lessons.welcome.array.search.SecondMaxValue
Programming Language: Java
Locale: English (United States)
Java version: 11.0.1 (VM: OpenJDK 64-Bit Server VM; version: 11.0.1+13-Ubuntu-3ubuntu3.18.10.1)
OS: Linux (version: 4.18.0-15-generic; arch: amd64)
PLM version: 2.7 (20170901)
Public user ID: PLM6e527c892fb4e499ce3404b433efcb1eb7f70feb
The text was updated successfully, but these errors were encountered: