You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: longest_increasing_subsequence_nlogn.rb
    path of file: ./repos/algorithms/src
    
    the code of the file until where you have to start completion: #nlogn
def l
    
def lis arr
  return [] if arr.empty?
  n = arr.size
  pre = [-1]
  len = [0]

  1.upto(n-1) do |i|
    # binary search first pos s.t. arr[len[pos]] >= arr[i]
    left, right, mid, pos = 0, len.size-1, -1, len.size
    while left <= right
      mid = left + (right - left) / 2
      if arr[len[mid]] >= arr[i]
        right = mid - 1
        pos = mid 
      else
        left = mid + 1
      end
    end