Documentation·
vishal8113/Hacktoberfest-2024
Document longest increasing subsequence with a Java example
Adds a Markdown walkthrough of the longest strictly increasing subsequence problem under the Java arrays directory. The embedded Java implementation computes the subsequence length using dynamic programming.
The problem
The example asks for the length of the longest strictly increasing subsequence in an integer array. The solution must preserve element order while allowing elements to be skipped, and equal values must not extend a subsequence.
The approach
Initialize a DP array with length one for each element, then compare each element with all earlier elements. When an earlier value is smaller, extend its subsequence length and retain the maximum for the current position. Return the largest DP value, with an explicit return of zero for an empty array.
What changed
Adds an embedded Java solution and a main-method demonstration whose annotated result is 4 for the supplied array. The implementation uses O(n²) time and O(n) auxiliary space; the PR adds documentation rather than a standalone Java source file or automated tests.
- java
- dynamic-programming
- arrays
- longest-increasing-subsequence