class TransposeUtils {

  public static <T> List<List<T>> transpose(List<List<T>> mat) {
    int height = mat.size();
    int width = mat.get(0).size();
    List<List<T>> transposed = new ArrayList<>(width);
    for (int w = 0; w < width; w++) {
      List<T> newRow = new ArrayList<>(height);
      for (List<T> aMat : mat) {
        newRow.add(aMat.get(w));
      }
      transposed.add(newRow);
    }
    return transposed;
  }

  private  TransposeUtils();

}