Day 10/100 – #100DaysOfCode 🚀 Solved LeetCode #66 – Plus One (Python). Today I worked on an array manipulation problem that simulates adding one to a large integer represented as a list of digits. Approach: 1) Traverse the array from the last digit to the first. 2) If the current digit + 1 is not equal to 10, simply increment it and return the array. 3) If the digit becomes 10, set it to 0 and carry over to the next digit. 4) If the carry reaches the first digit, add 1 at the beginning of the array. Time Complexity: O(n) Space Complexity: O(1) Understanding how carry propagation works in arrays 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
LeetCode #66: Plus One Array Solution
More Relevant Posts
-
Day 12/100 – #100DaysOfCode 🚀 Solved LeetCode #217 – Contains Duplicate (Python). Today I worked on an array problem to determine whether any value appears at least twice in the array. Approach: 1) Sort the array first. 2) Traverse through the array from index 0 to n-2. 3) Compare each element with the next element. 4) If two adjacent elements are equal, a duplicate exists. 5) If no duplicates are found after traversal, return False. Time Complexity: O(n log n) due to sorting Space Complexity: O(1) Understanding how sorting can simplify duplicate detection in arrays 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
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
-
-
Day 30/100 – #100DaysOfCode 🚀 Solved LeetCode #1299 – Replace Elements with Greatest Element on Right Side (Python). Today I practiced reverse traversal to efficiently replace each element with the greatest element on its right. Approach: 1) Initialize max_right = -1. 2) Traverse the array from right to left. 3) Store the current element in a temporary variable. 4) Replace the current element with max_right. 5) Update max_right as the maximum of max_right and the stored value. 6) Continue until the entire array is processed. Time Complexity: O(n) Space Complexity: O(1) Learning how reverse traversal can simplify problems efficiently 💪 #LeetCode #Python #DSA #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
Day 19 of #100DaysOfPython Today was about instances, state, and higher-order functions. I built a Turtle Race Game using Python’s turtle module. I created multiple turtle instances, each with its own color and position, then made them race using random movement speeds until one wins. This project helped me understand: How different instances can be created from the same class How each instance maintains its own state (position, movement, etc.) How to use functions in a more flexible way when controlling behavior It was a fun way to see objects come to life and interact on the screen. Starting to think more in terms of objects and behavior, not just lines of code. #100DaysOfCode #100DaysOfPython #Python #OOP #PythonProjects #TurtleGraphics #LearningToCode #CodingJourney #BuildInPublic
To view or add a comment, sign in
-
Longest Common Prefix: Column-Wise Early Exit Beats Pairwise Comparison Comparing strings pairwise requires multiple passes. Column-wise iteration checks all strings at each character position simultaneously — first mismatch or string exhaustion returns accumulated prefix. Early termination saves processing remaining characters. Early Exit Advantage: Best case (short prefix): O(m) where m = prefix length. Worst case: O(n × k) where k = min string length. Column-wise processing enables stopping the moment consensus breaks. Time: O(n × m) | Space: O(m) #StringAlgorithms #EarlyTermination #CommonPrefix #ColumnWiseProcessing #Python #AlgorithmOptimization #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 Day 25 — DSA + Python Today I practiced Array Rotation problems. ✅ Learned: Left rotation Right rotation Rotation by K positions 💡 Understood the logic of shifting elements and how to think about better approaches instead of brute force. Practicing arrays is helping me build stronger problem-solving skills in DSA. #DSA #Python #CodingJourney #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 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
To view or add a comment, sign in
-
-
I recently implemented the K-Medoids clustering algorithm from scratch in Python and visualized the clusters using graphs to understand how the algorithm groups data points. #MachineLearning #PythonProjects https://lnkd.in/gczybNGr
To view or add a comment, sign in
Explore related topics
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