Third Maximum Number | LeetCode 414 Explained in C++ 🚀 | Easy Array Problem | Beginner Friendly

In this video, we solve LeetCode 414 - Third Maximum Number using a simple and beginner-friendly C++ approach 😄 📌 Given an integer array nums, return the third distinct maximum number in the array. If the third maximum does not exist, return the maximum number. Example 1 Input: nums = [3,2,1] Output: 1 Explanation: Distinct maximum numbers are: 3 → First Maximum 2 → Second Maximum 1 → Third Maximum ✅ Answer = 1 Example 2 Input: nums = [1,2] Output: 2 Explanation: There are only two distinct numbers, so return the maximum number. ✅ Example 3 Input: nums = [2,2,3,1] Output: 1 Explanation: Distinct numbers are: 3, 2, 1 Third maximum number is: 1 ✅ What You'll Learn ✅ Arrays ✅ Sorting ✅ Removing Duplicates ✅ Distinct Elements ✅ Vector Operations ✅ Beginner-Friendly DSA Approach 🔹 Sort the array. 🔹 Remove duplicate values. 🔹 Count distinct elements. 🔹 If there are at least 3 distinct numbers, return the third maximum. 🔹 Otherwise, return the largest number. Complexity Analysis ⏱ Time Complexity: O(n log n) 📦 Space Complexity: O(n) 🔥 Perfect for: ✔️ DSA Beginners ✔️ C++ Learners ✔️ Array Practice ✔️ Coding Interview Preparation ✔️ LeetCode Easy Problems 👍 If you found this video helpful, don't forget to Like, Share, and Subscribe! 💬 Comment your next LeetCode problem below. 🔔 Subscribe for more beginner-friendly DSA, C++, and LeetCode solutions. #leetcode #leetcode414 #thirdmaximumnumber #arrays #sorting #cpp #cplusplus #dsa #coding #programming #leetcodeeasy #algorithms #interviewprep #computerscience 🚀🔥