title: Is there any chance to get rid of that error?(Memory Limit Exceeded)
body: <p>Here is a problem:
  Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.</p>
  
  <p>Note:</p>
  
  <p>If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string. For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"].
  All airports are represented by three capital letters (IATA code).
  You may assume all tickets form at least one valid itinerary.</p>
  
  <p>Unfortunately i get  all the time these errors </p>
  
  <blockquote>
    <p>Line 63: error: cannot find symbol [in MainClass.java]
              list.add(stringToStringList(cols.toString()));
                       ^   symbol:   method stringToStringList(String)   location: class MainClass Line 83: error: cannot find symbol [in
    MainClass.java]
                List> tickets = stringToString2dList(line);
                                             ^   symbol:   method stringToString2dList(String)   location: class MainClass 2 errors</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>class Solution {
      class Checker implements Comparator&lt;String&gt;{
          @Override
          public int compare(String o1, String o2) {
              return o1.compareToIgnoreCase(o2);
          }
      }
      public List&lt;String&gt; findItinerary(List&lt;List&lt;String&gt;&gt; tickets){
          String begin="JFK";
          final String example=begin;
          List&lt;String&gt; solution = new ArrayList&lt;&gt;();
          long counter=tickets.stream().filter(lister-&gt;lister.get(0).equals(example)).count();
          List&lt;String&gt; lexic=tickets.stream().filter(lister-&gt;lister.get(0).equals("JFK")).map(p-&gt;p.get(1)).distinct().collect(Collectors.toList());
          Comparator&lt;String&gt; comparator =new Checker();
          lexic.sort(comparator);
          solution.add(begin);
          begin=lexic.get(0);
          System.out.println(counter);
          for(int i=0;i&lt;tickets.size();i++) {
              if(tickets.get(i).get(0).equals(begin)) {
                  if(!solution.contains(begin)) {
                      solution.add(begin);
                  }
                  begin=tickets.get(i).get(1);
                  solution.add(begin);
                  i=-1;
              }
          }
          return solution;
      }
  
  }
  
  public class MainClass {
      public static String[] stringToStringArray(String line) {
          JsonArray jsonArray = JsonArray.readFrom(line);
          String[] arr = new String[jsonArray.size()];
          for (int i = 0; i &lt; arr.length; i++) {
            arr[i] = jsonArray.get(i).asString();
          }
          return arr;
      }
  
      public static List&lt;List&lt;String&gt;&gt; stringToString2dArray(String input) {
          JsonArray jsonArray = JsonArray.readFrom(input);
          if (jsonArray.size() == 0) {
            return new ArrayList&lt;List&lt;String&gt;&gt;();
          }
          List&lt;List&lt;String&gt;&gt; list = new ArrayList&lt;&gt;(jsonArray.size());
          for (int i = 0; i &lt; jsonArray.size(); i++) {
            JsonArray cols = jsonArray.get(i).asArray();
            list.add(stringToStringList(cols.toString()));
          }
          return list;
      }
  
      public static String stringListToString(List&lt;String&gt; stringList) {
          StringBuilder sb = new StringBuilder("[");
          for (String item : stringList) {
              sb.append(item);
              sb.append(",");
          }
  
          sb.setCharAt(sb.length() - 1, ']');
          return sb.toString();
      }
  
      public static void main(String[] args) throws IOException {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          String line;
          while ((line = in.readLine()) != null) {
              List&lt;List&lt;String&gt;&gt; tickets = stringToString2dList(line);
  
              List&lt;String&gt; ret = new Solution().findItinerary(tickets);
  
              String out = stringListToString(ret);
  
              System.out.print(out);
          }
      }
  }
  </code></pre>