Maximum Value of an Ordered Triplet I and II | Leetcode 2874 | Leetcode 2873