SHARE
TWEET

Untitled

a guest Feb 16th, 2020 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  public ArrayList<Integer> toOddList(List<Integer> list)
  2.         {
  3.              ArrayList<Integer> newList = new ArrayList<Integer>(list);
  4.              
  5.            
  6.            int temp = newList.size();
  7.            if (newList.size()<=0)// The list is empty or has one element)
  8.            {
  9.                return newList;
  10.            }
  11.            else
  12.            {
  13.                if(newList.size()%2==0)
  14.                   temp = newList.remove(newList.size()-1);
  15.                newList.remove(newList.size()-1);
  16.                newList = toOddList(newList);
  17.                if (temp>0)
  18.                 newList.add(temp);
  19.         }
  20.         return newList;
  21.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top