1. Engineering
  2. Computer Science
  3. in java implement the method listsswaplargestandsecondsmallestarraylistltintegergt a that swaps the...

Question: in java implement the method listsswaplargestandsecondsmallestarraylistltintegergt a that swaps the...

Question details
  1. In Java, implement the method Lists.swapLargestAndSecondSmallest(ArrayList<Integer> a) that swaps the largest and second smallest element in a. If there are multiple largest or second smallest elements, pick the first one. If all elements are the same, don't change anything. Your algorithm should be O(n). Check your answer with CodeCheck http://www.codecheck.it/files/161214081248b0jah3c7dttwa7b2ptynser
Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution