package leetcode_problems.hard

/*
https://leetcode.com/problems/median-of-two-sorted-arrays/
*/

fun findMedianSortedArrays(nums1: IntArray, nums2: IntArray): Double {
    val maxNumSize  = 1000 ; val maxAllNumsSize  = 2000

    // Lengths of two arrays
    val m = nums1.size
    val n = nums2.size
    val allNums = nums1.plus(nums2).sorted()

   // eliminate constraints
    if (m > maxNumSize) throw IllegalArgumentException("nums1 can't be larger than $maxNumSize")
    if (n > maxNumSize) throw IllegalArgumentException("nums2 can't be larger than $maxNumSize")
    if (allNums.size > maxAllNumsSize) throw IllegalArgumentException("nums1 + nums2 can't be larger than $maxAllNumsSize together")
    if (allNums.size == 1) return allNums[0].toDouble()

    // Check if num1 is smaller than num2
    // If not, then we will swap num1 with num2
    if (nums1.size > nums2.size) {
        return findMedianSortedArrays(nums2, nums1)
    }

    // Pointers for binary search
    var start = 0
    var end = m
    // Binary search starts from here
    while (start <= end) {
        // Partitions of both the array
        val partitionNums1 = (start + end) / 2
        val partitionNums2 = (m + n + 1) / 2 - partitionNums1
        // Edge cases
        // If there are no elements left on the left side after partition
        val maxLeftNums1 = if (partitionNums1 == 0) Int.MIN_VALUE else nums1[partitionNums1 - 1]
        // If there are no elements left on the right side after partition
        val minRightNums1 = if (partitionNums1 == m) Int.MAX_VALUE else nums1[partitionNums1]
        // Similarly for nums2
        val maxLeftNums2 = if (partitionNums2 == 0) Int.MIN_VALUE else nums2[partitionNums2 - 1]
        val minRightNums2 = if (partitionNums2 == n) Int.MAX_VALUE else nums2[partitionNums2]
        // Check if we have found the match
        if (maxLeftNums1 <= minRightNums2 && maxLeftNums2 <= minRightNums1) {
            // Check if the combined array is of even/odd length
            return if ((m + n) % 2 == 0) {
                (maxLeftNums1.coerceAtLeast(maxLeftNums2) + minRightNums1.coerceAtMost(minRightNums2)) / 2.0
            } else {
                maxLeftNums1.coerceAtLeast(maxLeftNums2).toDouble()
            }
        } else if (maxLeftNums1 > minRightNums2) {
            end = partitionNums1 - 1
        } else {
            start = partitionNums1 + 1
        }
    }
    throw IllegalArgumentException()
}

fun main(){
    val nums2 = arrayListOf<Int>()
     (1..1000).forEach {
        nums2.add(it)
    }
    val ans = findMedianSortedArrays(intArrayOf() , intArrayOf(1,2,3,4,5))
    println(ans)
}

Compiled from "MedianOfTwoSortedArrays.kt"
public final class leetcode_problems.hard.MedianOfTwoSortedArraysKt {
  public static final double findMedianSortedArrays(int[], int[]);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums1
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: ldc           #17                 // String nums2
       9: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
      12: sipush        1000
      15: istore_2
      16: sipush        2000
      19: istore_3
      20: aload_0
      21: arraylength
      22: istore        4
      24: aload_1
      25: arraylength
      26: istore        5
      28: aload_0
      29: aload_1
      30: invokestatic  #23                 // Method kotlin/collections/ArraysKt.plus:([I[I)[I
      33: invokestatic  #27                 // Method kotlin/collections/ArraysKt.sorted:([I)Ljava/util/List;
      36: astore        6
      38: iload         4
      40: iload_2
      41: if_icmple     71
      44: new           #29                 // class java/lang/IllegalArgumentException
      47: dup
      48: new           #31                 // class java/lang/StringBuilder
      51: dup
      52: invokespecial #35                 // Method java/lang/StringBuilder."<init>":()V
      55: ldc           #37                 // String nums1 can\'t be larger than
      57: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: iload_2
      61: invokevirtual #44                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      64: invokevirtual #48                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      67: invokespecial #51                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
      70: athrow
      71: iload         5
      73: iload_2
      74: if_icmple     104
      77: new           #29                 // class java/lang/IllegalArgumentException
      80: dup
      81: new           #31                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #35                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #53                 // String nums2 can\'t be larger than
      90: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_2
      94: invokevirtual #44                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #48                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: invokespecial #51                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     103: athrow
     104: aload         6
     106: invokeinterface #59,  1           // InterfaceMethod java/util/List.size:()I
     111: iload_3
     112: if_icmple     147
     115: new           #29                 // class java/lang/IllegalArgumentException
     118: dup
     119: new           #31                 // class java/lang/StringBuilder
     122: dup
     123: invokespecial #35                 // Method java/lang/StringBuilder."<init>":()V
     126: ldc           #61                 // String nums1 + nums2 can\'t be larger than
     128: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     131: iload_3
     132: invokevirtual #44                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     135: ldc           #63                 // String  together
     137: invokevirtual #41                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     140: invokevirtual #48                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     143: invokespecial #51                 // Method java/lang/IllegalArgumentException."<init>":(Ljava/lang/String;)V
     146: athrow
     147: aload         6
     149: invokeinterface #59,  1           // InterfaceMethod java/util/List.size:()I
     154: iconst_1
     155: if_icmpne     174
     158: aload         6
     160: iconst_0
     161: invokeinterface #67,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     166: checkcast     #69                 // class java/lang/Number
     169: invokevirtual #72                 // Method java/lang/Number.intValue:()I
     172: i2d
     173: dreturn
     174: aload_0
     175: arraylength
     176: aload_1
     177: arraylength
     178: if_icmple     187
     181: aload_1
     182: aload_0
     183: invokestatic  #74                 // Method findMedianSortedArrays:([I[I)D
     186: dreturn
     187: iconst_0
     188: istore        7
     190: iload         4
     192: istore        8
     194: iload         7
     196: iload         8
     198: if_icmpgt     377
     201: iload         7
     203: iload         8
     205: iadd
     206: iconst_2
     207: idiv
     208: istore        9
     210: iload         4
     212: iload         5
     214: iadd
     215: iconst_1
     216: iadd
     217: iconst_2
     218: idiv
     219: iload         9
     221: isub
     222: istore        10
     224: iload         9
     226: ifne          234
     229: ldc           #75                 // int -2147483648
     231: goto          240
     234: aload_0
     235: iload         9
     237: iconst_1
     238: isub
     239: iaload
     240: istore        11
     242: iload         9
     244: iload         4
     246: if_icmpne     254
     249: ldc           #76                 // int 2147483647
     251: goto          258
     254: aload_0
     255: iload         9
     257: iaload
     258: istore        12
     260: iload         10
     262: ifne          270
     265: ldc           #75                 // int -2147483648
     267: goto          276
     270: aload_1
     271: iload         10
     273: iconst_1
     274: isub
     275: iaload
     276: istore        13
     278: iload         10
     280: iload         5
     282: if_icmpne     290
     285: ldc           #76                 // int 2147483647
     287: goto          294
     290: aload_1
     291: iload         10
     293: iaload
     294: istore        14
     296: iload         11
     298: iload         14
     300: if_icmpgt     352
     303: iload         13
     305: iload         12
     307: if_icmpgt     352
     310: iload         4
     312: iload         5
     314: iadd
     315: iconst_2
     316: irem
     317: ifne          343
     320: iload         11
     322: iload         13
     324: invokestatic  #82                 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     327: iload         12
     329: iload         14
     331: invokestatic  #85                 // Method kotlin/ranges/RangesKt.coerceAtMost:(II)I
     334: iadd
     335: i2d
     336: ldc2_w        #86                 // double 2.0d
     339: ddiv
     340: goto          351
     343: iload         11
     345: iload         13
     347: invokestatic  #82                 // Method kotlin/ranges/RangesKt.coerceAtLeast:(II)I
     350: i2d
     351: dreturn
     352: iload         11
     354: iload         14
     356: if_icmple     368
     359: iload         9
     361: iconst_1
     362: isub
     363: istore        8
     365: goto          194
     368: iload         9
     370: iconst_1
     371: iadd
     372: istore        7
     374: goto          194
     377: new           #29                 // class java/lang/IllegalArgumentException
     380: dup
     381: invokespecial #88                 // Method java/lang/IllegalArgumentException."<init>":()V
     384: athrow

  public static final void main();
    Code:
       0: new           #108                // class java/util/ArrayList
       3: dup
       4: invokespecial #109                // Method java/util/ArrayList."<init>":()V
       7: astore_0
       8: new           #111                // class kotlin/ranges/IntRange
      11: dup
      12: iconst_1
      13: sipush        1000
      16: invokespecial #114                // Method kotlin/ranges/IntRange."<init>":(II)V
      19: checkcast     #116                // class java/lang/Iterable
      22: astore_1
      23: iconst_0
      24: istore_2
      25: aload_1
      26: invokeinterface #120,  1          // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      31: astore_3
      32: aload_3
      33: invokeinterface #126,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      38: ifeq          72
      41: aload_3
      42: checkcast     #128                // class kotlin/collections/IntIterator
      45: invokevirtual #131                // Method kotlin/collections/IntIterator.nextInt:()I
      48: istore        4
      50: iload         4
      52: istore        5
      54: iconst_0
      55: istore        6
      57: aload_0
      58: iload         5
      60: invokestatic  #137                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      63: invokevirtual #141                // Method java/util/ArrayList.add:(Ljava/lang/Object;)Z
      66: pop
      67: nop
      68: nop
      69: goto          32
      72: nop
      73: iconst_0
      74: newarray       int
      76: iconst_5
      77: newarray       int
      79: astore_3
      80: aload_3
      81: iconst_0
      82: iconst_1
      83: iastore
      84: aload_3
      85: iconst_1
      86: iconst_2
      87: iastore
      88: aload_3
      89: iconst_2
      90: iconst_3
      91: iastore
      92: aload_3
      93: iconst_3
      94: iconst_4
      95: iastore
      96: aload_3
      97: iconst_4
      98: iconst_5
      99: iastore
     100: aload_3
     101: invokestatic  #74                 // Method findMedianSortedArrays:([I[I)D
     104: dstore_1
     105: getstatic     #147                // Field java/lang/System.out:Ljava/io/PrintStream;
     108: dload_1
     109: invokevirtual #153                // Method java/io/PrintStream.println:(D)V
     112: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #165                // Method main:()V
       3: return
}


package leetcode_problems.medium

import java.lang.Exception
import kotlin.math.abs

/*
https://www.geeksforgeeks.org/find-a-pair-with-the-given-difference/

Given an unsorted array and a number n,
find if there exists a pair of elements in the array whose difference is n.

Examples:

-Input: arr[] = {5, 20, 3, 2, 50, 80}, n = 78
=Output: Pair Found: (2, 80)

-Input: arr[] = {90, 70, 20, 80, 50}, n = 45
=Output: No Such Pair*/

fun findPair(nums: IntArray, n: Int): IntArray {
//    //<editor-fold desc = "Solution 1">
//    /*
//    Time Complexity: O(n*n) as two nested for loops are executing both from 1 to n where n is size of input array.
//    Space Complexity: O(1) as no extra space has been taken
//    */
//
//    nums.forEach { i ->
//        for (j in i + 1 until nums.size) {
//            if (abs(nums[i] - nums[j]) == n) return intArrayOf(nums[i], nums[j])
//        }
//    }
//    throw Exception("no pair found")
//    //</editor-fold>

    //<editor-fold desc = "Solution 2">

    // Time Complexity: O(n*log(n))
    val sorted = nums.sorted()
    var p1 = 0
    var p2 = sorted.size - 1

    while (p2 >= p1 && p2 < sorted.size) {
        if (abs(sorted[p1] - sorted[p2]) == n && p1 != p2) {
            println("p1 = $p1")
            println("p2 = $p2")
            println("abs diff = ${abs(sorted[p1] - sorted[p2])}")
            return intArrayOf(sorted[p1], sorted[p2])
        } else {
            if (sorted[p1] - sorted[p2] > n) {
                println("p1 = $p1")
                println("p2 = $p2")
                println("n = $n")
                println("diff = ${sorted[p1] - sorted[p2]}")
                p1++
                println("p1++ = ${p1++}")
            } else {
                p2--
                println("p2-- = ${p2--}")

            }
        }
    }

    throw Exception("no pair found")
    //</editor-fold>
}

fun main() {
    val result = findPair(nums = intArrayOf(5, 20, 3, 2, 50, 80, 90, 83), n = 78)
    println(result.contentToString())

}

Compiled from "PairWithGivenDifference.kt"
public final class leetcode_problems.medium.PairWithGivenDifferenceKt {
  public static final int[] findPair(int[], int);
    Code:
       0: aload_0
       1: ldc           #9                  // String nums
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #21                 // Method kotlin/collections/ArraysKt.sorted:([I)Ljava/util/List;
      10: astore_2
      11: iconst_0
      12: istore_3
      13: aload_2
      14: invokeinterface #27,  1           // InterfaceMethod java/util/List.size:()I
      19: iconst_1
      20: isub
      21: istore        4
      23: iload         4
      25: iload_3
      26: if_icmplt     468
      29: iload         4
      31: aload_2
      32: invokeinterface #27,  1           // InterfaceMethod java/util/List.size:()I
      37: if_icmpge     468
      40: aload_2
      41: iload_3
      42: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      47: checkcast     #33                 // class java/lang/Number
      50: invokevirtual #36                 // Method java/lang/Number.intValue:()I
      53: aload_2
      54: iload         4
      56: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      61: checkcast     #33                 // class java/lang/Number
      64: invokevirtual #36                 // Method java/lang/Number.intValue:()I
      67: isub
      68: invokestatic  #42                 // Method java/lang/Math.abs:(I)I
      71: iload_1
      72: if_icmpne     233
      75: iload_3
      76: iload         4
      78: if_icmpeq     233
      81: new           #44                 // class java/lang/StringBuilder
      84: dup
      85: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
      88: ldc           #50                 // String p1 =
      90: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      93: iload_3
      94: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      97: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     100: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     103: swap
     104: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     107: new           #44                 // class java/lang/StringBuilder
     110: dup
     111: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     114: ldc           #75                 // String p2 =
     116: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     119: iload         4
     121: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     124: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     127: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     130: swap
     131: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     134: new           #44                 // class java/lang/StringBuilder
     137: dup
     138: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     141: ldc           #77                 // String abs diff =
     143: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     146: aload_2
     147: iload_3
     148: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     153: checkcast     #33                 // class java/lang/Number
     156: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     159: aload_2
     160: iload         4
     162: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     167: checkcast     #33                 // class java/lang/Number
     170: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     173: isub
     174: invokestatic  #42                 // Method java/lang/Math.abs:(I)I
     177: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     180: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     183: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     186: swap
     187: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     190: iconst_2
     191: newarray       int
     193: astore        5
     195: aload         5
     197: iconst_0
     198: aload_2
     199: iload_3
     200: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     205: checkcast     #33                 // class java/lang/Number
     208: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     211: iastore
     212: aload         5
     214: iconst_1
     215: aload_2
     216: iload         4
     218: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     223: checkcast     #33                 // class java/lang/Number
     226: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     229: iastore
     230: aload         5
     232: areturn
     233: aload_2
     234: iload_3
     235: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     240: checkcast     #33                 // class java/lang/Number
     243: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     246: aload_2
     247: iload         4
     249: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     254: checkcast     #33                 // class java/lang/Number
     257: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     260: isub
     261: iload_1
     262: if_icmple     432
     265: new           #44                 // class java/lang/StringBuilder
     268: dup
     269: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     272: ldc           #50                 // String p1 =
     274: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     277: iload_3
     278: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     281: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     284: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     287: swap
     288: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     291: new           #44                 // class java/lang/StringBuilder
     294: dup
     295: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     298: ldc           #75                 // String p2 =
     300: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     303: iload         4
     305: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     308: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     311: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     314: swap
     315: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     318: new           #44                 // class java/lang/StringBuilder
     321: dup
     322: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     325: ldc           #79                 // String n =
     327: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     330: iload_1
     331: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     334: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     337: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     340: swap
     341: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     344: new           #44                 // class java/lang/StringBuilder
     347: dup
     348: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     351: ldc           #81                 // String diff =
     353: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     356: aload_2
     357: iload_3
     358: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     363: checkcast     #33                 // class java/lang/Number
     366: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     369: aload_2
     370: iload         4
     372: invokeinterface #31,  2           // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
     377: checkcast     #33                 // class java/lang/Number
     380: invokevirtual #36                 // Method java/lang/Number.intValue:()I
     383: isub
     384: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     387: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     390: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     393: swap
     394: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     397: iinc          3, 1
     400: new           #44                 // class java/lang/StringBuilder
     403: dup
     404: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     407: ldc           #83                 // String p1++ =
     409: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     412: iload_3
     413: iinc          3, 1
     416: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     419: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     422: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     425: swap
     426: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     429: goto          23
     432: iinc          4, -1
     435: new           #44                 // class java/lang/StringBuilder
     438: dup
     439: invokespecial #48                 // Method java/lang/StringBuilder."<init>":()V
     442: ldc           #85                 // String p2-- =
     444: invokevirtual #54                 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     447: iload         4
     449: iinc          4, -1
     452: invokevirtual #57                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     455: invokevirtual #61                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     458: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
     461: swap
     462: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     465: goto          23
     468: new           #87                 // class java/lang/Exception
     471: dup
     472: ldc           #89                 // String no pair found
     474: invokespecial #92                 // Method java/lang/Exception."<init>":(Ljava/lang/String;)V
     477: athrow

  public static final void main();
    Code:
       0: bipush        8
       2: newarray       int
       4: astore_1
       5: aload_1
       6: iconst_0
       7: iconst_5
       8: iastore
       9: aload_1
      10: iconst_1
      11: bipush        20
      13: iastore
      14: aload_1
      15: iconst_2
      16: iconst_3
      17: iastore
      18: aload_1
      19: iconst_3
      20: iconst_2
      21: iastore
      22: aload_1
      23: iconst_4
      24: bipush        50
      26: iastore
      27: aload_1
      28: iconst_5
      29: bipush        80
      31: iastore
      32: aload_1
      33: bipush        6
      35: bipush        90
      37: iastore
      38: aload_1
      39: bipush        7
      41: bipush        83
      43: iastore
      44: aload_1
      45: bipush        78
      47: invokestatic  #101                // Method findPair:([II)[I
      50: astore_0
      51: aload_0
      52: invokestatic  #106                // Method java/util/Arrays.toString:([I)Ljava/lang/String;
      55: dup
      56: ldc           #108                // String toString(...)
      58: invokestatic  #111                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      61: astore_1
      62: getstatic     #67                 // Field java/lang/System.out:Ljava/io/PrintStream;
      65: aload_1
      66: invokevirtual #73                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      69: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #115                // Method main:()V
       3: return
}


package leetcode_problems.medium//https://leetcode.com/problems/longest-common-prefix/

//best
fun longestCommonPrefix(strs: Array<String>?): String {
    if (strs == null || strs.isEmpty()) return ""
    for (i in 0 until strs[0].length) {
        val c = strs[0][i]
        for (j in 1 until strs.size) {
            if (i == strs[j].length || strs[j][i] != c) return strs[0].substring(0, i)
        }
    }
    return strs[0]
}

fun longestCommonPrefix1(strs: Array<String>): String {
    println(strs.contentToString())
    if (strs.isEmpty()) return ""
    if (strs.size == 1) return strs[0]
    val firstItem = strs[0]
    for (i in firstItem.indices) {
        strs.forEach {
            if (firstItem[i] != it[i])
                return firstItem.substring(0, i)
        }
    }
    return ""
}

fun longestCommonPrefix2(strs: Array<String>): String {
    println(strs.contentToString())
    return if (strs.isNotEmpty()) strs.reduce { accumulator, string ->
        accumulator.commonPrefixWith(string)
    } else ""
}

fun main() {
    val strs = arrayOf("flower", "fla", "flight", "fl")
    val strs2 = arrayOf("flower", "fla", "asd", "fl")
    val strs3 = arrayOf("a", "ab")
    println(longestCommonPrefix(strs))

}

Compiled from "LongestCommonPref.kt"
public final class leetcode_problems.medium.LongestCommonPrefKt {
  public static final java.lang.String longestCommonPrefix(java.lang.String[]);
    Code:
       0: aload_0
       1: ifnull        17
       4: aload_0
       5: arraylength
       6: ifne          13
       9: iconst_1
      10: goto          14
      13: iconst_0
      14: ifeq          20
      17: ldc           #10                 // String
      19: areturn
      20: iconst_0
      21: istore_1
      22: aload_0
      23: iconst_0
      24: aaload
      25: invokevirtual #16                 // Method java/lang/String.length:()I
      28: istore_2
      29: iload_1
      30: iload_2
      31: if_icmpge     106
      34: aload_0
      35: iconst_0
      36: aaload
      37: iload_1
      38: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
      41: istore_3
      42: iconst_1
      43: istore        4
      45: aload_0
      46: arraylength
      47: istore        5
      49: iload         4
      51: iload         5
      53: if_icmpge     100
      56: iload_1
      57: aload_0
      58: iload         4
      60: aaload
      61: invokevirtual #16                 // Method java/lang/String.length:()I
      64: if_icmpeq     79
      67: aload_0
      68: iload         4
      70: aaload
      71: iload_1
      72: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
      75: iload_3
      76: if_icmpeq     94
      79: aload_0
      80: iconst_0
      81: aaload
      82: iconst_0
      83: iload_1
      84: invokevirtual #24                 // Method java/lang/String.substring:(II)Ljava/lang/String;
      87: dup
      88: ldc           #26                 // String substring(...)
      90: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      93: areturn
      94: iinc          4, 1
      97: goto          49
     100: iinc          1, 1
     103: goto          29
     106: aload_0
     107: iconst_0
     108: aaload
     109: areturn

  public static final java.lang.String longestCommonPrefix1(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #41                 // String strs
       3: invokestatic  #44                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #50                 // Method java/util/Arrays.toString:([Ljava/lang/Object;)Ljava/lang/String;
      10: dup
      11: ldc           #52                 // String toString(...)
      13: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      16: astore_1
      17: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
      20: aload_1
      21: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: aload_0
      25: arraylength
      26: ifne          33
      29: iconst_1
      30: goto          34
      33: iconst_0
      34: ifeq          40
      37: ldc           #10                 // String
      39: areturn
      40: aload_0
      41: arraylength
      42: iconst_1
      43: if_icmpne     50
      46: aload_0
      47: iconst_0
      48: aaload
      49: areturn
      50: aload_0
      51: iconst_0
      52: aaload
      53: astore_1
      54: iconst_0
      55: istore_2
      56: aload_1
      57: checkcast     #66                 // class java/lang/CharSequence
      60: invokeinterface #67,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      65: istore_3
      66: iload_2
      67: iload_3
      68: if_icmpge     148
      71: aload_0
      72: astore        4
      74: iconst_0
      75: istore        5
      77: iconst_0
      78: istore        6
      80: aload         4
      82: arraylength
      83: istore        7
      85: iload         6
      87: iload         7
      89: if_icmpge     141
      92: aload         4
      94: iload         6
      96: aaload
      97: astore        8
      99: aload         8
     101: astore        9
     103: iconst_0
     104: istore        10
     106: aload_1
     107: iload_2
     108: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
     111: aload         9
     113: iload_2
     114: invokevirtual #20                 // Method java/lang/String.charAt:(I)C
     117: if_icmpeq     133
     120: aload_1
     121: iconst_0
     122: iload_2
     123: invokevirtual #24                 // Method java/lang/String.substring:(II)Ljava/lang/String;
     126: dup
     127: ldc           #26                 // String substring(...)
     129: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     132: areturn
     133: nop
     134: nop
     135: iinc          6, 1
     138: goto          85
     141: nop
     142: iinc          2, 1
     145: goto          66
     148: ldc           #10                 // String
     150: areturn

  public static final java.lang.String longestCommonPrefix2(java.lang.String[]);
    Code:
       0: aload_0
       1: ldc           #41                 // String strs
       3: invokestatic  #44                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: invokestatic  #50                 // Method java/util/Arrays.toString:([Ljava/lang/Object;)Ljava/lang/String;
      10: dup
      11: ldc           #52                 // String toString(...)
      13: invokestatic  #32                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      16: astore_1
      17: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
      20: aload_1
      21: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      24: aload_0
      25: arraylength
      26: ifne          33
      29: iconst_1
      30: goto          34
      33: iconst_0
      34: ifne          41
      37: iconst_1
      38: goto          42
      41: iconst_0
      42: ifeq          138
      45: aload_0
      46: astore_1
      47: iconst_0
      48: istore_2
      49: aload_1
      50: arraylength
      51: ifne          58
      54: iconst_1
      55: goto          59
      58: iconst_0
      59: ifeq          72
      62: new           #80                 // class java/lang/UnsupportedOperationException
      65: dup
      66: ldc           #82                 // String Empty array can\'t be reduced.
      68: invokespecial #86                 // Method java/lang/UnsupportedOperationException."<init>":(Ljava/lang/String;)V
      71: athrow
      72: aload_1
      73: iconst_0
      74: aaload
      75: astore_3
      76: iconst_1
      77: istore        4
      79: aload_1
      80: invokestatic  #92                 // Method kotlin/collections/ArraysKt.getLastIndex:([Ljava/lang/Object;)I
      83: istore        5
      85: iload         4
      87: iload         5
      89: if_icmpgt     134
      92: aload_3
      93: aload_1
      94: iload         4
      96: aaload
      97: astore        6
      99: astore        7
     101: iconst_0
     102: istore        8
     104: aload         7
     106: checkcast     #66                 // class java/lang/CharSequence
     109: aload         6
     111: checkcast     #66                 // class java/lang/CharSequence
     114: iconst_0
     115: iconst_2
     116: aconst_null
     117: invokestatic  #98                 // Method kotlin/text/StringsKt.commonPrefixWith$default:(Ljava/lang/CharSequence;Ljava/lang/CharSequence;ZILjava/lang/Object;)Ljava/lang/String;
     120: astore_3
     121: iload         4
     123: iload         5
     125: if_icmpeq     134
     128: iinc          4, 1
     131: goto          92
     134: aload_3
     135: goto          140
     138: ldc           #10                 // String
     140: areturn

  public static final void main();
    Code:
       0: iconst_4
       1: anewarray     #12                 // class java/lang/String
       4: astore_1
       5: aload_1
       6: iconst_0
       7: ldc           #109                // String flower
       9: aastore
      10: aload_1
      11: iconst_1
      12: ldc           #111                // String fla
      14: aastore
      15: aload_1
      16: iconst_2
      17: ldc           #113                // String flight
      19: aastore
      20: aload_1
      21: iconst_3
      22: ldc           #115                // String fl
      24: aastore
      25: aload_1
      26: astore_0
      27: iconst_4
      28: anewarray     #12                 // class java/lang/String
      31: astore_2
      32: aload_2
      33: iconst_0
      34: ldc           #109                // String flower
      36: aastore
      37: aload_2
      38: iconst_1
      39: ldc           #111                // String fla
      41: aastore
      42: aload_2
      43: iconst_2
      44: ldc           #117                // String asd
      46: aastore
      47: aload_2
      48: iconst_3
      49: ldc           #115                // String fl
      51: aastore
      52: aload_2
      53: astore_1
      54: iconst_2
      55: anewarray     #12                 // class java/lang/String
      58: astore_3
      59: aload_3
      60: iconst_0
      61: ldc           #119                // String a
      63: aastore
      64: aload_3
      65: iconst_1
      66: ldc           #121                // String ab
      68: aastore
      69: aload_3
      70: astore_2
      71: aload_0
      72: invokestatic  #123                // Method longestCommonPrefix:([Ljava/lang/String;)Ljava/lang/String;
      75: getstatic     #58                 // Field java/lang/System.out:Ljava/io/PrintStream;
      78: swap
      79: invokevirtual #64                 // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      82: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #128                // Method main:()V
       3: return
}


package leetcode_problems.medium

/*
https://leetcode.com/problems/add-two-numbers/
*/

/**
 * Example:
 * var li = ListNode(5)
 * var v = li.`val`
 * Definition for singly-linked list.
 * class ListNode(var `val`: Int) {
 *     var next: ListNode? = null
 * }
 * Example 1:
 * Input: l1 = [2,4,3], l2 = [5,6,4]
 * Output: [7,0,8]
 * Explanation: 342 + 465 = 807.
 *
 * Example 2:
 * Input: l1 = [0], l2 = [0]
 * Output: [0]
 *
 * Example 3:
 * Input: l1 = [9,9,9,9,9,9,9], l2 = [9,9,9,9]
 * Output: [8,9,9,9,0,0,0,1]
 */
/// 3(4(5))

class ListNode(var value: List<Int>)

fun addTwoNumbers(l1: ListNode?, l2: ListNode?): ListNode {
    val ls1 = StringBuilder()
    val ls2 = StringBuilder()
    val resultNode = mutableListOf<Int>()
    (l1?.value?.reversed() ?: listOf()).forEach { i ->
        ls1.append(i)
    }
    for (i in l2?.value?.reversed() ?: listOf()) {
        ls2.append(i)
    }
    val result = ls1.toString().toInt() + ls2.toString().toInt()
    result.toString().forEach {
        resultNode.add(it.digitToInt())
    }
    return ListNode(resultNode.reversed())
}

fun main() {
    val ans = addTwoNumbers(l1 = ListNode(listOf(9,9,9,9,9,9,9)), l2 = ListNode(listOf(9,9,9,9)))
    println(ans.value)
}

Compiled from "AddTwoNumbers.kt"
public final class leetcode_problems.medium.AddTwoNumbersKt {
  public static final leetcode_problems.medium.ListNode addTwoNumbers(leetcode_problems.medium.ListNode, leetcode_problems.medium.ListNode);
    Code:
       0: new           #10                 // class java/lang/StringBuilder
       3: dup
       4: invokespecial #14                 // Method java/lang/StringBuilder."<init>":()V
       7: astore_2
       8: new           #10                 // class java/lang/StringBuilder
      11: dup
      12: invokespecial #14                 // Method java/lang/StringBuilder."<init>":()V
      15: astore_3
      16: new           #16                 // class java/util/ArrayList
      19: dup
      20: invokespecial #17                 // Method java/util/ArrayList."<init>":()V
      23: checkcast     #19                 // class java/util/List
      26: astore        4
      28: aload_0
      29: dup
      30: ifnull        50
      33: invokevirtual #25                 // Method leetcode_problems/medium/ListNode.getValue:()Ljava/util/List;
      36: dup
      37: ifnull        50
      40: checkcast     #27                 // class java/lang/Iterable
      43: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
      46: dup
      47: ifnonnull     54
      50: pop
      51: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
      54: checkcast     #27                 // class java/lang/Iterable
      57: astore        5
      59: nop
      60: iconst_0
      61: istore        6
      63: aload         5
      65: invokeinterface #40,  1           // InterfaceMethod java/lang/Iterable.iterator:()Ljava/util/Iterator;
      70: astore        7
      72: aload         7
      74: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
      79: ifeq          116
      82: aload         7
      84: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      89: astore        8
      91: aload         8
      93: checkcast     #52                 // class java/lang/Number
      96: invokevirtual #56                 // Method java/lang/Number.intValue:()I
      99: istore        9
     101: iconst_0
     102: istore        10
     104: aload_2
     105: iload         9
     107: invokevirtual #60                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     110: pop
     111: nop
     112: nop
     113: goto          72
     116: nop
     117: aload_1
     118: dup
     119: ifnull        139
     122: invokevirtual #25                 // Method leetcode_problems/medium/ListNode.getValue:()Ljava/util/List;
     125: dup
     126: ifnull        139
     129: checkcast     #27                 // class java/lang/Iterable
     132: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     135: dup
     136: ifnonnull     143
     139: pop
     140: invokestatic  #36                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     143: invokeinterface #61,  1           // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
     148: astore        5
     150: aload         5
     152: invokeinterface #46,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     157: ifeq          185
     160: aload         5
     162: invokeinterface #50,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     167: checkcast     #52                 // class java/lang/Number
     170: invokevirtual #56                 // Method java/lang/Number.intValue:()I
     173: istore        6
     175: aload_3
     176: iload         6
     178: invokevirtual #60                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     181: pop
     182: goto          150
     185: aload_2
     186: invokevirtual #65                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     189: dup
     190: ldc           #67                 // String toString(...)
     192: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     195: invokestatic  #79                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     198: aload_3
     199: invokevirtual #65                 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     202: dup
     203: ldc           #67                 // String toString(...)
     205: invokestatic  #73                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     208: invokestatic  #79                 // Method java/lang/Integer.parseInt:(Ljava/lang/String;)I
     211: iadd
     212: istore        5
     214: iload         5
     216: invokestatic  #85                 // Method java/lang/String.valueOf:(I)Ljava/lang/String;
     219: checkcast     #87                 // class java/lang/CharSequence
     222: astore        6
     224: iconst_0
     225: istore        7
     227: iconst_0
     228: istore        8
     230: iload         8
     232: aload         6
     234: invokeinterface #90,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     239: if_icmpge     284
     242: aload         6
     244: iload         8
     246: invokeinterface #94,  2           // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     251: istore        9
     253: iload         9
     255: istore        10
     257: iconst_0
     258: istore        11
     260: aload         4
     262: iload         10
     264: invokestatic  #100                // Method kotlin/text/CharsKt.digitToInt:(C)I
     267: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     270: invokeinterface #107,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     275: pop
     276: nop
     277: nop
     278: iinc          8, 1
     281: goto          230
     284: nop
     285: new           #21                 // class leetcode_problems/medium/ListNode
     288: dup
     289: aload         4
     291: checkcast     #27                 // class java/lang/Iterable
     294: invokestatic  #33                 // Method kotlin/collections/CollectionsKt.reversed:(Ljava/lang/Iterable;)Ljava/util/List;
     297: invokespecial #110                // Method leetcode_problems/medium/ListNode."<init>":(Ljava/util/List;)V
     300: areturn

  public static final void main();
    Code:
       0: new           #21                 // class leetcode_problems/medium/ListNode
       3: dup
       4: bipush        7
       6: anewarray     #75                 // class java/lang/Integer
       9: astore_1
      10: aload_1
      11: iconst_0
      12: bipush        9
      14: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      17: aastore
      18: aload_1
      19: iconst_1
      20: bipush        9
      22: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      25: aastore
      26: aload_1
      27: iconst_2
      28: bipush        9
      30: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      33: aastore
      34: aload_1
      35: iconst_3
      36: bipush        9
      38: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      41: aastore
      42: aload_1
      43: iconst_4
      44: bipush        9
      46: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      49: aastore
      50: aload_1
      51: iconst_5
      52: bipush        9
      54: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      57: aastore
      58: aload_1
      59: bipush        6
      61: bipush        9
      63: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      66: aastore
      67: aload_1
      68: invokestatic  #136                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
      71: invokespecial #110                // Method leetcode_problems/medium/ListNode."<init>":(Ljava/util/List;)V
      74: new           #21                 // class leetcode_problems/medium/ListNode
      77: dup
      78: iconst_4
      79: anewarray     #75                 // class java/lang/Integer
      82: astore_1
      83: aload_1
      84: iconst_0
      85: bipush        9
      87: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      90: aastore
      91: aload_1
      92: iconst_1
      93: bipush        9
      95: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      98: aastore
      99: aload_1
     100: iconst_2
     101: bipush        9
     103: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     106: aastore
     107: aload_1
     108: iconst_3
     109: bipush        9
     111: invokestatic  #103                // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     114: aastore
     115: aload_1
     116: invokestatic  #136                // Method kotlin/collections/CollectionsKt.listOf:([Ljava/lang/Object;)Ljava/util/List;
     119: invokespecial #110                // Method leetcode_problems/medium/ListNode."<init>":(Ljava/util/List;)V
     122: invokestatic  #138                // Method addTwoNumbers:(Lleetcode_problems/medium/ListNode;Lleetcode_problems/medium/ListNode;)Lleetcode_problems/medium/ListNode;
     125: astore_0
     126: aload_0
     127: invokevirtual #25                 // Method leetcode_problems/medium/ListNode.getValue:()Ljava/util/List;
     130: getstatic     #144                // Field java/lang/System.out:Ljava/io/PrintStream;
     133: swap
     134: invokevirtual #150                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     137: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #154                // Method main:()V
       3: return
}


package com.frosch2010.fuzzywuzzy_kotlin.algorithms

import java.util.Arrays
import java.util.Collections
import java.util.PriorityQueue

object Utils {
    fun tokenize(`in`: String): List<String> {
        return Arrays.asList(*`in`.split("\\s+".toRegex()).dropLastWhile { it.isEmpty() }
            .toTypedArray())
    }

    fun tokenizeSet(`in`: String): Set<String> {
        return HashSet(tokenize(`in`))
    }

    fun sortAndJoin(col: List<String?>, sep: String?): String {
        val sortedList = col.sortedWith(Comparator { a, b ->
            when {
                a == null && b == null -> 0
                a == null -> -1
                b == null -> 1
                else -> a.compareTo(b)
            }
        })
        return join(sortedList, sep)
    }

    fun join(strings: List<String?>, sep: String?): String {
        val buf = StringBuilder(strings.size * 16)
        for (i in strings.indices) {
            if (i < strings.size) {
                buf.append(sep)
            }
            buf.append(strings[i])
        }
        return buf.toString().trim { it <= ' ' }
    }

    fun sortAndJoin(col: Set<String?>?, sep: String?): String {
        return sortAndJoin(ArrayList(col), sep)
    }

    fun <T : Comparable<T>?> findTopKHeap(arr: List<T>, k: Int): List<T> {
        val pq = PriorityQueue<T>()
        for (x in arr) {
            if (pq.size < k) pq.add(x) else if (x!!.compareTo(pq.peek()) > 0) {
                pq.poll()
                pq.add(x)
            }
        }
        val res: MutableList<T> = ArrayList()
        for (i in k downTo 1) {
            val polled = pq.poll()
            if (polled != null) {
                res.add(polled)
            }
        }
        return res
    }

    fun <T : Comparable<T>?> max(vararg elems: T): T? {
        if (elems.size == 0) return null
        var best = elems[0]
        for (t in elems) {
            if (t!!.compareTo(best) > 0) {
                best = t
            }
        }
        return best
    }
}

Compiled from "Utils.kt"
public final class com.frosch2010.fuzzywuzzy_kotlin.algorithms.Utils {
  public static final com.frosch2010.fuzzywuzzy_kotlin.algorithms.Utils INSTANCE;

  private com.frosch2010.fuzzywuzzy_kotlin.algorithms.Utils();
    Code:
       0: aload_0
       1: invokespecial #8                  // Method java/lang/Object."<init>":()V
       4: return

  public final java.util.List<java.lang.String> tokenize(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #16                 // String in
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #24                 // class java/lang/CharSequence
      10: astore_3
      11: new           #26                 // class kotlin/text/Regex
      14: dup
      15: ldc           #28                 // String \\s+
      17: invokespecial #31                 // Method kotlin/text/Regex."<init>":(Ljava/lang/String;)V
      20: astore        4
      22: iconst_0
      23: istore        5
      25: aload         4
      27: aload_3
      28: iload         5
      30: invokevirtual #35                 // Method kotlin/text/Regex.split:(Ljava/lang/CharSequence;I)Ljava/util/List;
      33: astore_3
      34: nop
      35: iconst_0
      36: istore        4
      38: aload_3
      39: invokeinterface #41,  1           // InterfaceMethod java/util/List.isEmpty:()Z
      44: ifne          127
      47: aload_3
      48: aload_3
      49: invokeinterface #45,  1           // InterfaceMethod java/util/List.size:()I
      54: invokeinterface #49,  2           // InterfaceMethod java/util/List.listIterator:(I)Ljava/util/ListIterator;
      59: astore        5
      61: aload         5
      63: invokeinterface #54,  1           // InterfaceMethod java/util/ListIterator.hasPrevious:()Z
      68: ifeq          127
      71: aload         5
      73: invokeinterface #58,  1           // InterfaceMethod java/util/ListIterator.previous:()Ljava/lang/Object;
      78: checkcast     #60                 // class java/lang/String
      81: astore        6
      83: iconst_0
      84: istore        7
      86: aload         6
      88: checkcast     #24                 // class java/lang/CharSequence
      91: invokeinterface #63,  1           // InterfaceMethod java/lang/CharSequence.length:()I
      96: ifne          103
      99: iconst_1
     100: goto          104
     103: iconst_0
     104: nop
     105: ifne          61
     108: aload_3
     109: checkcast     #65                 // class java/lang/Iterable
     112: aload         5
     114: invokeinterface #68,  1           // InterfaceMethod java/util/ListIterator.nextIndex:()I
     119: iconst_1
     120: iadd
     121: invokestatic  #74                 // Method kotlin/collections/CollectionsKt.take:(Ljava/lang/Iterable;I)Ljava/util/List;
     124: goto          130
     127: invokestatic  #78                 // Method kotlin/collections/CollectionsKt.emptyList:()Ljava/util/List;
     130: checkcast     #80                 // class java/util/Collection
     133: astore_3
     134: nop
     135: iconst_0
     136: istore        4
     138: aload_3
     139: astore        5
     141: aload         5
     143: iconst_0
     144: anewarray     #60                 // class java/lang/String
     147: invokeinterface #84,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     152: checkcast     #86                 // class "[Ljava/lang/String;"
     155: astore_2
     156: aload_2
     157: aload_2
     158: arraylength
     159: invokestatic  #92                 // Method java/util/Arrays.copyOf:([Ljava/lang/Object;I)[Ljava/lang/Object;
     162: invokestatic  #96                 // Method java/util/Arrays.asList:([Ljava/lang/Object;)Ljava/util/List;
     165: dup
     166: ldc           #98                 // String asList(...)
     168: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
     171: areturn

  public final java.util.Set<java.lang.String> tokenizeSet(java.lang.String);
    Code:
       0: aload_1
       1: ldc           #16                 // String in
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #119                // class java/util/HashSet
       9: dup
      10: aload_0
      11: aload_1
      12: invokevirtual #121                // Method tokenize:(Ljava/lang/String;)Ljava/util/List;
      15: checkcast     #80                 // class java/util/Collection
      18: invokespecial #124                // Method java/util/HashSet."<init>":(Ljava/util/Collection;)V
      21: checkcast     #126                // class java/util/Set
      24: areturn

  public final java.lang.String sortAndJoin(java.util.List<java.lang.String>, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #132                // String col
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_1
       7: checkcast     #65                 // class java/lang/Iterable
      10: invokedynamic #151,  0            // InvokeDynamic #0:compare:()Ljava/util/Comparator;
      15: invokestatic  #155                // Method kotlin/collections/CollectionsKt.sortedWith:(Ljava/lang/Iterable;Ljava/util/Comparator;)Ljava/util/List;
      18: astore_3
      19: aload_0
      20: aload_3
      21: aload_2
      22: invokevirtual #158                // Method join:(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;
      25: areturn

  public final java.lang.String join(java.util.List<java.lang.String>, java.lang.String);
    Code:
       0: aload_1
       1: ldc           #162                // String strings
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #164                // class java/lang/StringBuilder
       9: dup
      10: aload_1
      11: invokeinterface #45,  1           // InterfaceMethod java/util/List.size:()I
      16: bipush        16
      18: imul
      19: invokespecial #167                // Method java/lang/StringBuilder."<init>":(I)V
      22: astore_3
      23: iconst_0
      24: istore        4
      26: aload_1
      27: checkcast     #80                 // class java/util/Collection
      30: invokeinterface #168,  1          // InterfaceMethod java/util/Collection.size:()I
      35: istore        5
      37: iload         4
      39: iload         5
      41: if_icmpge     83
      44: iload         4
      46: aload_1
      47: invokeinterface #45,  1           // InterfaceMethod java/util/List.size:()I
      52: if_icmpge     61
      55: aload_3
      56: aload_2
      57: invokevirtual #172                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      60: pop
      61: aload_3
      62: aload_1
      63: iload         4
      65: invokeinterface #176,  2          // InterfaceMethod java/util/List.get:(I)Ljava/lang/Object;
      70: checkcast     #60                 // class java/lang/String
      73: invokevirtual #172                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      76: pop
      77: iinc          4, 1
      80: goto          37
      83: aload_3
      84: invokevirtual #180                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      87: dup
      88: ldc           #182                // String toString(...)
      90: invokestatic  #101                // Method kotlin/jvm/internal/Intrinsics.checkNotNullExpressionValue:(Ljava/lang/Object;Ljava/lang/String;)V
      93: astore        4
      95: iconst_0
      96: istore        5
      98: aload         4
     100: checkcast     #24                 // class java/lang/CharSequence
     103: astore        6
     105: iconst_0
     106: istore        7
     108: iconst_0
     109: istore        8
     111: aload         6
     113: invokeinterface #63,  1           // InterfaceMethod java/lang/CharSequence.length:()I
     118: iconst_1
     119: isub
     120: istore        9
     122: iconst_0
     123: istore        10
     125: iload         8
     127: iload         9
     129: if_icmpgt     213
     132: iload         10
     134: ifne          142
     137: iload         8
     139: goto          144
     142: iload         9
     144: istore        11
     146: aload         6
     148: iload         11
     150: invokeinterface #186,  2          // InterfaceMethod java/lang/CharSequence.charAt:(I)C
     155: istore        12
     157: iconst_0
     158: istore        13
     160: iload         12
     162: bipush        32
     164: invokestatic  #189                // Method kotlin/jvm/internal/Intrinsics.compare:(II)I
     167: ifgt          174
     170: iconst_1
     171: goto          175
     174: iconst_0
     175: istore        12
     177: iload         10
     179: ifne          199
     182: iload         12
     184: ifne          193
     187: iconst_1
     188: istore        10
     190: goto          125
     193: iinc          8, 1
     196: goto          125
     199: iload         12
     201: ifne          207
     204: goto          213
     207: iinc          9, -1
     210: goto          125
     213: aload         6
     215: iload         8
     217: iload         9
     219: iconst_1
     220: iadd
     221: invokeinterface #193,  3          // InterfaceMethod java/lang/CharSequence.subSequence:(II)Ljava/lang/CharSequence;
     226: invokevirtual #194                // Method java/lang/Object.toString:()Ljava/lang/String;
     229: areturn

  public final java.lang.String sortAndJoin(java.util.Set<java.lang.String>, java.lang.String);
    Code:
       0: aload_0
       1: new           #213                // class java/util/ArrayList
       4: dup
       5: aload_1
       6: checkcast     #80                 // class java/util/Collection
       9: invokespecial #214                // Method java/util/ArrayList."<init>":(Ljava/util/Collection;)V
      12: checkcast     #37                 // class java/util/List
      15: aload_2
      16: invokevirtual #216                // Method sortAndJoin:(Ljava/util/List;Ljava/lang/String;)Ljava/lang/String;
      19: areturn

  public final <T extends java.lang.Comparable<? super T>> java.util.List<T> findTopKHeap(java.util.List<? extends T>, int);
    Code:
       0: aload_1
       1: ldc           #222                // String arr
       3: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: new           #224                // class java/util/PriorityQueue
       9: dup
      10: invokespecial #225                // Method java/util/PriorityQueue."<init>":()V
      13: astore_3
      14: aload_1
      15: invokeinterface #229,  1          // InterfaceMethod java/util/List.iterator:()Ljava/util/Iterator;
      20: astore        4
      22: aload         4
      24: invokeinterface #234,  1          // InterfaceMethod java/util/Iterator.hasNext:()Z
      29: ifeq          95
      32: aload         4
      34: invokeinterface #237,  1          // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
      39: checkcast     #239                // class java/lang/Comparable
      42: astore        5
      44: aload_3
      45: invokevirtual #240                // Method java/util/PriorityQueue.size:()I
      48: iload_2
      49: if_icmpge     62
      52: aload_3
      53: aload         5
      55: invokevirtual #244                // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z
      58: pop
      59: goto          22
      62: aload         5
      64: dup
      65: invokestatic  #248                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      68: aload_3
      69: invokevirtual #251                // Method java/util/PriorityQueue.peek:()Ljava/lang/Object;
      72: invokeinterface #255,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      77: ifle          22
      80: aload_3
      81: invokevirtual #258                // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
      84: pop
      85: aload_3
      86: aload         5
      88: invokevirtual #244                // Method java/util/PriorityQueue.add:(Ljava/lang/Object;)Z
      91: pop
      92: goto          22
      95: new           #213                // class java/util/ArrayList
      98: dup
      99: invokespecial #259                // Method java/util/ArrayList."<init>":()V
     102: checkcast     #37                 // class java/util/List
     105: astore        4
     107: iload_2
     108: istore        5
     110: iconst_0
     111: iload         5
     113: if_icmpge     146
     116: aload_3
     117: invokevirtual #258                // Method java/util/PriorityQueue.poll:()Ljava/lang/Object;
     120: checkcast     #239                // class java/lang/Comparable
     123: astore        6
     125: aload         6
     127: ifnull        140
     130: aload         4
     132: aload         6
     134: invokeinterface #260,  2          // InterfaceMethod java/util/List.add:(Ljava/lang/Object;)Z
     139: pop
     140: iinc          5, -1
     143: goto          110
     146: aload         4
     148: areturn

  public final <T extends java.lang.Comparable<? super T>> T max(T...);
    Code:
       0: aload_1
       1: ldc_w         #272                // String elems
       4: invokestatic  #22                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       7: aload_1
       8: arraylength
       9: ifne          14
      12: aconst_null
      13: areturn
      14: aload_1
      15: iconst_0
      16: aaload
      17: astore_2
      18: iconst_0
      19: istore_3
      20: aload_1
      21: arraylength
      22: istore        4
      24: iload_3
      25: iload         4
      27: if_icmpge     59
      30: aload_1
      31: iload_3
      32: aaload
      33: astore        5
      35: aload         5
      37: dup
      38: invokestatic  #248                // Method kotlin/jvm/internal/Intrinsics.checkNotNull:(Ljava/lang/Object;)V
      41: aload_2
      42: invokeinterface #255,  2          // InterfaceMethod java/lang/Comparable.compareTo:(Ljava/lang/Object;)I
      47: ifle          53
      50: aload         5
      52: astore_2
      53: iinc          3, 1
      56: goto          24
      59: aload_2
      60: areturn

  private static final int sortAndJoin$lambda$1(java.lang.String, java.lang.String);
    Code:
       0: nop
       1: aload_0
       2: ifnonnull     13
       5: aload_1
       6: ifnonnull     13
       9: iconst_0
      10: goto          34
      13: aload_0
      14: ifnonnull     21
      17: iconst_m1
      18: goto          34
      21: aload_1
      22: ifnonnull     29
      25: iconst_1
      26: goto          34
      29: aload_0
      30: aload_1
      31: invokevirtual #278                // Method java/lang/String.compareTo:(Ljava/lang/String;)I
      34: ireturn

  static {};
    Code:
       0: new           #2                  // class com/frosch2010/fuzzywuzzy_kotlin/algorithms/Utils
       3: dup
       4: invokespecial #282                // Method "<init>":()V
       7: putstatic     #285                // Field INSTANCE:Lcom/frosch2010/fuzzywuzzy_kotlin/algorithms/Utils;
      10: return
}


package dev.aspid812.leetcode.problem1854

import java.time.Year

/* 1854. Maximum Population Year
 * -----------------------------
 *
 * You are given a 2D integer array `logs` where each `logs[i] = [birth_i, death_i]` indicates the birth and death
 * years of the `i`-th person.
 *
 * The **population** of some year `x` is the number of people alive during that year. The `i`-th person is counted
 * in year `x`'s population if `x` is in the **inclusive** range `[birth_i, death_i - 1]`. Note that the person
 * is **not** counted in the year that they die.
 *
 * Return *the **earliest** year with the **maximum population***.
 *
 * ### Constraints:
 *
 *   * `1 <= logs.length <= 100`
 *   * `1950 <= birth_i < death_i <= 2050`
 */

import kotlin.math.min

typealias Lifespan = IntArray

data class PopulationRecord(
    public val year: Int,
    public val population: Int
)

class Solution {
    fun maximumPopulation(logs: Array<Lifespan>): Int {
        val birthYears = logs.map { log -> log[0] }.toIntArray()
        birthYears.sort()

        val deathYears = logs.map { log -> log[1] }.toIntArray()
        deathYears.sort()

        return sequence {
            var population = 0
            var (i, j) = Pair(0, 0)
            while (i < birthYears.size || j < deathYears.size) {
                var year = min(
                    birthYears.getOrNull(i) ?: 2050,
                    deathYears.getOrNull(j) ?: 2050
                )
                while (i < birthYears.size && birthYears[i] == year) {
                    population += 1
                    i++
                }
                while (j < deathYears.size && deathYears[j] == year) {
                    population -= 1
                    j++
                }
                yield(PopulationRecord(year, population))
            }
        }.maxByOrNull(PopulationRecord::population)?.year ?: 1950
    }
}

fun makeLogs(vararg lifespans: IntRange): Array<Lifespan> {
    return lifespans.map { range -> intArrayOf(range.start, range.endInclusive + 1) }.toTypedArray()
}

fun main() {
    val s = Solution()

    // The maximum population is 1, and 1993 is the earliest year with this population.
    val logs1 = makeLogs(1993 until 1999, 2000 until 2010)
    println("${s.maximumPopulation(logs1)} == 1993")

    // The maximum population is 2, and it had happened in years 1960 and 1970.
    // The earlier year between them is 1960.
    val logs2 = makeLogs(1950 until 1961, 1960 until 1971, 1970 until 1981)
    println("${s.maximumPopulation(logs2)} == 1960")

    val logs3 = makeLogs(1982 until 1998, 2013 until 2042, 2010 until 2035, 2022 until 2050, 2047 until 2048)
    println("${s.maximumPopulation(logs3)} == 2022")
}

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

  public final int maximumPopulation(int[][]);
    Code:
       0: aload_1
       1: ldc           #15                 // String logs
       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: astore_3
      11: iconst_0
      12: istore        4
      14: aload_3
      15: astore        5
      17: new           #25                 // class java/util/ArrayList
      20: dup
      21: aload_3
      22: arraylength
      23: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
      26: checkcast     #30                 // class java/util/Collection
      29: astore        6
      31: iconst_0
      32: istore        7
      34: iconst_0
      35: istore        8
      37: aload         5
      39: arraylength
      40: istore        9
      42: iload         8
      44: iload         9
      46: if_icmpge     92
      49: aload         5
      51: iload         8
      53: aaload
      54: astore        10
      56: aload         6
      58: aload         10
      60: checkcast     #32                 // class "[I"
      63: astore        11
      65: astore        14
      67: iconst_0
      68: istore        12
      70: aload         11
      72: iconst_0
      73: iaload
      74: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
      77: aload         14
      79: swap
      80: invokeinterface #42,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
      85: pop
      86: iinc          8, 1
      89: goto          42
      92: aload         6
      94: checkcast     #44                 // class java/util/List
      97: nop
      98: checkcast     #30                 // class java/util/Collection
     101: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     104: astore_2
     105: aload_2
     106: invokestatic  #56                 // Method kotlin/collections/ArraysKt.sort:([I)V
     109: aload_1
     110: checkcast     #23                 // class "[Ljava/lang/Object;"
     113: astore        4
     115: iconst_0
     116: istore        5
     118: aload         4
     120: astore        6
     122: new           #25                 // class java/util/ArrayList
     125: dup
     126: aload         4
     128: arraylength
     129: invokespecial #28                 // Method java/util/ArrayList."<init>":(I)V
     132: checkcast     #30                 // class java/util/Collection
     135: astore        7
     137: iconst_0
     138: istore        8
     140: iconst_0
     141: istore        9
     143: aload         6
     145: arraylength
     146: istore        10
     148: iload         9
     150: iload         10
     152: if_icmpge     198
     155: aload         6
     157: iload         9
     159: aaload
     160: astore        11
     162: aload         7
     164: aload         11
     166: checkcast     #32                 // class "[I"
     169: astore        12
     171: astore        14
     173: iconst_0
     174: istore        13
     176: aload         12
     178: iconst_1
     179: iaload
     180: invokestatic  #38                 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer;
     183: aload         14
     185: swap
     186: invokeinterface #42,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     191: pop
     192: iinc          9, 1
     195: goto          148
     198: aload         7
     200: checkcast     #44                 // class java/util/List
     203: nop
     204: checkcast     #30                 // class java/util/Collection
     207: invokestatic  #50                 // Method kotlin/collections/CollectionsKt.toIntArray:(Ljava/util/Collection;)[I
     210: astore_3
     211: aload_3
     212: invokestatic  #56                 // Method kotlin/collections/ArraysKt.sort:([I)V
     215: new           #58                 // class dev/aspid812/leetcode/problem1854/Solution$maximumPopulation$1
     218: dup
     219: aload_2
     220: aload_3
     221: aconst_null
     222: invokespecial #61                 // Method dev/aspid812/leetcode/problem1854/Solution$maximumPopulation$1."<init>":([I[ILkotlin/coroutines/Continuation;)V
     225: checkcast     #63                 // class kotlin/jvm/functions/Function2
     228: invokestatic  #69                 // Method kotlin/sequences/SequencesKt.sequence:(Lkotlin/jvm/functions/Function2;)Lkotlin/sequences/Sequence;
     231: astore        5
     233: nop
     234: iconst_0
     235: istore        6
     237: aload         5
     239: invokeinterface #75,  1           // InterfaceMethod kotlin/sequences/Sequence.iterator:()Ljava/util/Iterator;
     244: astore        7
     246: aload         7
     248: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     253: ifne          260
     256: aconst_null
     257: goto          354
     260: aload         7
     262: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     267: astore        8
     269: aload         7
     271: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     276: ifne          284
     279: aload         8
     281: goto          354
     284: aload         8
     286: checkcast     #87                 // class dev/aspid812/leetcode/problem1854/PopulationRecord
     289: astore        9
     291: iconst_0
     292: istore        10
     294: aload         9
     296: invokevirtual #91                 // Method dev/aspid812/leetcode/problem1854/PopulationRecord.getPopulation:()I
     299: istore        9
     301: aload         7
     303: invokeinterface #85,  1           // InterfaceMethod java/util/Iterator.next:()Ljava/lang/Object;
     308: astore        10
     310: aload         10
     312: checkcast     #87                 // class dev/aspid812/leetcode/problem1854/PopulationRecord
     315: astore        11
     317: iconst_0
     318: istore        12
     320: aload         11
     322: invokevirtual #91                 // Method dev/aspid812/leetcode/problem1854/PopulationRecord.getPopulation:()I
     325: istore        11
     327: iload         9
     329: iload         11
     331: if_icmpge     342
     334: aload         10
     336: astore        8
     338: iload         11
     340: istore        9
     342: aload         7
     344: invokeinterface #81,  1           // InterfaceMethod java/util/Iterator.hasNext:()Z
     349: ifne          301
     352: aload         8
     354: checkcast     #87                 // class dev/aspid812/leetcode/problem1854/PopulationRecord
     357: astore        4
     359: aload         4
     361: ifnull        372
     364: aload         4
     366: invokevirtual #94                 // Method dev/aspid812/leetcode/problem1854/PopulationRecord.getYear:()I
     369: goto          375
     372: sipush        1950
     375: ireturn
}

Compiled from "Solution.kt"
public final class dev.aspid812.leetcode.problem1854.SolutionKt {
  public static final int[][] makeLogs(kotlin.ranges.IntRange...);
    Code:
       0: aload_0
       1: ldc           #9                  // String lifespans
       3: invokestatic  #15                 // Method kotlin/jvm/internal/Intrinsics.checkNotNullParameter:(Ljava/lang/Object;Ljava/lang/String;)V
       6: aload_0
       7: astore_1
       8: iconst_0
       9: istore_2
      10: aload_1
      11: astore_3
      12: new           #17                 // class java/util/ArrayList
      15: dup
      16: aload_1
      17: arraylength
      18: invokespecial #21                 // Method java/util/ArrayList."<init>":(I)V
      21: checkcast     #23                 // class java/util/Collection
      24: astore        4
      26: iconst_0
      27: istore        5
      29: iconst_0
      30: istore        6
      32: aload_3
      33: arraylength
      34: istore        7
      36: iload         6
      38: iload         7
      40: if_icmpge     108
      43: aload_3
      44: iload         6
      46: aaload
      47: astore        8
      49: aload         4
      51: aload         8
      53: astore        9
      55: astore        12
      57: iconst_0
      58: istore        10
      60: iconst_2
      61: newarray       int
      63: astore        11
      65: aload         11
      67: iconst_0
      68: aload         9
      70: invokevirtual #29                 // Method kotlin/ranges/IntRange.getStart:()Ljava/lang/Integer;
      73: invokevirtual #35                 // Method java/lang/Integer.intValue:()I
      76: iastore
      77: aload         11
      79: iconst_1
      80: aload         9
      82: invokevirtual #38                 // Method kotlin/ranges/IntRange.getEndInclusive:()Ljava/lang/Integer;
      85: invokevirtual #35                 // Method java/lang/Integer.intValue:()I
      88: iconst_1
      89: iadd
      90: iastore
      91: aload         11
      93: aload         12
      95: swap
      96: invokeinterface #42,  2           // InterfaceMethod java/util/Collection.add:(Ljava/lang/Object;)Z
     101: pop
     102: iinc          6, 1
     105: goto          36
     108: aload         4
     110: checkcast     #44                 // class java/util/List
     113: nop
     114: checkcast     #23                 // class java/util/Collection
     117: astore_1
     118: nop
     119: iconst_0
     120: istore_2
     121: aload_1
     122: astore_3
     123: aload_3
     124: iconst_0
     125: anewarray     #46                 // class "[I"
     128: invokeinterface #50,  2           // InterfaceMethod java/util/Collection.toArray:([Ljava/lang/Object;)[Ljava/lang/Object;
     133: checkcast     #52                 // class "[[I"
     136: areturn

  public static final void main();
    Code:
       0: new           #74                 // class dev/aspid812/leetcode/problem1854/Solution
       3: dup
       4: invokespecial #76                 // Method dev/aspid812/leetcode/problem1854/Solution."<init>":()V
       7: astore_0
       8: iconst_2
       9: anewarray     #25                 // class kotlin/ranges/IntRange
      12: astore_2
      13: aload_2
      14: iconst_0
      15: sipush        1993
      18: sipush        1999
      21: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      24: aastore
      25: aload_2
      26: iconst_1
      27: sipush        2000
      30: sipush        2010
      33: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      36: aastore
      37: aload_2
      38: invokestatic  #84                 // Method makeLogs:([Lkotlin/ranges/IntRange;)[[I
      41: astore_1
      42: new           #86                 // class java/lang/StringBuilder
      45: dup
      46: invokespecial #87                 // Method java/lang/StringBuilder."<init>":()V
      49: aload_0
      50: aload_1
      51: invokevirtual #91                 // Method dev/aspid812/leetcode/problem1854/Solution.maximumPopulation:([[I)I
      54: invokevirtual #95                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
      57: ldc           #97                 // String  == 1993
      59: invokevirtual #100                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
      62: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
      65: getstatic     #110                // Field java/lang/System.out:Ljava/io/PrintStream;
      68: swap
      69: invokevirtual #116                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
      72: iconst_3
      73: anewarray     #25                 // class kotlin/ranges/IntRange
      76: astore_3
      77: aload_3
      78: iconst_0
      79: sipush        1950
      82: sipush        1961
      85: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
      88: aastore
      89: aload_3
      90: iconst_1
      91: sipush        1960
      94: sipush        1971
      97: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     100: aastore
     101: aload_3
     102: iconst_2
     103: sipush        1970
     106: sipush        1981
     109: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     112: aastore
     113: aload_3
     114: invokestatic  #84                 // Method makeLogs:([Lkotlin/ranges/IntRange;)[[I
     117: astore_2
     118: new           #86                 // class java/lang/StringBuilder
     121: dup
     122: invokespecial #87                 // Method java/lang/StringBuilder."<init>":()V
     125: aload_0
     126: aload_2
     127: invokevirtual #91                 // Method dev/aspid812/leetcode/problem1854/Solution.maximumPopulation:([[I)I
     130: invokevirtual #95                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     133: ldc           #118                // String  == 1960
     135: invokevirtual #100                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     138: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     141: getstatic     #110                // Field java/lang/System.out:Ljava/io/PrintStream;
     144: swap
     145: invokevirtual #116                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     148: iconst_5
     149: anewarray     #25                 // class kotlin/ranges/IntRange
     152: astore        4
     154: aload         4
     156: iconst_0
     157: sipush        1982
     160: sipush        1998
     163: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     166: aastore
     167: aload         4
     169: iconst_1
     170: sipush        2013
     173: sipush        2042
     176: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     179: aastore
     180: aload         4
     182: iconst_2
     183: sipush        2010
     186: sipush        2035
     189: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     192: aastore
     193: aload         4
     195: iconst_3
     196: sipush        2022
     199: sipush        2050
     202: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     205: aastore
     206: aload         4
     208: iconst_4
     209: sipush        2047
     212: sipush        2048
     215: invokestatic  #82                 // Method kotlin/ranges/RangesKt.until:(II)Lkotlin/ranges/IntRange;
     218: aastore
     219: aload         4
     221: invokestatic  #84                 // Method makeLogs:([Lkotlin/ranges/IntRange;)[[I
     224: astore_3
     225: new           #86                 // class java/lang/StringBuilder
     228: dup
     229: invokespecial #87                 // Method java/lang/StringBuilder."<init>":()V
     232: aload_0
     233: aload_3
     234: invokevirtual #91                 // Method dev/aspid812/leetcode/problem1854/Solution.maximumPopulation:([[I)I
     237: invokevirtual #95                 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
     240: ldc           #120                // String  == 2022
     242: invokevirtual #100                // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
     245: invokevirtual #104                // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
     248: getstatic     #110                // Field java/lang/System.out:Ljava/io/PrintStream;
     251: swap
     252: invokevirtual #116                // Method java/io/PrintStream.println:(Ljava/lang/Object;)V
     255: return

  public static void main(java.lang.String[]);
    Code:
       0: invokestatic  #128                // Method main:()V
       3: return
}

Compiled from "Solution.kt"
final class dev.aspid812.leetcode.problem1854.Solution$maximumPopulation$1 extends kotlin.coroutines.jvm.internal.RestrictedSuspendLambda implements kotlin.jvm.functions.Function2<kotlin.sequences.SequenceScope<? super dev.aspid812.leetcode.problem1854.PopulationRecord>, kotlin.coroutines.Continuation<? super kotlin.Unit>, java.lang.Object> {
  int I$0;

  int I$1;

  int I$2;

  int label;

  private java.lang.Object L$0;

  final int[] $birthYears;

  final int[] $deathYears;

  dev.aspid812.leetcode.problem1854.Solution$maximumPopulation$1(int[], int[], kotlin.coroutines.Continuation<? super dev.aspid812.leetcode.problem1854.Solution$maximumPopulation$1>);
    Code:
       0: aload_0
       1: aload_1
       2: putfield      #14                 // Field $birthYears:[I
       5: aload_0
       6: aload_2
       7: putfield      #17                 // Field $deathYears:[I
      10: aload_0
      11: iconst_2
      12: aload_3
      13: invokespecial #20                 // Method kotlin/coroutines/jvm/internal/RestrictedSuspendLambda."<init>":(ILkotlin/coroutines/Continuation;)V
      16: return

  public final java.lang.Object invokeSuspend(java.lang.Object);
    Code:
       0: invokestatic  #52                 // Method kotlin/coroutines/intrinsics/IntrinsicsKt.getCOROUTINE_SUSPENDED:()Ljava/lang/Object;
       3: astore        10
       5: aload_0
       6: getfield      #55                 // Field label:I
       9: tableswitch   { // 0 to 1
                     0: 32
                     1: 284
               default: 322
          }
      32: aload_1
      33: invokestatic  #61                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
      36: aload_0
      37: getfield      #64                 // Field L$0:Ljava/lang/Object;
      40: checkcast     #66                 // class kotlin/sequences/SequenceScope
      43: astore_2
      44: iconst_0
      45: istore_3
      46: new           #68                 // class kotlin/Pair
      49: dup
      50: iconst_0
      51: invokestatic  #74                 // Method kotlin/coroutines/jvm/internal/Boxing.boxInt:(I)Ljava/lang/Integer;
      54: iconst_0
      55: invokestatic  #74                 // Method kotlin/coroutines/jvm/internal/Boxing.boxInt:(I)Ljava/lang/Integer;
      58: invokespecial #77                 // Method kotlin/Pair."<init>":(Ljava/lang/Object;Ljava/lang/Object;)V
      61: astore        4
      63: aload         4
      65: invokevirtual #80                 // Method kotlin/Pair.component1:()Ljava/lang/Object;
      68: checkcast     #82                 // class java/lang/Number
      71: invokevirtual #86                 // Method java/lang/Number.intValue:()I
      74: istore        5
      76: aload         4
      78: invokevirtual #89                 // Method kotlin/Pair.component2:()Ljava/lang/Object;
      81: checkcast     #82                 // class java/lang/Number
      84: invokevirtual #86                 // Method java/lang/Number.intValue:()I
      87: istore        6
      89: iload         5
      91: aload_0
      92: getfield      #14                 // Field $birthYears:[I
      95: arraylength
      96: if_icmplt     109
      99: iload         6
     101: aload_0
     102: getfield      #17                 // Field $deathYears:[I
     105: arraylength
     106: if_icmpge     318
     109: aload_0
     110: getfield      #14                 // Field $birthYears:[I
     113: iload         5
     115: invokestatic  #95                 // Method kotlin/collections/ArraysKt.getOrNull:([II)Ljava/lang/Integer;
     118: dup
     119: ifnull        128
     122: invokevirtual #98                 // Method java/lang/Integer.intValue:()I
     125: goto          132
     128: pop
     129: sipush        2050
     132: istore        8
     134: aload_0
     135: getfield      #17                 // Field $deathYears:[I
     138: iload         6
     140: invokestatic  #95                 // Method kotlin/collections/ArraysKt.getOrNull:([II)Ljava/lang/Integer;
     143: dup
     144: ifnull        153
     147: invokevirtual #98                 // Method java/lang/Integer.intValue:()I
     150: goto          157
     153: pop
     154: sipush        2050
     157: istore        9
     159: iload         8
     161: iload         9
     163: invokestatic  #104                // Method java/lang/Math.min:(II)I
     166: istore        7
     168: iload         5
     170: aload_0
     171: getfield      #14                 // Field $birthYears:[I
     174: arraylength
     175: if_icmpge     199
     178: aload_0
     179: getfield      #14                 // Field $birthYears:[I
     182: iload         5
     184: iaload
     185: iload         7
     187: if_icmpne     199
     190: iinc          3, 1
     193: iinc          5, 1
     196: goto          168
     199: iload         6
     201: aload_0
     202: getfield      #17                 // Field $deathYears:[I
     205: arraylength
     206: if_icmpge     230
     209: aload_0
     210: getfield      #17                 // Field $deathYears:[I
     213: iload         6
     215: iaload
     216: iload         7
     218: if_icmpne     230
     221: iinc          3, -1
     224: iinc          6, 1
     227: goto          199
     230: aload_2
     231: new           #106                // class dev/aspid812/leetcode/problem1854/PopulationRecord
     234: dup
     235: iload         7
     237: iload_3
     238: invokespecial #109                // Method dev/aspid812/leetcode/problem1854/PopulationRecord."<init>":(II)V
     241: aload_0
     242: checkcast     #111                // class kotlin/coroutines/Continuation
     245: aload_0
     246: aload_2
     247: putfield      #64                 // Field L$0:Ljava/lang/Object;
     250: aload_0
     251: iload_3
     252: putfield      #113                // Field I$0:I
     255: aload_0
     256: iload         5
     258: putfield      #115                // Field I$1:I
     261: aload_0
     262: iload         6
     264: putfield      #117                // Field I$2:I
     267: aload_0
     268: iconst_1
     269: putfield      #55                 // Field label:I
     272: invokevirtual #121                // Method kotlin/sequences/SequenceScope.yield:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
     275: dup
     276: aload         10
     278: if_acmpne     314
     281: aload         10
     283: areturn
     284: aload_0
     285: getfield      #117                // Field I$2:I
     288: istore        6
     290: aload_0
     291: getfield      #115                // Field I$1:I
     294: istore        5
     296: aload_0
     297: getfield      #113                // Field I$0:I
     300: istore_3
     301: aload_0
     302: getfield      #64                 // Field L$0:Ljava/lang/Object;
     305: checkcast     #66                 // class kotlin/sequences/SequenceScope
     308: astore_2
     309: aload_1
     310: invokestatic  #61                 // Method kotlin/ResultKt.throwOnFailure:(Ljava/lang/Object;)V
     313: aload_1
     314: pop
     315: goto          89
     318: getstatic     #127                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
     321: areturn
     322: new           #129                // class java/lang/IllegalStateException
     325: dup
     326: ldc           #131                // String call to \'resume\' before \'invoke\' with coroutine
     328: invokespecial #134                // Method java/lang/IllegalStateException."<init>":(Ljava/lang/String;)V
     331: athrow

  public final kotlin.coroutines.Continuation<kotlin.Unit> create(java.lang.Object, kotlin.coroutines.Continuation<?>);
    Code:
       0: new           #2                  // class dev/aspid812/leetcode/problem1854/Solution$maximumPopulation$1
       3: dup
       4: aload_0
       5: getfield      #14                 // Field $birthYears:[I
       8: aload_0
       9: getfield      #17                 // Field $deathYears:[I
      12: aload_2
      13: invokespecial #144                // Method "<init>":([I[ILkotlin/coroutines/Continuation;)V
      16: astore_3
      17: aload_3
      18: aload_1
      19: putfield      #64                 // Field L$0:Ljava/lang/Object;
      22: aload_3
      23: checkcast     #111                // class kotlin/coroutines/Continuation
      26: areturn

  public final java.lang.Object invoke(kotlin.sequences.SequenceScope<? super dev.aspid812.leetcode.problem1854.PopulationRecord>, kotlin.coroutines.Continuation<? super kotlin.Unit>);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: invokevirtual #150                // Method create:(Ljava/lang/Object;Lkotlin/coroutines/Continuation;)Lkotlin/coroutines/Continuation;
       6: checkcast     #2                  // class dev/aspid812/leetcode/problem1854/Solution$maximumPopulation$1
       9: getstatic     #127                // Field kotlin/Unit.INSTANCE:Lkotlin/Unit;
      12: invokevirtual #152                // Method invokeSuspend:(Ljava/lang/Object;)Ljava/lang/Object;
      15: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: checkcast     #66                 // class kotlin/sequences/SequenceScope
       5: aload_2
       6: checkcast     #111                // class kotlin/coroutines/Continuation
       9: invokevirtual #157                // Method invoke:(Lkotlin/sequences/SequenceScope;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
      12: areturn
}