LIS algorithm