In which case there is no point in writing any code before you have got the logic worked out. Please post a description of the algorithm you are using. I presume you are being taught algorithms, in which case, what did they tell you to use? Why did you say positive numbers? Why can't you do the same with five negative numbers or 0s?kabi Rabbi wrote:. . . I think I'm doing something wrong in my logic. . . .
You are not helping the OP to learn by providing a ready‑made solution; in fact it may interfere with his(?) learning because he(?) no longer has to work out what the solution is; I have deleted your solution.We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
Campbell Ritchie wrote:You are not helping the OP to learn by providing a ready‑made solution;
kabi Rabbi wrote:problem:
Issue: My output is wrong. I think I'm doing something wrong in my logic.
Can you please give a hint on that?
xin yi wrote:use the Arrays.sort() method, then you will get a sorted array with sort of raising .
to get the maxnumber is to skip the first index;
to get the minnumber is to skip the last index;
kabi Rabbi wrote:I'm sorry the program above does not work for all the test cases.
Why fit in when you were born to stand out? - Seuss. Tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|