@@ -0,0 +1,2236 @@
+/*%0APlane tickets%0A%0AA plane ticket contains a departure location and a destination. Locations are identified by unique integer numbers.%0A%0AGiven a set of plane tickets used by a traveler%0A%0AYour task is to%0A%0A    write a function that reconstructs the traveler%E2%80%99s itinerary and prints to the standard output (stdout) the IDs of each visited location in the order they were visited (one per line)%0A    please note that no location was visited twice in the traveler's journey%0A%0ANote that your function will receive the following arguments:%0A%0A    departure_ids%0A        an array of integer numbers representing the IDs of the departure locations for all given plane tickets%0A    destination_ids%0A        which is an array of integers representing the corresponding IDs of the destinations for all given plane tickets%0A%0Ae.g. departure_ids%5Bi%5D and destination_ids%5Bi%5D represent the locations on ticket i%0A%0AData constraints%0A%0A    the length of the arrays above will not exceed 20,000 entries%0A*/%0A%0A%0Aimport java.util.*;%0A%0Aclass MyClass %7B%0A%0A    public static void get_journey(Integer%5B%5D departure_ids, Integer%5B%5D destination_ids) %0A    %7B           %0A        HashMap%3CInteger,Integer%3E depDes = new HashMap%3CInteger, Integer%3E();%0A        %0A        for(int i = 0; i %3C departure_ids.length; i++)%0A        %7B%0A            depDes.put(departure_ids%5Bi%5D, destination_ids%5Bi%5D);  %0A        %7D%0A          %0A        Integer next = findFirst(depDes);%0A        Integer temp;%0A        int size = depDes.size();%0A        %0A        while(size %3E 1)%0A        %7B%0A            System.out.print(next + %22 %22);%0A            temp = next;%0A            next = depDes.get(next);%0A            depDes.remove(temp); %0A            size--;%0A        %7D%0A        %0A        System.out.print(next + %22 %22 + depDes.get(next));%0A    %7D%0A    %0A    public static Integer findFirst(HashMap%3CInteger, Integer%3E depDes)%0A    %7B%0A        Integer key = -1;%0A        Integer value = -1;%0A        for (Map.Entry%3CInteger, Integer%3E entry : depDes.entrySet()) %0A        %7B%0A            key = entry.getKey();%0A%0A            if(!depDes.containsValue(key))%0A            %7B%0A                System.out.print(key + %22 %22);  %0A                depDes.remove(key);%0A                value = entry.getValue();%0A                break;%0A            %7D%0A        %7D%0A        return value;%0A    %7D%0A%7D%0A

Create PlaneTickets.java