/**
 * Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.
 *
 * For example,
 * Given n = 3, your program should return all 5 unique BST's shown below.
 *
 * 1       3     3      2      1
 * \      /     /      / \      \
 * 3     2     1      1  3      2
 * /    /       \                \
 * 2   1        2                 3
 *
 * Accepted.
 */
class UniqueBinarySearchTreesII {

    fun generateTrees(n: Int): List<TreeNode?> {
        val list = mutableListOf<TreeNode>()

        return if (n <= 0) {
            list
        } else gen(1, n)
    }

    private fun gen(start: Int, end: Int): List<TreeNode?> {
        val list = mutableListOf<TreeNode?>()
        if (start > end) {
            list.add(null)
            return list
        }
        if (start == end) {
            list.add(TreeNode(start))
            return list
        }

        for (i in start..end) {
            for (m in gen(start, i - 1)) {
                gen(i + 1, end).mapTo(list) {
                    TreeNode(i).apply {
                        left = m
                        right = it
                    }
                }
            }
        }

        return list
    }

    data class TreeNode(
            var `val`: Int,
            var left: TreeNode? = null,
            var right: TreeNode? = null
    )

}

Compiled from "UniqueBinarySearchTreesII.kt"
public final class UniqueBinarySearchTreesII {
  public UniqueBinarySearchTreesII();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<UniqueBinarySearchTreesII$TreeNode> generateTrees(int);
    Code:
       0: new           #16                 // class java/util/ArrayList
       3: dup
       4: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #19                 // class java/util/List
      10: astore_2
      11: iload_1
      12: ifgt          19
      15: aload_2
      16: goto          25
      19: aload_0
      20: iconst_1
      21: iload_1
      22: invokespecial #23                 // Method gen:(II)Ljava/util/List;
      25: areturn

  private final java.util.List<UniqueBinarySearchTreesII$TreeNode> gen(int, int);
    Code:
       0: new           #16                 // class java/util/ArrayList
       3: dup
       4: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #19                 // class java/util/List
      10: astore_3
      11: iload_1
      12: iload_2
      13: if_icmple     26
      16: aload_3
      17: aconst_null
      18: invokeinterface #32,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      23: pop
      24: aload_3
      25: areturn
      26: iload_1
      27: iload_2
      28: if_icmpne     53
      31: aload_3
      32: new           #34                 // class UniqueBinarySearchTreesII$TreeNode
      35: dup
      36: iload_1
      37: aconst_null
      38: aconst_null
      39: bipush        6
      41: aconst_null
      42: invokespecial #37                 // Method UniqueBinarySearchTreesII$TreeNode."<init>":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
      45: invokeinterface #32,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      50: pop
      51: aload_3
      52: areturn
      53: iload_1
      54: istore        4
      56: iload         4
      58: iload_2
      59: if_icmpgt     234
      62: aload_0
      63: iload_1
      64: iload         4
      66: iconst_1
      67: isub
      68: invokespecial #23                 // Method gen:(II)Ljava/util/List;
      71: invokeinterface #41,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      76: astore        5
      78: aload         5
      80: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      85: ifeq          222
      88: aload         5
      90: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      95: checkcast     #34                 // class UniqueBinarySearchTreesII$TreeNode
      98: astore        6
     100: aload_0
     101: iload         4
     103: iconst_1
     104: iadd
     105: iload_2
     106: invokespecial #23                 // Method gen:(II)Ljava/util/List;
     109: checkcast     #53                 // class java/lang/Iterable
     112: astore        7
     114: iconst_0
     115: istore        8
     117: aload         7
     119: invokeinterface #54,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     124: astore        9
     126: aload         9
     128: invokeinterface #47,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     133: ifeq          214
     136: aload         9
     138: invokeinterface #51,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     143: astore        10
     145: aload_3
     146: checkcast     #56                 // class java/util/Collection
     149: aload         10
     151: checkcast     #34                 // class UniqueBinarySearchTreesII$TreeNode
     154: astore        11
     156: astore        16
     158: iconst_0
     159: istore        12
     161: new           #34                 // class UniqueBinarySearchTreesII$TreeNode
     164: dup
     165: iload         4
     167: aconst_null
     168: aconst_null
     169: bipush        6
     171: aconst_null
     172: invokespecial #37                 // Method UniqueBinarySearchTreesII$TreeNode."<init>":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
     175: astore        13
     177: aload         13
     179: astore        14
     181: iconst_0
     182: istore        15
     184: aload         14
     186: aload         6
     188: invokevirtual #60                 // Method UniqueBinarySearchTreesII$TreeNode.setLeft:(LUniqueBinarySearchTreesII$TreeNode;)V
     191: aload         14
     193: aload         11
     195: invokevirtual #63                 // Method UniqueBinarySearchTreesII$TreeNode.setRight:(LUniqueBinarySearchTreesII$TreeNode;)V
     198: nop
     199: aload         13
     201: nop
     202: aload         16
     204: swap
     205: invokeinterface #64,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     210: pop
     211: goto          126
     214: aload_3
     215: checkcast     #56                 // class java/util/Collection
     218: pop
     219: goto          78
     222: iload         4
     224: iload_2
     225: if_icmpeq     234
     228: iinc          4, 1
     231: goto          62
     234: aload_3
     235: areturn
}

Compiled from "UniqueBinarySearchTreesII.kt"
public final class UniqueBinarySearchTreesII$TreeNode {
  private int val;

  private UniqueBinarySearchTreesII$TreeNode left;

  private UniqueBinarySearchTreesII$TreeNode right;

  public UniqueBinarySearchTreesII$TreeNode(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode);
    Code:
       0: aload_0
       1: invokespecial #10                 // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #14                 // Field val:I
       9: aload_0
      10: aload_2
      11: putfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      14: aload_0
      15: aload_3
      16: putfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      19: return

  public UniqueBinarySearchTreesII$TreeNode(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode, int, kotlin.jvm.internal.DefaultConstructorMarker);
    Code:
       0: iload         4
       2: iconst_2
       3: iand
       4: ifeq          9
       7: aconst_null
       8: astore_2
       9: iload         4
      11: iconst_4
      12: iand
      13: ifeq          18
      16: aconst_null
      17: astore_3
      18: aload_0
      19: iload_1
      20: aload_2
      21: aload_3
      22: invokespecial #25                 // Method "<init>":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)V
      25: return

  public final int getVal();
    Code:
       0: aload_0
       1: getfield      #14                 // Field val:I
       4: ireturn

  public final void setVal(int);
    Code:
       0: aload_0
       1: iload_1
       2: putfield      #14                 // Field val:I
       5: return

  public final UniqueBinarySearchTreesII$TreeNode getLeft();
    Code:
       0: aload_0
       1: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
       4: areturn

  public final void setLeft(UniqueBinarySearchTreesII$TreeNode);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
       5: return

  public final UniqueBinarySearchTreesII$TreeNode getRight();
    Code:
       0: aload_0
       1: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
       4: areturn

  public final void setRight(UniqueBinarySearchTreesII$TreeNode);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
       5: return

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #14                 // Field val:I
       4: ireturn

  public final UniqueBinarySearchTreesII$TreeNode component2();
    Code:
       0: aload_0
       1: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
       4: areturn

  public final UniqueBinarySearchTreesII$TreeNode component3();
    Code:
       0: aload_0
       1: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
       4: areturn

  public final UniqueBinarySearchTreesII$TreeNode copy(int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode);
    Code:
       0: new           #2                  // class UniqueBinarySearchTreesII$TreeNode
       3: dup
       4: iload_1
       5: aload_2
       6: aload_3
       7: invokespecial #25                 // Method "<init>":(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)V
      10: areturn

  public static UniqueBinarySearchTreesII$TreeNode copy$default(UniqueBinarySearchTreesII$TreeNode, int, UniqueBinarySearchTreesII$TreeNode, UniqueBinarySearchTreesII$TreeNode, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #14                 // Field val:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      23: astore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      35: astore_3
      36: aload_0
      37: iload_1
      38: aload_2
      39: aload_3
      40: invokevirtual #46                 // Method copy:(ILUniqueBinarySearchTreesII$TreeNode;LUniqueBinarySearchTreesII$TreeNode;)LUniqueBinarySearchTreesII$TreeNode;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #50                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #51                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #53                 // String TreeNode(val=
       9: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #14                 // Field val:I
      16: invokevirtual #60                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #62                 // String , left=
      21: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      28: invokevirtual #65                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      31: ldc           #67                 // String , right=
      33: invokevirtual #57                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      40: invokevirtual #65                 // Method java/lang/StringBuilder.append:(Ljava/lang/Object;)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #70                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #72                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #14                 // Field val:I
       4: invokestatic  #78                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      16: ifnonnull     23
      19: iconst_0
      20: goto          30
      23: aload_0
      24: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      27: invokevirtual #80                 // Method hashCode:()I
      30: iadd
      31: istore_1
      32: iload_1
      33: bipush        31
      35: imul
      36: aload_0
      37: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      40: ifnonnull     47
      43: iconst_0
      44: goto          54
      47: aload_0
      48: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      51: invokevirtual #80                 // Method hashCode:()I
      54: iadd
      55: istore_1
      56: iload_1
      57: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class UniqueBinarySearchTreesII$TreeNode
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class UniqueBinarySearchTreesII$TreeNode
      20: astore_2
      21: aload_0
      22: getfield      #14                 // Field val:I
      25: aload_2
      26: getfield      #14                 // Field val:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      38: aload_2
      39: getfield      #18                 // Field left:LUniqueBinarySearchTreesII$TreeNode;
      42: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      45: ifne          50
      48: iconst_0
      49: ireturn
      50: aload_0
      51: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      54: aload_2
      55: getfield      #21                 // Field right:LUniqueBinarySearchTreesII$TreeNode;
      58: invokestatic  #89                 // Method kotlin/jvm/internal/Intrinsics.areEqual:(Ljava/lang/Object;Ljava/lang/Object;)Z
      61: ifne          66
      64: iconst_0
      65: ireturn
      66: iconst_1
      67: ireturn
}


/**
 * Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0?
 * Find all unique triplets in the array which gives the sum of zero.
 *
 * Note: The solution set must not contain duplicate triplets.
 *
 * For example, given array S = [-1, 0, 1, 2, -1, -4],
 *
 * A solution set is:
 * [
 * [-1, 0, 1],
 * [-1, -1, 2]
 * ]
 *
 * Accepted.
 */
class ThreeSum {

    fun threeSum(nums: IntArray): List<List<Int>> {
        nums.sort()
        val set = mutableSetOf<Triple>()

        for (first in 0 until nums.size - 2) {
            if (nums[first] > 0) {
                break
            }

            val target = 0 - nums[first]
            var second = first + 1
            var third = nums.size - 1

            while (second < third) {
                when {
                    nums[second] + nums[third] == target -> {
                        set.add(Triple(nums[first], nums[second], nums[third]))
                        while (second < third && nums[second] == nums[second + 1]) {
                            second++
                        }
                        while (second < third && nums[third] == nums[third - 1]) {
                            third--
                        }
                        second++
                        third--
                    }
                    nums[second] + nums[third] < target -> second++
                    else -> third--
                }
            }
        }

        return mutableListOf<List<Int>>().apply {
            addAll(set.map { arrayListOf(it.a, it.b, it.c) })
        }
    }

    internal data class Triple(
            val a: Int,
            val b: Int,
            val c: Int
    )

}

Compiled from "ThreeSum.kt"
public final class ThreeSum {
  public ThreeSum();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.util.List<java.lang.Integer>> threeSum(int[]);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #28                 // Method kotlin/collections/ArraysKt.sort:([I)V
      10: new           #30                 // class java/util/LinkedHashSet
      13: dup
      14: invokespecial #31                 // Method java/util/LinkedHashSet."<init>":()V
      17: checkcast     #33                 // class java/util/Set
      20: astore_2
      21: iconst_0
      22: istore_3
      23: aload_1
      24: arraylength
      25: iconst_2
      26: isub
      27: istore        4
      29: iload_3
      30: iload         4
      32: if_icmpge     202
      35: aload_1
      36: iload_3
      37: iaload
      38: ifle          44
      41: goto          202
      44: iconst_0
      45: aload_1
      46: iload_3
      47: iaload
      48: isub
      49: istore        5
      51: iload_3
      52: iconst_1
      53: iadd
      54: istore        6
      56: aload_1
      57: arraylength
      58: iconst_1
      59: isub
      60: istore        7
      62: iload         6
      64: iload         7
      66: if_icmpge     196
      69: nop
      70: aload_1
      71: iload         6
      73: iaload
      74: aload_1
      75: iload         7
      77: iaload
      78: iadd
      79: iload         5
      81: if_icmpne     170
      84: aload_2
      85: new           #35                 // class ThreeSum$Triple
      88: dup
      89: aload_1
      90: iload_3
      91: iaload
      92: aload_1
      93: iload         6
      95: iaload
      96: aload_1
      97: iload         7
      99: iaload
     100: invokespecial #38                 // Method ThreeSum$Triple."<init>":(III)V
     103: invokeinterface #42,  2           // InterfaceMethod java/util/Set.add:(Ljava/lang/Object;)Z
     108: pop
     109: iload         6
     111: iload         7
     113: if_icmpge     135
     116: aload_1
     117: iload         6
     119: iaload
     120: aload_1
     121: iload         6
     123: iconst_1
     124: iadd
     125: iaload
     126: if_icmpne     135
     129: iinc          6, 1
     132: goto          109
     135: iload         6
     137: iload         7
     139: if_icmpge     161
     142: aload_1
     143: iload         7
     145: iaload
     146: aload_1
     147: iload         7
     149: iconst_1
     150: isub
     151: iaload
     152: if_icmpne     161
     155: iinc          7, -1
     158: goto          135
     161: iinc          6, 1
     164: iinc          7, -1
     167: goto          62
     170: aload_1
     171: iload         6
     173: iaload
     174: aload_1
     175: iload         7
     177: iaload
     178: iadd
     179: iload         5
     181: if_icmpge     190
     184: iinc          6, 1
     187: goto          62
     190: iinc          7, -1
     193: goto          62
     196: iinc          3, 1
     199: goto          29
     202: new           #44                 // class java/util/ArrayList
     205: dup
     206: invokespecial #45                 // Method java/util/ArrayList."<init>":()V
     209: checkcast     #47                 // class java/util/List
     212: astore_3
     213: aload_3
     214: astore        4
     216: iconst_0
     217: istore        5
     219: aload         4
     221: aload_2
     222: checkcast     #49                 // class java/lang/Iterable
     225: astore        6
     227: astore        7
     229: iconst_0
     230: istore        8
     232: aload         6
     234: astore        9
     236: new           #44                 // class java/util/ArrayList
     239: dup
     240: aload         6
     242: bipush        10
     244: invokestatic  #55                 // Method kotlin/collections/CollectionsKt.collectionSizeOrDefault:(Ljava/lang/Iterable;I)I
     247: invokespecial #58                 // Method java/util/ArrayList."<init>":(I)V
     250: checkcast     #60                 // class java/util/Collection
     253: astore        10
     255: iconst_0
     256: istore        11
     258: aload         9
     260: invokeinterface #64,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     265: astore        12
     267: aload         12
     269: invokeinterface #70,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     274: ifeq          359
     277: aload         12
     279: invokeinterface #74,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     284: astore        13
     286: aload         10
     288: aload         13
     290: checkcast     #35                 // class ThreeSum$Triple
     293: astore        14
     295: astore        15
     297: iconst_0
     298: istore        16
     300: iconst_3
     301: anewarray     #76                 // class java/lang/Integer
     304: astore        17
     306: aload         17
     308: iconst_0
     309: aload         14
     311: invokevirtual #80                 // Method ThreeSum$Triple.getA:()I
     314: invokestatic  #84                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     317: aastore
     318: aload         17
     320: iconst_1
     321: aload         14
     323: invokevirtual #87                 // Method ThreeSum$Triple.getB:()I
     326: invokestatic  #84                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     329: aastore
     330: aload         17
     332: iconst_2
     333: aload         14
     335: invokevirtual #90                 // Method ThreeSum$Triple.getC:()I
     338: invokestatic  #84                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     341: aastore
     342: aload         17
     344: invokestatic  #94                 // Method kotlin/collections/CollectionsKt.arrayListOf:([Ljava/lang/Object;)Ljava/util/ArrayList;
     347: aload         15
     349: swap
     350: invokeinterface #95,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     355: pop
     356: goto          267
     359: aload         10
     361: checkcast     #47                 // class java/util/List
     364: nop
     365: aload         7
     367: swap
     368: checkcast     #60                 // class java/util/Collection
     371: invokeinterface #99,  2           // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     376: pop
     377: nop
     378: aload_3
     379: areturn
}

Compiled from "ThreeSum.kt"
public final class ThreeSum$Triple {
  private final int a;

  private final int b;

  private final int c;

  public ThreeSum$Triple(int, int, int);
    Code:
       0: aload_0
       1: invokespecial #9                  // Method java/lang/Object."<init>":()V
       4: aload_0
       5: iload_1
       6: putfield      #13                 // Field a:I
       9: aload_0
      10: iload_2
      11: putfield      #16                 // Field b:I
      14: aload_0
      15: iload_3
      16: putfield      #19                 // Field c:I
      19: return

  public final int getA();
    Code:
       0: aload_0
       1: getfield      #13                 // Field a:I
       4: ireturn

  public final int getB();
    Code:
       0: aload_0
       1: getfield      #16                 // Field b:I
       4: ireturn

  public final int getC();
    Code:
       0: aload_0
       1: getfield      #19                 // Field c:I
       4: ireturn

  public final int component1();
    Code:
       0: aload_0
       1: getfield      #13                 // Field a:I
       4: ireturn

  public final int component2();
    Code:
       0: aload_0
       1: getfield      #16                 // Field b:I
       4: ireturn

  public final int component3();
    Code:
       0: aload_0
       1: getfield      #19                 // Field c:I
       4: ireturn

  public final ThreeSum$Triple copy(int, int, int);
    Code:
       0: new           #2                  // class ThreeSum$Triple
       3: dup
       4: iload_1
       5: iload_2
       6: iload_3
       7: invokespecial #33                 // Method "<init>":(III)V
      10: areturn

  public static ThreeSum$Triple copy$default(ThreeSum$Triple, int, int, int, int, java.lang.Object);
    Code:
       0: iload         4
       2: iconst_1
       3: iand
       4: ifeq          12
       7: aload_0
       8: getfield      #13                 // Field a:I
      11: istore_1
      12: iload         4
      14: iconst_2
      15: iand
      16: ifeq          24
      19: aload_0
      20: getfield      #16                 // Field b:I
      23: istore_2
      24: iload         4
      26: iconst_4
      27: iand
      28: ifeq          36
      31: aload_0
      32: getfield      #19                 // Field c:I
      35: istore_3
      36: aload_0
      37: iload_1
      38: iload_2
      39: iload_3
      40: invokevirtual #37                 // Method copy:(III)LThreeSum$Triple;
      43: areturn

  public java.lang.String toString();
    Code:
       0: new           #41                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #42                 // Method java/lang/StringBuilder."<init>":()V
       7: ldc           #44                 // String Triple(a=
       9: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      12: aload_0
      13: getfield      #13                 // Field a:I
      16: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      19: ldc           #53                 // String , b=
      21: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      24: aload_0
      25: getfield      #16                 // Field b:I
      28: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      31: ldc           #55                 // String , c=
      33: invokevirtual #48                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      36: aload_0
      37: getfield      #19                 // Field c:I
      40: invokevirtual #51                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      43: bipush        41
      45: invokevirtual #58                 // Method java/lang/StringBuilder.append:(C)Ljava/lang/StringBuilder;
      48: invokevirtual #60                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      51: areturn

  public int hashCode();
    Code:
       0: aload_0
       1: getfield      #13                 // Field a:I
       4: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
       7: istore_1
       8: iload_1
       9: bipush        31
      11: imul
      12: aload_0
      13: getfield      #16                 // Field b:I
      16: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
      19: iadd
      20: istore_1
      21: iload_1
      22: bipush        31
      24: imul
      25: aload_0
      26: getfield      #19                 // Field c:I
      29: invokestatic  #66                 // Method java/lang/Integer.hashCode:(I)I
      32: iadd
      33: istore_1
      34: iload_1
      35: ireturn

  public boolean equals(java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: if_acmpne     7
       5: iconst_1
       6: ireturn
       7: aload_1
       8: instanceof    #2                  // class ThreeSum$Triple
      11: ifne          16
      14: iconst_0
      15: ireturn
      16: aload_1
      17: checkcast     #2                  // class ThreeSum$Triple
      20: astore_2
      21: aload_0
      22: getfield      #13                 // Field a:I
      25: aload_2
      26: getfield      #13                 // Field a:I
      29: if_icmpeq     34
      32: iconst_0
      33: ireturn
      34: aload_0
      35: getfield      #16                 // Field b:I
      38: aload_2
      39: getfield      #16                 // Field b:I
      42: if_icmpeq     47
      45: iconst_0
      46: ireturn
      47: aload_0
      48: getfield      #19                 // Field c:I
      51: aload_2
      52: getfield      #19                 // Field c:I
      55: if_icmpeq     60
      58: iconst_0
      59: ireturn
      60: iconst_1
      61: ireturn
}


/**
 * Given a collection of integers that might contain duplicates, nums, return all possible subsets (the power set).
 *
 * Note: The solution set must not contain duplicate subsets.
 *
 * For example,
 * If nums = [1,2,2], a solution is:
 *
 * [
 * [2],
 * [1],
 * [1,2,2],
 * [2,2],
 * [1,2],
 * []
 * ]
 *
 * Accepted.
 */
class SubsetsII {

    fun subsetsWithDup(nums: IntArray): List<List<Int>> {
        if (nums.isEmpty()) {
            return emptyList()
        }

        val lists = mutableListOf<List<Int>>()

        if (nums.size == 1) {
            // Add the empty list.
            lists.add(emptyList())

            lists.add(listOf(nums[0]))

            return lists
        }

        nums.sort()

        for (list in subsetsWithDup(nums.copyOfRange(0, nums.size - 1))) {
            val l = mutableListOf(nums[nums.size - 1])
            l.addAll(list)

            if (!lists.contains(l)) {
                lists.add(l)
            }

            if (!lists.contains(list)) {
                lists.add(list)
            }
        }

        return lists
    }

}

Compiled from "SubsetsII.kt"
public final class SubsetsII {
  public SubsetsII();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.util.List<java.lang.Integer>> subsetsWithDup(int[]);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: ifne          15
      11: iconst_1
      12: goto          16
      15: iconst_0
      16: ifeq          23
      19: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      22: areturn
      23: new           #30                 // class java/util/ArrayList
      26: dup
      27: invokespecial #31                 // Method java/util/ArrayList."<init>":()V
      30: checkcast     #33                 // class java/util/List
      33: astore_2
      34: aload_1
      35: arraylength
      36: iconst_1
      37: if_icmpne     68
      40: aload_2
      41: invokestatic  #28                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      44: invokeinterface #37,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      49: pop
      50: aload_2
      51: aload_1
      52: iconst_0
      53: iaload
      54: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: invokestatic  #47                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      60: invokeinterface #37,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      65: pop
      66: aload_2
      67: areturn
      68: aload_1
      69: invokestatic  #53                 // Method kotlin/collections/ArraysKt.sort:([I)V
      72: aload_0
      73: aload_1
      74: iconst_0
      75: aload_1
      76: arraylength
      77: iconst_1
      78: isub
      79: invokestatic  #57                 // Method kotlin/collections/ArraysKt.copyOfRange:([III)[I
      82: invokevirtual #59                 // Method subsetsWithDup:([I)Ljava/util/List;
      85: invokeinterface #63,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      90: astore_3
      91: aload_3
      92: invokeinterface #69,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      97: ifeq          193
     100: aload_3
     101: invokeinterface #73,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     106: checkcast     #33                 // class java/util/List
     109: astore        4
     111: iconst_1
     112: anewarray     #39                 // class java/lang/Integer
     115: astore        6
     117: aload         6
     119: iconst_0
     120: aload_1
     121: aload_1
     122: arraylength
     123: iconst_1
     124: isub
     125: iaload
     126: invokestatic  #43                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     129: aastore
     130: aload         6
     132: invokestatic  #77                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
     135: astore        5
     137: aload         5
     139: aload         4
     141: checkcast     #79                 // class java/util/Collection
     144: invokeinterface #83,  2           // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     149: pop
     150: aload_2
     151: aload         5
     153: invokeinterface #86,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     158: ifne          170
     161: aload_2
     162: aload         5
     164: invokeinterface #37,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     169: pop
     170: aload_2
     171: aload         4
     173: invokeinterface #86,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     178: ifne          91
     181: aload_2
     182: aload         4
     184: invokeinterface #37,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     189: pop
     190: goto          91
     193: aload_2
     194: areturn
}


/**
 * Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.
 * Return the sum of the three integers.
 * You may assume that each input would have exactly one solution.
 *
 * For example, given array S = {-1 2 1 -4}, and target = 1.
 *
 * The sum that is closest to the target is 2. (-1 + 2 + 1 = 2).
 *
 * Accepted.
 */
class ThreeSumClosest {

    fun threeSumClosest(nums: IntArray, target: Int): Int {
        nums.sort()

        var result = nums[0] + nums[1] + nums[2]
        for (i in 0 until nums.size - 2) {
            var l = i + 1
            var r = nums.size - 1
            while (l < r) {
                val tmp = nums[i] + nums[l] + nums[r]
                if (tmp == target) {
                    return tmp
                }
                if (Math.abs(tmp - target) < Math.abs(result - target)) {
                    result = tmp
                }
                if (tmp < target) {
                    l++
                } else if (tmp > target) {
                    r--
                }
            }
        }

        return result
    }

}

Compiled from "ThreeSumClosest.kt"
public final class ThreeSumClosest {
  public ThreeSumClosest();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int threeSumClosest(int[], int);
    Code:
       0: aload_1
       1: ldc           #15                 // String nums
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: invokestatic  #27                 // Method kotlin/collections/ArraysKt.sort:([I)V
      10: aload_1
      11: iconst_0
      12: iaload
      13: aload_1
      14: iconst_1
      15: iaload
      16: iadd
      17: aload_1
      18: iconst_2
      19: iaload
      20: iadd
      21: istore_3
      22: iconst_0
      23: istore        4
      25: aload_1
      26: arraylength
      27: iconst_2
      28: isub
      29: istore        5
      31: iload         4
      33: iload         5
      35: if_icmpge     131
      38: iload         4
      40: iconst_1
      41: iadd
      42: istore        6
      44: aload_1
      45: arraylength
      46: iconst_1
      47: isub
      48: istore        7
      50: iload         6
      52: iload         7
      54: if_icmpge     125
      57: aload_1
      58: iload         4
      60: iaload
      61: aload_1
      62: iload         6
      64: iaload
      65: iadd
      66: aload_1
      67: iload         7
      69: iaload
      70: iadd
      71: istore        8
      73: iload         8
      75: iload_2
      76: if_icmpne     82
      79: iload         8
      81: ireturn
      82: iload         8
      84: iload_2
      85: isub
      86: invokestatic  #33                 // Method java/lang/Math.abs:(I)I
      89: iload_3
      90: iload_2
      91: isub
      92: invokestatic  #33                 // Method java/lang/Math.abs:(I)I
      95: if_icmpge     101
      98: iload         8
     100: istore_3
     101: iload         8
     103: iload_2
     104: if_icmpge     113
     107: iinc          6, 1
     110: goto          50
     113: iload         8
     115: iload_2
     116: if_icmple     50
     119: iinc          7, -1
     122: goto          50
     125: iinc          4, 1
     128: goto          31
     131: iload_3
     132: ireturn
}


/**
 * Given a digit string, return all possible letter combinations that the number could represent.
 *
 * A mapping of digit to letters (just like on the telephone buttons) is given below.
 *
 * Input:Digit string "23"
 * Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"].
 * Note:
 * Although the above answer is in lexicographical order, your answer could be in any order you want.
 *
 * Accepted.
 */
class LetterCombinationsOfAPhoneNumber {

    fun letterCombinations(digits: String): List<String> {
        val dict = arrayOf(" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz")
        val results = mutableListOf<String>()

        if (digits.isEmpty()) {
            return emptyList()
        }

        if (digits.length == 1) {
            dict[Integer.valueOf(digits)].toCharArray()
                    .mapTo(results) {
                        it.toString()
                    }
            return results
        }

        val list = letterCombinations(digits.substring(1, digits.length))
        val sb = StringBuilder()

        for (c in dict[Integer.valueOf(digits.substring(0, 1))].toCharArray()) {
            for (s in list) {
                sb.append(c.toString()).append(s)
                results.add(sb.toString())
                sb.setLength(0)
            }
        }

        return results
    }

}

Compiled from "LetterCombinationsOfAPhoneNumber.kt"
public final class LetterCombinationsOfAPhoneNumber {
  public LetterCombinationsOfAPhoneNumber();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.lang.String> letterCombinations(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #16                 // String digits
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: bipush        10
       8: anewarray     #24                 // class java/lang/String
      11: astore_3
      12: aload_3
      13: iconst_0
      14: ldc           #26                 // String
      16: aastore
      17: aload_3
      18: iconst_1
      19: ldc           #28                 // String
      21: aastore
      22: aload_3
      23: iconst_2
      24: ldc           #30                 // String abc
      26: aastore
      27: aload_3
      28: iconst_3
      29: ldc           #32                 // String def
      31: aastore
      32: aload_3
      33: iconst_4
      34: ldc           #34                 // String ghi
      36: aastore
      37: aload_3
      38: iconst_5
      39: ldc           #36                 // String jkl
      41: aastore
      42: aload_3
      43: bipush        6
      45: ldc           #38                 // String mno
      47: aastore
      48: aload_3
      49: bipush        7
      51: ldc           #40                 // String pqrs
      53: aastore
      54: aload_3
      55: bipush        8
      57: ldc           #42                 // String tuv
      59: aastore
      60: aload_3
      61: bipush        9
      63: ldc           #44                 // String wxyz
      65: aastore
      66: aload_3
      67: astore_2
      68: new           #46                 // class java/util/ArrayList
      71: dup
      72: invokespecial #47                 // Method java/util/ArrayList."<init>":()V
      75: checkcast     #49                 // class java/util/List
      78: astore_3
      79: aload_1
      80: checkcast     #51                 // class java/lang/CharSequence
      83: invokeinterface #55,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      88: ifne          95
      91: iconst_1
      92: goto          96
      95: iconst_0
      96: ifeq          103
      99: invokestatic  #61                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     102: areturn
     103: aload_1
     104: invokevirtual #62                 // Method java/lang/String.length:()I
     107: iconst_1
     108: if_icmpne     206
     111: aload_2
     112: aload_1
     113: invokestatic  #68                 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;
     116: dup
     117: ldc           #70                 // String valueOf(...)
     119: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     122: checkcast     #75                 // class java/lang/Number
     125: invokevirtual #78                 // Method java/lang/Number.intValue:()I
     128: aaload
     129: invokevirtual #82                 // Method java/lang/String.toCharArray:()[C
     132: dup
     133: ldc           #84                 // String toCharArray(...)
     135: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     138: astore        4
     140: nop
     141: iconst_0
     142: istore        5
     144: iconst_0
     145: istore        6
     147: aload         4
     149: arraylength
     150: istore        7
     152: iload         6
     154: iload         7
     156: if_icmpge     199
     159: aload         4
     161: iload         6
     163: caload
     164: istore        8
     166: aload_3
     167: checkcast     #86                 // class java/util/Collection
     170: iload         8
     172: istore        9
     174: astore        12
     176: iconst_0
     177: istore        10
     179: iload         9
     181: invokestatic  #89                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     184: aload         12
     186: swap
     187: invokeinterface #93,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     192: pop
     193: iinc          6, 1
     196: goto          152
     199: aload_3
     200: checkcast     #86                 // class java/util/Collection
     203: pop
     204: aload_3
     205: areturn
     206: aload_0
     207: aload_1
     208: iconst_1
     209: aload_1
     210: invokevirtual #62                 // Method java/lang/String.length:()I
     213: invokevirtual #97                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     216: dup
     217: ldc           #99                 // String substring(...)
     219: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     222: invokevirtual #101                // Method letterCombinations:(Ljava/lang/String;)Ljava/util/List;
     225: astore        4
     227: new           #103                // class java/lang/StringBuilder
     230: dup
     231: invokespecial #104                // Method java/lang/StringBuilder."<init>":()V
     234: astore        5
     236: aload_2
     237: aload_1
     238: iconst_0
     239: iconst_1
     240: invokevirtual #97                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     243: dup
     244: ldc           #99                 // String substring(...)
     246: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     249: invokestatic  #68                 // Method java/lang/Integer.valueOf:(Ljava/lang/String;)Ljava/lang/Integer;
     252: dup
     253: ldc           #70                 // String valueOf(...)
     255: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     258: checkcast     #75                 // class java/lang/Number
     261: invokevirtual #78                 // Method java/lang/Number.intValue:()I
     264: aaload
     265: invokevirtual #82                 // Method java/lang/String.toCharArray:()[C
     268: dup
     269: ldc           #84                 // String toCharArray(...)
     271: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     274: astore        6
     276: iconst_0
     277: istore        7
     279: aload         6
     281: arraylength
     282: istore        8
     284: iload         7
     286: iload         8
     288: if_icmpge     378
     291: aload         6
     293: iload         7
     295: caload
     296: istore        9
     298: aload         4
     300: invokeinterface #108,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     305: astore        10
     307: aload         10
     309: invokeinterface #114,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
     314: ifeq          372
     317: aload         10
     319: invokeinterface #118,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     324: checkcast     #24                 // class java/lang/String
     327: astore        11
     329: aload         5
     331: iload         9
     333: invokestatic  #89                 // Method java/lang/String.valueOf:(C)Ljava/lang/String;
     336: invokevirtual #122                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     339: aload         11
     341: invokevirtual #122                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     344: pop
     345: aload_3
     346: aload         5
     348: invokevirtual #126                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     351: dup
     352: ldc           #128                // String toString(...)
     354: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     357: invokeinterface #129,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     362: pop
     363: aload         5
     365: iconst_0
     366: invokevirtual #133                // Method java/lang/StringBuilder.setLength:(I)V
     369: goto          307
     372: iinc          7, 1
     375: goto          284
     378: aload_3
     379: areturn
}


import java.util.Arrays

/**
 * Follow up for "Search in Rotated Sorted Array":
 * What if duplicates are allowed?
 *
 * Would this affect the run-time complexity? How and why?
 *
 * Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
 *
 * (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
 *
 * Write nums function to determine if nums given target is in the array.
 *
 * The array may contain duplicates.
 *
 * Accepted.
 */
class SearchInRotatedSortedArrayII {

    fun search(nums: IntArray, target: Int): Boolean {
        if (nums.isEmpty()) {
            return false
        }

        var start = 0
        var end = nums.size - 1
        while (start <= end) {
            val mid = start + (end - start) / 2
            if (nums[mid] == target) {
                return true
            }
            if (nums[mid] < nums[end]) { // right half sorted
                if (target > nums[mid] && target <= nums[end]) {
                    return Arrays.binarySearch(nums, mid, end + 1, target) >= 0
                } else {
                    end = mid - 1
                }
            } else if (nums[mid] > nums[end]) {  // left half sorted
                if (target >= nums[start] && target < nums[mid]) {
                    return Arrays.binarySearch(nums, start, mid + 1, target) >= 0
                } else {
                    start = mid + 1
                }
            } else {
                end--
            }
        }
        return false
    }

}

Compiled from "SearchInRotatedSortedArrayII.kt"
public final class SearchInRotatedSortedArrayII {
  public SearchInRotatedSortedArrayII();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final boolean search(int[], int);
    Code:
       0: aload_1
       1: ldc           #15                 // String nums
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: ifne          15
      11: iconst_1
      12: goto          16
      15: iconst_0
      16: ifeq          21
      19: iconst_0
      20: ireturn
      21: iconst_0
      22: istore_3
      23: aload_1
      24: arraylength
      25: iconst_1
      26: isub
      27: istore        4
      29: iload_3
      30: iload         4
      32: if_icmpgt     173
      35: iload_3
      36: iload         4
      38: iload_3
      39: isub
      40: iconst_2
      41: idiv
      42: iadd
      43: istore        5
      45: aload_1
      46: iload         5
      48: iaload
      49: iload_2
      50: if_icmpne     55
      53: iconst_1
      54: ireturn
      55: aload_1
      56: iload         5
      58: iaload
      59: aload_1
      60: iload         4
      62: iaload
      63: if_icmpge     111
      66: iload_2
      67: aload_1
      68: iload         5
      70: iaload
      71: if_icmple     102
      74: iload_2
      75: aload_1
      76: iload         4
      78: iaload
      79: if_icmpgt     102
      82: aload_1
      83: iload         5
      85: iload         4
      87: iconst_1
      88: iadd
      89: iload_2
      90: invokestatic  #27                 // Method java/util/Arrays.binarySearch:([IIII)I
      93: iflt          100
      96: iconst_1
      97: goto          101
     100: iconst_0
     101: ireturn
     102: iload         5
     104: iconst_1
     105: isub
     106: istore        4
     108: goto          29
     111: aload_1
     112: iload         5
     114: iaload
     115: aload_1
     116: iload         4
     118: iaload
     119: if_icmple     164
     122: iload_2
     123: aload_1
     124: iload_3
     125: iaload
     126: if_icmplt     156
     129: iload_2
     130: aload_1
     131: iload         5
     133: iaload
     134: if_icmpge     156
     137: aload_1
     138: iload_3
     139: iload         5
     141: iconst_1
     142: iadd
     143: iload_2
     144: invokestatic  #27                 // Method java/util/Arrays.binarySearch:([IIII)I
     147: iflt          154
     150: iconst_1
     151: goto          155
     154: iconst_0
     155: ireturn
     156: iload         5
     158: iconst_1
     159: iadd
     160: istore_3
     161: goto          29
     164: iload         4
     166: iinc          4, -1
     169: pop
     170: goto          29
     173: iconst_0
     174: ireturn
}


/**
 * Given a collection of distinct numbers, return all possible permutations.
 *
 * For example,
 * [1,2,3] have the following permutations:
 * [
 * [1,2,3],
 * [1,3,2],
 * [2,1,3],
 * [2,3,1],
 * [3,1,2],
 * [3,2,1]
 * ]
 *
 * Accepted.
 */
class Permutations {

    fun permute(nums: IntArray): List<List<Int>> {
        val results = mutableListOf<List<Int>>()

        if (nums.isEmpty()) {
            return results
        }
        if (nums.size == 1) {
            return results.apply {
                add(mutableListOf(nums[0]))
            }
        }

        val ints = IntArray(nums.size - 1)
        System.arraycopy(nums, 0, ints, 0, nums.size - 1)

        for (list in permute(ints)) {
            for (i in 0..list.size) {
                val tmp = mutableListOf<Int>()
                tmp.addAll(list)
                tmp.add(i, nums[nums.size - 1])
                results.add(tmp)
            }
        }

        return results
    }

}

Compiled from "Permutations.kt"
public final class Permutations {
  public Permutations();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.util.List<java.lang.Integer>> permute(int[]);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class java/util/ArrayList
       9: dup
      10: invokespecial #25                 // Method java/util/ArrayList."<init>":()V
      13: checkcast     #27                 // class java/util/List
      16: astore_2
      17: aload_1
      18: arraylength
      19: ifne          26
      22: iconst_1
      23: goto          27
      26: iconst_0
      27: ifeq          32
      30: aload_2
      31: areturn
      32: aload_1
      33: arraylength
      34: iconst_1
      35: if_icmpne     78
      38: aload_2
      39: astore_3
      40: aload_3
      41: astore        4
      43: iconst_0
      44: istore        5
      46: aload         4
      48: iconst_1
      49: anewarray     #29                 // class java/lang/Integer
      52: astore        6
      54: aload         6
      56: iconst_0
      57: aload_1
      58: iconst_0
      59: iaload
      60: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: aastore
      64: aload         6
      66: invokestatic  #39                 // Method kotlin/collections/CollectionsKt.mutableListOf:([Ljava/lang/Object;)Ljava/util/List;
      69: invokeinterface #43,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
      74: pop
      75: nop
      76: aload_3
      77: areturn
      78: aload_1
      79: arraylength
      80: iconst_1
      81: isub
      82: newarray       int
      84: astore_3
      85: aload_1
      86: iconst_0
      87: aload_3
      88: iconst_0
      89: aload_1
      90: arraylength
      91: iconst_1
      92: isub
      93: invokestatic  #49                 // Method java/lang/System.arraycopy:(Ljava/lang/Object;ILjava/lang/Object;II)V
      96: aload_0
      97: aload_3
      98: invokevirtual #51                 // Method permute:([I)Ljava/util/List;
     101: invokeinterface #55,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     106: astore        4
     108: aload         4
     110: invokeinterface #61,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     115: ifeq          214
     118: aload         4
     120: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     125: checkcast     #27                 // class java/util/List
     128: astore        5
     130: iconst_0
     131: istore        6
     133: aload         5
     135: invokeinterface #69,  1           // InterfaceMethod java/util/List.size:()I
     140: istore        7
     142: iload         6
     144: iload         7
     146: if_icmpgt     108
     149: new           #24                 // class java/util/ArrayList
     152: dup
     153: invokespecial #25                 // Method java/util/ArrayList."<init>":()V
     156: checkcast     #27                 // class java/util/List
     159: astore        8
     161: aload         8
     163: aload         5
     165: checkcast     #71                 // class java/util/Collection
     168: invokeinterface #75,  2           // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     173: pop
     174: aload         8
     176: iload         6
     178: aload_1
     179: aload_1
     180: arraylength
     181: iconst_1
     182: isub
     183: iaload
     184: invokestatic  #33                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     187: invokeinterface #78,  3           // InterfaceMethod java/util/List.add:(ILjava/lang/Object;)V
     192: aload_2
     193: aload         8
     195: invokeinterface #43,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     200: pop
     201: iload         6
     203: iload         7
     205: if_icmpeq     108
     208: iinc          6, 1
     211: goto          149
     214: aload_2
     215: areturn
}


/**
 * Given a m x n grid filled with non-negative numbers,
 * find a path from top left to bottom right which minimizes the sum of all numbers along its path.
 *
 * Note: You can only move either down or right at any point in time.
 *
 * Example 1:
 * [[1,3,1],
 * [1,5,1],
 * [4,2,1]]
 * Given the above grid map, return 7. Because the path 1→3→1→1→1 minimizes the sum.
 *
 * Accepted.
 */
class MinimumPathSum {

    fun minPathSum(grid: Array<IntArray>): Int {
        if (grid.isEmpty()) {
            return 0
        }
        if (grid.size == 1) {
            if (grid[0].isEmpty()) {
                return 0
            }
            if (grid[0].size == 1) {
                return grid[0][0]
            }
        }

        val matrix = Array(grid.size) {
            IntArray(grid[0].size)
        }
        matrix[0][0] = grid[0][0]

        (1 until grid.size).forEach {
            matrix[it][0] = matrix[it - 1][0] + grid[it][0]
        }

        (1 until grid[0].size).forEach {
            matrix[0][it] = matrix[0][it - 1] + grid[0][it]
        }

        (1 until grid.size).forEach { i ->
            (1 until grid[0].size).forEach {
                matrix[i][it] = Math.min(matrix[i - 1][it] + grid[i][it], matrix[i][it - 1] + grid[i][it])
            }
        }

        return matrix[grid.size - 1][grid[0].size - 1]
    }

}

Compiled from "MinimumPathSum.kt"
public final class MinimumPathSum {
  public MinimumPathSum();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int minPathSum(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String grid
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #23                 // class "[Ljava/lang/Object;"
      10: arraylength
      11: ifne          18
      14: iconst_1
      15: goto          19
      18: iconst_0
      19: ifeq          24
      22: iconst_0
      23: ireturn
      24: aload_1
      25: checkcast     #23                 // class "[Ljava/lang/Object;"
      28: arraylength
      29: iconst_1
      30: if_icmpne     64
      33: aload_1
      34: iconst_0
      35: aaload
      36: arraylength
      37: ifne          44
      40: iconst_1
      41: goto          45
      44: iconst_0
      45: ifeq          50
      48: iconst_0
      49: ireturn
      50: aload_1
      51: iconst_0
      52: aaload
      53: arraylength
      54: iconst_1
      55: if_icmpne     64
      58: aload_1
      59: iconst_0
      60: aaload
      61: iconst_0
      62: iaload
      63: ireturn
      64: iconst_0
      65: istore_3
      66: aload_1
      67: checkcast     #23                 // class "[Ljava/lang/Object;"
      70: arraylength
      71: istore        4
      73: iload         4
      75: anewarray     #25                 // class "[I"
      78: astore        5
      80: iload_3
      81: iload         4
      83: if_icmpge     106
      86: iload_3
      87: istore        6
      89: aload         5
      91: iload         6
      93: aload_1
      94: iconst_0
      95: aaload
      96: arraylength
      97: newarray       int
      99: aastore
     100: iinc          3, 1
     103: goto          80
     106: aload         5
     108: astore_2
     109: aload_2
     110: iconst_0
     111: aaload
     112: iconst_0
     113: aload_1
     114: iconst_0
     115: aaload
     116: iconst_0
     117: iaload
     118: iastore
     119: iconst_1
     120: aload_1
     121: checkcast     #23                 // class "[Ljava/lang/Object;"
     124: arraylength
     125: invokestatic  #31                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     128: checkcast     #33                 // class java/lang/Iterable
     131: astore_3
     132: iconst_0
     133: istore        4
     135: aload_3
     136: invokeinterface #37,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     141: astore        5
     143: aload         5
     145: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          196
     153: aload         5
     155: checkcast     #45                 // class kotlin/collections/IntIterator
     158: invokevirtual #49                 // Method kotlin/collections/IntIterator.nextInt:()I
     161: istore        6
     163: iload         6
     165: istore        7
     167: iconst_0
     168: istore        8
     170: aload_2
     171: iload         7
     173: aaload
     174: iconst_0
     175: aload_2
     176: iload         7
     178: iconst_1
     179: isub
     180: aaload
     181: iconst_0
     182: iaload
     183: aload_1
     184: iload         7
     186: aaload
     187: iconst_0
     188: iaload
     189: iadd
     190: iastore
     191: nop
     192: nop
     193: goto          143
     196: nop
     197: iconst_1
     198: aload_1
     199: iconst_0
     200: aaload
     201: arraylength
     202: invokestatic  #31                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     205: checkcast     #33                 // class java/lang/Iterable
     208: astore_3
     209: iconst_0
     210: istore        4
     212: aload_3
     213: invokeinterface #37,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     218: astore        5
     220: aload         5
     222: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     227: ifeq          273
     230: aload         5
     232: checkcast     #45                 // class kotlin/collections/IntIterator
     235: invokevirtual #49                 // Method kotlin/collections/IntIterator.nextInt:()I
     238: istore        6
     240: iload         6
     242: istore        7
     244: iconst_0
     245: istore        8
     247: aload_2
     248: iconst_0
     249: aaload
     250: iload         7
     252: aload_2
     253: iconst_0
     254: aaload
     255: iload         7
     257: iconst_1
     258: isub
     259: iaload
     260: aload_1
     261: iconst_0
     262: aaload
     263: iload         7
     265: iaload
     266: iadd
     267: iastore
     268: nop
     269: nop
     270: goto          220
     273: nop
     274: iconst_1
     275: aload_1
     276: checkcast     #23                 // class "[Ljava/lang/Object;"
     279: arraylength
     280: invokestatic  #31                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     283: checkcast     #33                 // class java/lang/Iterable
     286: astore_3
     287: iconst_0
     288: istore        4
     290: aload_3
     291: invokeinterface #37,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     296: astore        5
     298: aload         5
     300: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     305: ifeq          432
     308: aload         5
     310: checkcast     #45                 // class kotlin/collections/IntIterator
     313: invokevirtual #49                 // Method kotlin/collections/IntIterator.nextInt:()I
     316: istore        6
     318: iload         6
     320: istore        7
     322: iconst_0
     323: istore        8
     325: iconst_1
     326: aload_1
     327: iconst_0
     328: aaload
     329: arraylength
     330: invokestatic  #31                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     333: checkcast     #33                 // class java/lang/Iterable
     336: astore        9
     338: iconst_0
     339: istore        10
     341: aload         9
     343: invokeinterface #37,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     348: astore        11
     350: aload         11
     352: invokeinterface #43,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     357: ifeq          426
     360: aload         11
     362: checkcast     #45                 // class kotlin/collections/IntIterator
     365: invokevirtual #49                 // Method kotlin/collections/IntIterator.nextInt:()I
     368: istore        12
     370: iload         12
     372: istore        13
     374: iconst_0
     375: istore        14
     377: aload_2
     378: iload         7
     380: aaload
     381: iload         13
     383: aload_2
     384: iload         7
     386: iconst_1
     387: isub
     388: aaload
     389: iload         13
     391: iaload
     392: aload_1
     393: iload         7
     395: aaload
     396: iload         13
     398: iaload
     399: iadd
     400: aload_2
     401: iload         7
     403: aaload
     404: iload         13
     406: iconst_1
     407: isub
     408: iaload
     409: aload_1
     410: iload         7
     412: aaload
     413: iload         13
     415: iaload
     416: iadd
     417: invokestatic  #55                 // Method java/lang/Math.min:(II)I
     420: iastore
     421: nop
     422: nop
     423: goto          350
     426: nop
     427: nop
     428: nop
     429: goto          298
     432: nop
     433: aload_2
     434: aload_1
     435: checkcast     #23                 // class "[Ljava/lang/Object;"
     438: arraylength
     439: iconst_1
     440: isub
     441: aaload
     442: aload_1
     443: iconst_0
     444: aaload
     445: arraylength
     446: iconst_1
     447: isub
     448: iaload
     449: ireturn
}


/**
 * Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
 *
 * If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
 *
 * The replacement must be in-place, do not allocate extra memory.
 *
 * Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
 * 1,2,3 → 1,3,2
 * 3,2,1 → 1,2,3
 * 1,1,5 → 1,5,1
 *
 * Accepted.
 */
class NextPermutation {

    fun nextPermutation(nums: IntArray) {
        var i = nums.size - 2
        while (i >= 0 && nums[i] >= nums[i + 1]) {
            i--
        }
        if (i >= 0) {
            var j = nums.size - 1
            while (nums[j] <= nums[i]) {
                j--
            }
            swap(nums, i, j)
        }
        reverse(nums, i + 1, nums.size - 1)
    }

    private fun swap(nums: IntArray, i: Int, j: Int) {
        val tmp = nums[i]
        nums[i] = nums[j]
        nums[j] = tmp
    }

    private fun reverse(nums: IntArray, i: Int, j: Int) {
        var tmpI = i
        var tmpJ = j
        while (tmpI < tmpJ) {
            swap(nums, tmpI++, tmpJ--)
        }
    }

}

Compiled from "NextPermutation.kt"
public final class NextPermutation {
  public NextPermutation();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final void nextPermutation(int[]);
    Code:
       0: aload_1
       1: ldc           #15                 // String nums
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: arraylength
       8: iconst_2
       9: isub
      10: istore_2
      11: iload_2
      12: iflt          32
      15: aload_1
      16: iload_2
      17: iaload
      18: aload_1
      19: iload_2
      20: iconst_1
      21: iadd
      22: iaload
      23: if_icmplt     32
      26: iinc          2, -1
      29: goto          11
      32: iload_2
      33: iflt          63
      36: aload_1
      37: arraylength
      38: iconst_1
      39: isub
      40: istore_3
      41: aload_1
      42: iload_3
      43: iaload
      44: aload_1
      45: iload_2
      46: iaload
      47: if_icmpgt     56
      50: iinc          3, -1
      53: goto          41
      56: aload_0
      57: aload_1
      58: iload_2
      59: iload_3
      60: invokespecial #25                 // Method swap:([III)V
      63: aload_0
      64: aload_1
      65: iload_2
      66: iconst_1
      67: iadd
      68: aload_1
      69: arraylength
      70: iconst_1
      71: isub
      72: invokespecial #28                 // Method reverse:([III)V
      75: return

  private final void swap(int[], int, int);
    Code:
       0: aload_1
       1: iload_2
       2: iaload
       3: istore        4
       5: aload_1
       6: iload_2
       7: aload_1
       8: iload_3
       9: iaload
      10: iastore
      11: aload_1
      12: iload_3
      13: iload         4
      15: iastore
      16: return

  private final void reverse(int[], int, int);
    Code:
       0: iload_2
       1: istore        4
       3: iload_3
       4: istore        5
       6: iload         4
       8: iload         5
      10: if_icmpge     31
      13: aload_0
      14: aload_1
      15: iload         4
      17: iinc          4, 1
      20: iload         5
      22: iinc          5, -1
      25: invokespecial #25                 // Method swap:([III)V
      28: goto          6
      31: return
}


/**
 * Given n, how many structurally unique BST's (binary search trees) that store values 1...n?
 *
 * For example,
 * Given n = 3, there are a total of 5 unique BST's.
 *
 * 1        3     3      2      1
 * \       /     /      / \      \
 * 3      2     1      1   3      2
 * /     /      \                 \
 * 2    1       2                 3
 *
 * Two solutions are all accepted.
 */
class UniqueBinarySearchTrees {

    // Recursive solution. Accepted.
    /*fun numTrees(n: Int): Int {
        if (n == 0 || n == 1) return 1

        return (1..n).sumBy {
            numTrees(it - 1) * numTrees(n - it)
        }
    }*/

    // Dynamic programming.
    fun numTrees(n: Int): Int {
        val array = IntArray(n + 2, { 0 })
        array[0] = 1
        array[1] = 1

        for (i in 2..n) {
            for (j in 0 until i) {
                array[i] += array[j] * array[i - j - 1]
            }
        }

        return array[n]
    }

}

Compiled from "UniqueBinarySearchTrees.kt"
public final class UniqueBinarySearchTrees {
  public UniqueBinarySearchTrees();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final int numTrees(int);
    Code:
       0: iconst_0
       1: istore_3
       2: iload_1
       3: iconst_2
       4: iadd
       5: istore        4
       7: iload         4
       9: newarray       int
      11: astore        5
      13: iload_3
      14: iload         4
      16: if_icmpge     34
      19: iload_3
      20: istore        6
      22: aload         5
      24: iload         6
      26: iconst_0
      27: iastore
      28: iinc          3, 1
      31: goto          13
      34: aload         5
      36: astore_2
      37: aload_2
      38: iconst_0
      39: iconst_1
      40: iastore
      41: aload_2
      42: iconst_1
      43: iconst_1
      44: iastore
      45: iconst_2
      46: istore_3
      47: iload_3
      48: iload_1
      49: if_icmpgt     103
      52: iconst_0
      53: istore        4
      55: iload         4
      57: iload_3
      58: if_icmpge     92
      61: iload_3
      62: istore        5
      64: aload_2
      65: iload         5
      67: aload_2
      68: iload         5
      70: iaload
      71: aload_2
      72: iload         4
      74: iaload
      75: aload_2
      76: iload_3
      77: iload         4
      79: isub
      80: iconst_1
      81: isub
      82: iaload
      83: imul
      84: iadd
      85: iastore
      86: iinc          4, 1
      89: goto          55
      92: iload_3
      93: iload_1
      94: if_icmpeq     103
      97: iinc          3, 1
     100: goto          52
     103: aload_2
     104: iload_1
     105: iaload
     106: ireturn
}


/**
 * Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
 *
 * For example,
 * If n = 4 and k = 2, a solution is:
 *
 * [
 * [2,4],
 * [3,4],
 * [2,3],
 * [1,2],
 * [1,3],
 * [1,4],
 * ]
 */
class Combinations {

    // Iterative solution.
    // Accepted.
    fun combine(n: Int, k: Int): List<List<Int>> {
        var results = mutableListOf<List<Int>>()
        if (n == 0 || k == 0 || k > n) {
            return results
        }

        (1..n + 1 - k).mapTo(results) {
            listOf(it)
        }

        for (i in 2..k) {
            val tmp = mutableListOf<List<Int>>()
            for (list in results) {
                for (m in list[list.size - 1] + 1..n - (k - i)) {
                    val newList = mutableListOf<Int>()
                    newList.addAll(list)
                    newList.add(m)
                    tmp.add(newList)
                }
            }
            results = tmp
        }
        return results
    }

    // Recursive solution.
    // Accepted.
    /*fun combine(n: Int, k: Int): List<List<Int>> {
        val results = mutableListOf<List<Int>>()
        if (n == 0 || k == 0 || k > n) {
            return results
        }

        if (k == 1) {
            (1..n).mapTo(results) {
                listOf(it)
            }
            return results
        }

        for (list in combine(n, k - 1)) {
            for (i in list[list.size - 1] until n) {
                val tmp = mutableListOf<Int>()
                tmp.addAll(list)
                tmp.add(i + 1)
                results.add(tmp)
            }
        }

        return results*/

}

Compiled from "Combinations.kt"
public final class Combinations {
  public Combinations();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.util.List<java.lang.Integer>> combine(int, int);
    Code:
       0: new           #16                 // class java/util/ArrayList
       3: dup
       4: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
       7: checkcast     #19                 // class java/util/List
      10: astore_3
      11: iload_1
      12: ifeq          24
      15: iload_2
      16: ifeq          24
      19: iload_2
      20: iload_1
      21: if_icmple     26
      24: aload_3
      25: areturn
      26: new           #21                 // class kotlin/ranges/IntRange
      29: dup
      30: iconst_1
      31: iload_1
      32: iconst_1
      33: iadd
      34: iload_2
      35: isub
      36: invokespecial #24                 // Method kotlin/ranges/IntRange."<init>":(II)V
      39: checkcast     #26                 // class java/lang/Iterable
      42: astore        4
      44: iconst_0
      45: istore        5
      47: aload         4
      49: invokeinterface #30,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      54: astore        6
      56: aload         6
      58: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      63: ifeq          109
      66: aload         6
      68: checkcast     #38                 // class kotlin/collections/IntIterator
      71: invokevirtual #42                 // Method kotlin/collections/IntIterator.nextInt:()I
      74: istore        7
      76: aload_3
      77: checkcast     #44                 // class java/util/Collection
      80: iload         7
      82: istore        8
      84: astore        11
      86: iconst_0
      87: istore        9
      89: iload         8
      91: invokestatic  #50                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      94: invokestatic  #56                 // Method kotlin/collections/CollectionsKt.listOf:(Ljava/lang/Object;)Ljava/util/List;
      97: aload         11
      99: swap
     100: invokeinterface #60,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     105: pop
     106: goto          56
     109: aload_3
     110: checkcast     #44                 // class java/util/Collection
     113: pop
     114: iconst_2
     115: istore        4
     117: iload         4
     119: iload_2
     120: if_icmpgt     282
     123: new           #16                 // class java/util/ArrayList
     126: dup
     127: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
     130: checkcast     #19                 // class java/util/List
     133: astore        5
     135: aload_3
     136: invokeinterface #61,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     141: astore        6
     143: aload         6
     145: invokeinterface #36,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     150: ifeq          267
     153: aload         6
     155: invokeinterface #65,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     160: checkcast     #19                 // class java/util/List
     163: astore        7
     165: aload         7
     167: aload         7
     169: invokeinterface #68,  1           // InterfaceMethod java/util/List.size:()I
     174: iconst_1
     175: isub
     176: invokeinterface #72,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     181: checkcast     #74                 // class java/lang/Number
     184: invokevirtual #77                 // Method java/lang/Number.intValue:()I
     187: iconst_1
     188: iadd
     189: istore        8
     191: iload_1
     192: iload_2
     193: iload         4
     195: isub
     196: isub
     197: istore        9
     199: iload         8
     201: iload         9
     203: if_icmpgt     143
     206: new           #16                 // class java/util/ArrayList
     209: dup
     210: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
     213: checkcast     #19                 // class java/util/List
     216: astore        10
     218: aload         10
     220: aload         7
     222: checkcast     #44                 // class java/util/Collection
     225: invokeinterface #81,  2           // InterfaceMethod java/util/List.addAll:(Ljava/util/Collection;)Z
     230: pop
     231: aload         10
     233: iload         8
     235: invokestatic  #50                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     238: invokeinterface #82,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     243: pop
     244: aload         5
     246: aload         10
     248: invokeinterface #82,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     253: pop
     254: iload         8
     256: iload         9
     258: if_icmpeq     143
     261: iinc          8, 1
     264: goto          206
     267: aload         5
     269: astore_3
     270: iload         4
     272: iload_2
     273: if_icmpeq     282
     276: iinc          4, 1
     279: goto          123
     282: aload_3
     283: areturn
}


/**
 * Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target?
 * Find all unique quadruplets in the array which gives the sum of target.
 *
 * Note: The solution set must not contain duplicate quadruplets.
 *
 * For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0.
 *
 * A solution set is:
 * [
 * [-1,  0, 0, 1],
 * [-2, -1, 1, 2],
 * [-2,  0, 0, 2]
 * ]
 *
 * Accepted.
 */
class FourSum {

    // Accepted. 1600ms.
    /*fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
        val set = mutableSetOf<List<Int>>()
        nums.sort()

        for (i in 0 until nums.size - 3) {
            for (j in i + 1 until nums.size - 2) {
                for (k in j + 1 until nums.size - 1) {
                    for (m in k + 1 until nums.size) {
                        val sum = nums[i] + nums[j] + nums[k] + nums[m]
                        if (sum > target) {
                            continue
                        }
                        if (sum == target) {
                            set.add(listOf(nums[i], nums[j], nums[k], nums[m]))
                        }
                    }
                }
            }
        }

        return ArrayList(set)
    }*/

    fun fourSum(nums: IntArray, target: Int): List<List<Int>> {
        val results = mutableListOf<List<Int>>()
        nums.sort()

        for (i in 0 until nums.size - 3) {
            for (j in i + 1 until nums.size - 2) {
                var left = j + 1
                var right = nums.size - 1
                while (left < right) {
                    val sum = nums[i] + nums[j] + nums[left] + nums[right]
                    when {
                        sum == target -> {
                            val tmp = ArrayList<Int>(4)
                            tmp.add(nums[i])
                            tmp.add(nums[j])
                            tmp.add(nums[left])
                            tmp.add(nums[right])
                            if (!results.contains(tmp)) {
                                results.add(tmp)
                            }
                            left++
                            right--
                        }
                        sum < target -> left++
                        else -> right--
                    }
                }
            }
        }

        return results
    }

}

Compiled from "FourSum.kt"
public final class FourSum {
  public FourSum();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.util.List<java.lang.Integer>> fourSum(int[], int);
    Code:
       0: aload_1
       1: ldc           #16                 // String nums
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #24                 // class java/util/ArrayList
       9: dup
      10: invokespecial #25                 // Method java/util/ArrayList."<init>":()V
      13: checkcast     #27                 // class java/util/List
      16: astore_3
      17: aload_1
      18: invokestatic  #33                 // Method kotlin/collections/ArraysKt.sort:([I)V
      21: iconst_0
      22: istore        4
      24: aload_1
      25: arraylength
      26: iconst_3
      27: isub
      28: istore        5
      30: iload         4
      32: iload         5
      34: if_icmpge     224
      37: iload         4
      39: iconst_1
      40: iadd
      41: istore        6
      43: aload_1
      44: arraylength
      45: iconst_2
      46: isub
      47: istore        7
      49: iload         6
      51: iload         7
      53: if_icmpge     218
      56: iload         6
      58: iconst_1
      59: iadd
      60: istore        8
      62: aload_1
      63: arraylength
      64: iconst_1
      65: isub
      66: istore        9
      68: iload         8
      70: iload         9
      72: if_icmpge     212
      75: aload_1
      76: iload         4
      78: iaload
      79: aload_1
      80: iload         6
      82: iaload
      83: iadd
      84: aload_1
      85: iload         8
      87: iaload
      88: iadd
      89: aload_1
      90: iload         9
      92: iaload
      93: iadd
      94: istore        10
      96: nop
      97: iload         10
      99: iload_2
     100: if_icmpne     194
     103: new           #24                 // class java/util/ArrayList
     106: dup
     107: iconst_4
     108: invokespecial #36                 // Method java/util/ArrayList."<init>":(I)V
     111: astore        11
     113: aload         11
     115: aload_1
     116: iload         4
     118: iaload
     119: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     122: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     125: pop
     126: aload         11
     128: aload_1
     129: iload         6
     131: iaload
     132: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     135: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     138: pop
     139: aload         11
     141: aload_1
     142: iload         8
     144: iaload
     145: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     148: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     151: pop
     152: aload         11
     154: aload_1
     155: iload         9
     157: iaload
     158: invokestatic  #42                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     161: invokevirtual #46                 // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
     164: pop
     165: aload_3
     166: aload         11
     168: invokeinterface #49,  2           // InterfaceMethod java/util/List.contains:(Ljava/lang/Object;)Z
     173: ifne          185
     176: aload_3
     177: aload         11
     179: invokeinterface #50,  2           // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     184: pop
     185: iinc          8, 1
     188: iinc          9, -1
     191: goto          68
     194: iload         10
     196: iload_2
     197: if_icmpge     206
     200: iinc          8, 1
     203: goto          68
     206: iinc          9, -1
     209: goto          68
     212: iinc          6, 1
     215: goto          49
     218: iinc          4, 1
     221: goto          30
     224: aload_3
     225: areturn
}


/**
 * Given a 2D board and a word, find if the word exists in the grid.
 *
 * The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring.
 * The same letter cell may not be used more than once.
 *
 * For example,
 * Given board =
 *
 * [
 * ['A','B','C','E'],
 * ['S','F','C','S'],
 * ['A','D','E','E']
 * ]
 * word = "ABCCED", -> returns true,
 * word = "SEE", -> returns true,
 * word = "ABCB", -> returns false.
 *
 * Accepted.
 */
class WordSearch {

    fun exist(board: Array<CharArray>, word: String): Boolean {
        if (board.isEmpty() || board[0].isEmpty()) {
            return false
        }
        for (i in board.indices) {
            (0 until board[0].size)
                    .filter {
                        search(board, i, it, word, 0)
                    }
                    .forEach {
                        return true
                    }
        }
        return false
    }

    private fun search(board: Array<CharArray>, i: Int, j: Int, word: String, index: Int): Boolean {
        if (index >= word.length) {
            return true
        }
        if (i < 0 || i >= board.size || j < 0 || j >= board[0].size || board[i][j] != word[index]) {
            return false
        }

        board[i][j] = (board[i][j].toInt() xor 255).toChar()
        val res = (search(board, i - 1, j, word, index + 1)
                || search(board, i + 1, j, word, index + 1)
                || search(board, i, j - 1, word, index + 1)
                || search(board, i, j + 1, word, index + 1))

        board[i][j] = (board[i][j].toInt() xor 255).toChar()

        return res
    }

}

Compiled from "WordSearch.kt"
public final class WordSearch {
  public WordSearch();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final boolean exist(char[][], java.lang.String);
    Code:
       0: aload_1
       1: ldc           #15                 // String board
       3: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_2
       7: ldc           #23                 // String word
       9: invokestatic  #21                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: aload_1
      13: checkcast     #25                 // class "[Ljava/lang/Object;"
      16: arraylength
      17: ifne          24
      20: iconst_1
      21: goto          25
      24: iconst_0
      25: ifne          43
      28: aload_1
      29: iconst_0
      30: aaload
      31: arraylength
      32: ifne          39
      35: iconst_1
      36: goto          40
      39: iconst_0
      40: ifeq          45
      43: iconst_0
      44: ireturn
      45: iconst_0
      46: istore_3
      47: aload_1
      48: checkcast     #25                 // class "[Ljava/lang/Object;"
      51: arraylength
      52: istore        4
      54: iload_3
      55: iload         4
      57: if_icmpge     228
      60: iconst_0
      61: aload_1
      62: iconst_0
      63: aaload
      64: arraylength
      65: invokestatic  #31                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      68: checkcast     #33                 // class java/lang/Iterable
      71: astore        5
      73: nop
      74: iconst_0
      75: istore        6
      77: aload         5
      79: astore        7
      81: new           #35                 // class java/util/ArrayList
      84: dup
      85: invokespecial #36                 // Method java/util/ArrayList."<init>":()V
      88: checkcast     #38                 // class java/util/Collection
      91: astore        8
      93: iconst_0
      94: istore        9
      96: aload         7
      98: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     103: astore        10
     105: aload         10
     107: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     112: ifeq          163
     115: aload         10
     117: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     122: astore        11
     124: aload         11
     126: checkcast     #54                 // class java/lang/Number
     129: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     132: istore        12
     134: iconst_0
     135: istore        13
     137: aload_0
     138: aload_1
     139: iload_3
     140: iload         12
     142: aload_2
     143: iconst_0
     144: invokespecial #62                 // Method search:([[CIILjava/lang/String;I)Z
     147: ifeq          105
     150: aload         8
     152: aload         11
     154: invokeinterface #66,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     159: pop
     160: goto          105
     163: aload         8
     165: checkcast     #68                 // class java/util/List
     168: nop
     169: checkcast     #33                 // class java/lang/Iterable
     172: astore        5
     174: nop
     175: iconst_0
     176: istore        6
     178: aload         5
     180: invokeinterface #42,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
     185: astore        7
     187: aload         7
     189: invokeinterface #48,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     194: ifeq          221
     197: aload         7
     199: invokeinterface #52,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     204: astore        8
     206: aload         8
     208: checkcast     #54                 // class java/lang/Number
     211: invokevirtual #58                 // Method java/lang/Number.intValue:()I
     214: istore        9
     216: iconst_0
     217: istore        10
     219: iconst_1
     220: ireturn
     221: nop
     222: iinc          3, 1
     225: goto          54
     228: iconst_0
     229: ireturn

  private final boolean search(char[][], int, int, java.lang.String, int);
    Code:
       0: iload         5
       2: aload         4
       4: invokevirtual #93                 // Method java/lang/String.length:()I
       7: if_icmplt     12
      10: iconst_1
      11: ireturn
      12: iload_2
      13: iflt          52
      16: iload_2
      17: aload_1
      18: checkcast     #25                 // class "[Ljava/lang/Object;"
      21: arraylength
      22: if_icmpge     52
      25: iload_3
      26: iflt          52
      29: iload_3
      30: aload_1
      31: iconst_0
      32: aaload
      33: arraylength
      34: if_icmpge     52
      37: aload_1
      38: iload_2
      39: aaload
      40: iload_3
      41: caload
      42: aload         4
      44: iload         5
      46: invokevirtual #97                 // Method java/lang/String.charAt:(I)C
      49: if_icmpeq     54
      52: iconst_0
      53: ireturn
      54: aload_1
      55: iload_2
      56: aaload
      57: iload_3
      58: aload_1
      59: iload_2
      60: aaload
      61: iload_3
      62: caload
      63: sipush        255
      66: ixor
      67: i2c
      68: castore
      69: aload_0
      70: aload_1
      71: iload_2
      72: iconst_1
      73: isub
      74: iload_3
      75: aload         4
      77: iload         5
      79: iconst_1
      80: iadd
      81: invokespecial #62                 // Method search:([[CIILjava/lang/String;I)Z
      84: ifne          141
      87: aload_0
      88: aload_1
      89: iload_2
      90: iconst_1
      91: iadd
      92: iload_3
      93: aload         4
      95: iload         5
      97: iconst_1
      98: iadd
      99: invokespecial #62                 // Method search:([[CIILjava/lang/String;I)Z
     102: ifne          141
     105: aload_0
     106: aload_1
     107: iload_2
     108: iload_3
     109: iconst_1
     110: isub
     111: aload         4
     113: iload         5
     115: iconst_1
     116: iadd
     117: invokespecial #62                 // Method search:([[CIILjava/lang/String;I)Z
     120: ifne          141
     123: aload_0
     124: aload_1
     125: iload_2
     126: iload_3
     127: iconst_1
     128: iadd
     129: aload         4
     131: iload         5
     133: iconst_1
     134: iadd
     135: invokespecial #62                 // Method search:([[CIILjava/lang/String;I)Z
     138: ifeq          145
     141: iconst_1
     142: goto          146
     145: iconst_0
     146: istore        6
     148: aload_1
     149: iload_2
     150: aaload
     151: iload_3
     152: aload_1
     153: iload_2
     154: aaload
     155: iload_3
     156: caload
     157: sipush        255
     160: ixor
     161: i2c
     162: castore
     163: iload         6
     165: ireturn
}