Day 19/100 – #100DaysOfCode 🚀 Solved LeetCode #414 – Third Maximum Number (Python). Today I worked on an array problem to find the third distinct maximum number in the array. If it does not exist, return the maximum number. Approach: 1) Remove duplicates by converting the array into a set. 2) Convert it back to a list. 3) Sort the list in ascending order. 4) If the length is ≥ 3, return the third maximum element. 5) Otherwise, return the maximum element. Time Complexity: O(n log n) Space Complexity: O(n) Understanding how sets help remove duplicates efficiently 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
LeetCode #414: Third Maximum Number in Array
More Relevant Posts
-
Day 39/100 – #100DaysOfCode 🚀 Solved LeetCode #2215 – Find the Difference of Two Arrays (Python). Today I practiced set operations to efficiently find distinct elements between two arrays. Approach: 1) Convert both arrays into sets to remove duplicates. 2) Find elements present in nums1 but not in nums2 using set difference. 3) Find elements present in nums2 but not in nums1. 4) Convert both results back to lists. 5) Return the final list of differences. Time Complexity: O(n + m) Space Complexity: O(n + m) Understanding how set operations simplify comparison problems 💪 #LeetCode #Python #DSA #Sets #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 38/100 – #100DaysOfCode 🚀 Solved LeetCode #2011 – Final Value of Variable After Performing Operations (Python). Today I practiced string handling and simple iteration to compute the final value after a series of operations. Approach: 1) Initialize a variable x = 0. 2) Traverse through each operation in the list. 3) If the operation contains "++", increment x by 1. 4) Otherwise, decrement x by 1. 5) Return the final value of x. Time Complexity: O(n) Space Complexity: O(1) Simple logic but great practice for handling strings and loops 💪 #LeetCode #Python #DSA #Strings #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Hot take: Python is fast enough for most things. For the other things? 🦀 Rust. Just published a guide on using PyO3 v0.28 + maturin to drop Rust into your Python stack — the same approach Polars, Ruff, and Pydantic v2 use. One function. Native speed. Still pip install-able. 👉 https://lnkd.in/g794MZxa #Rust #Python #PyO3 #Engineering #Performance
To view or add a comment, sign in
-
-
Day 33/100 – #100DaysOfCode 🚀 Solved LeetCode #1480 – Running Sum of 1d Array (Python). Today I practiced prefix sum logic to compute the running sum of an array. Approach: 1) Initialize an empty list to store the running sum. 2) Maintain a variable sum = 0. 3) Traverse the array and keep adding each element to sum. 4) Append the updated sum to the result list. 5) Return the final running sum array. Time Complexity: O(n) Space Complexity: O(n) Understanding prefix sums helps solve many array problems efficiently 💪 #LeetCode #Python #DSA #Arrays #PrefixSum #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Some days, VS Code feels like a puzzle I didn’t sign up for. Setting up a simple thing like Python with Conda base turned into hours of confusion. Paths, terminals, environments… nothing talks to each other at first. But I’m learning: frustration is part of the process, not a sign to quit. Slowly, things start to make sense. #techjourney #womenintech #datasciencejourney #vscode #python #conda #beginnertodev
To view or add a comment, sign in
-
Day 42/100 – #100DaysOfCode 🚀 Solved LeetCode #2574 – Left and Right Sum Differences (Python). Today I practiced prefix sum logic to calculate the absolute difference between left and right sums for each index. Approach: 1) Calculate the total sum of the array. 2) Initialize leftSum = 0. 3) Traverse the array. 4) For each index, compute rightSum = total - leftSum - nums[i]. 5) Calculate the absolute difference and append it to the result. 6) Update leftSum by adding nums[i]. Time Complexity: O(n) Space Complexity: O(n) Understanding prefix sum helps solve problems efficiently 💪 #LeetCode #Python #DSA #Arrays #PrefixSum #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 24/100 – #100DaysOfCode 🚀 Solved LeetCode #747 – Largest Number At Least Twice of Others (Dominant Index) (Python). Today I practiced array traversal and comparison logic to find the dominant index in the array. Approach: 1) Find the largest element in the array and its index. 2) Traverse through the array. 3) For every other element, check if the largest is at least twice of it. 4) If any element violates this condition, return -1. 5) If all conditions are satisfied, return the index of the largest element. Time Complexity: O(n) Space Complexity: O(1) Learning how simple comparisons can solve array problems efficiently 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 31/100 – #100DaysOfCode 🚀 Solved LeetCode #1346 – Check If N and Its Double Exist (Python). Today I practiced brute-force comparison to check whether there exist two indices i and j such that arr[i] = 2 * arr[j]. Approach: 1) Use two nested loops to check all possible pairs. 2) Ensure that i ≠ j. 3) For each pair, check if arr[i] == 2 * arr[j]. 4) If condition is satisfied, return True. 5) If no such pair is found, return False. Time Complexity: O(n²) Space Complexity: O(1) Starting with brute force helps build understanding before optimization 💪 #LeetCode #Python #DSA #Arrays #BruteForce #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🤜 Python Challenge #7 – Answer Revealed! Python slicing can also work in reverse using a negative step. In s[::-2]: 👉 It starts from the end of the string 👉 Moves backward 👉 Picks every 2nd character For s = "Python": n -> h -> y Output: nhy #python #pythonchallenge #codechallenge #code #pythonslicing #string #challenge
To view or add a comment, sign in
-
-
🚀 Day 2 — Python Journey Continuing with Python, today I focused on integer operations. 📌 What I learned: - Integer declaration - Addition, subtraction, multiplication - Division and modulus (remainder) - Power operation - Operator precedence (which operation runs first) 💡 What stood out: Understanding operator precedence is really important — the same expression can give different results if you don’t know the order of execution. Also, modulus (%) is more useful than it looks (especially for problems and logic building). Trying to stay consistent and build strong basics step by step. #Day2 #Python #CodingJourney #Consistency #LearnInPublic
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development