Advertisement
Guitayk

Solution Exercice 2

Dec 5th, 2020 (edited)
992
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. public static int supprime(List<Integer> a, List<Integer> b){
  2.     ListIterator<Integer> ita = a.listIterator();
  3.     ListIterator<Integer> itb = b.listIterator();
  4.     int count = 0;
  5.     while(ita.hasNext() && itb.hasNext()){
  6.         int valeurA = ita.next();
  7.         int valeurB = itb.next();
  8.         if(valeurA < valeurB) itb.previous();
  9.         else if(valeurB < valeurA) ita.previous();
  10.         else{
  11.             itb.remove();
  12.             count++;
  13.         }
  14.     }
  15.     return count;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement