code: public static LeetLevel fromString(String str)
              throws Exception {
          if (str == null || str.equalsIgnoreCase("null") || str.length() == 0)
              return LEVEL1;
  
          try {
              int i = Integer.parseInt(str);
              if (i >= 1 && i <= LEVELS.length)
                  return LEVELS[i - 1];
          } catch (Exception ignored) {}
  
          String exceptionStr = String.format("Invalid LeetLevel '%1s', valid values are '1' to '9'", str);
          throw new Exception(exceptionStr);
      }
docs: Converts a string to a leet level.
  
  @param str The string to parse the leet level from.
  @return The leet level if valid.
  @throws Exception upon invalid level.