LeetCode 334: Increasing Triplet Subsequence Solution in Java

Day 9 of Daily DSA 🚀 Solved LeetCode 334: Increasing Triplet Subsequence ✅ 🔍 Approach: Implemented a greedy single-pass solution by tracking the smallest (a) and second smallest (b) and another smallest (c)values seen so far. Update a if a smaller value appears Update b if the value is greater than a but smaller than b If a value greater than both is found → update c → triplet exists No extra arrays, no sorting—just clean logic. ⏱ Complexity: • Time: O(n) • Space: O(1) 📊 LeetCode Stats: • Runtime: 2 ms (Beats 98.96%) ⚡ • Memory: 122.66 MB (Beats 56.98%) Great example of how a simple greedy observation make clean solution. #DSA #LeetCode #Java #GreedyAlgorithm #ProblemSolving #Consistency #DailyCoding

  • graphical user interface, text

To view or add a comment, sign in

Explore content categories