This file tests advanced Scriba features based solely on the reference document.
Given array a=[3,1,4,1,5]a = [3, 1, 4, 1, 5]a=[3,1,4,1,5], compute the LIS length at each index.
Array a=[3,1,4,1,5]a = [3,1,4,1,5]a=[3,1,4,1,5]. We compute dp[i]dp[i]dp[i] = LIS length ending at index iii.
Base case: dp[0]=1dp[0] = 1dp[0]=1. All others start unknown.
Start scanning from index 0. The cursor highlights the current cell.
Move cursor to index 1. Previous cell marked done.
Move cursor to index 2.
dp[2]=2dp[2] = 2dp[2]=2: we can extend from dp[0]dp[0]dp[0] since a[0]=3<a[2]=4a[0]=3 < a[2]=4a[0]=3<a[2]=4.
dp[3]=1dp[3] = 1dp[3]=1: no previous element is smaller than a[3]=1a[3]=1a[3]=1.
dp[4]=3dp[4] = 3dp[4]=3: extend from dp[2]dp[2]dp[2] since a[2]=4<a[4]=5a[2]=4 < a[4]=5a[2]=4<a[4]=5.
Mark even-indexed elements. The LIS length is 3.
Traceback: highlight the optimal LIS path in the DP table.
Recolor transition arrows along the optimal path.
Let us verify the sub-problem for index 2 in detail.
Compare a[0]=3a[0]=3a[0]=3 with a[2]=4a[2]=4a[2]=4: since 3<43 < 43<4, we can extend.
Confirmed: dp[2]=dp[0]+1=2dp[2] = dp[0] + 1 = 2dp[2]=dp[0]+1=2.
Final answer at index $target_idx=4{target\_idx} = 4target_idx=4: LIS length is dp[4]=3dp[4] = 3dp[4]=3.