Day 35/ 100- Plus One Today I worked on the Plus One problem, where a number is represented as an array of digits and we need to increment it by one. => Key Idea Start from the last digit Handle carry properly when digits are 9 If all digits are 9, add a new leading 1 => Optimized Approach Traverse from right to left Update digits in-place Time Complexity: O(n) Space Complexity: O(1) (excluding output) code https://lnkd.in/gsiFHb8c #Python #DSA #100DaysOfCode #ProblemSolving #CodingJourney #LeetCode
Incrementing Plus One Array in Python
More Relevant Posts
-
📅 Day 01 – LeetCode Progress Update Solved LeetCode #1: Two Sum using a brute-force approach. 🔹 Logic Used Traverse the array using two nested loops Check all possible pairs to find the target sum 🔹 Why this approach? Simple and easy to understand Helpful for building strong fundamentals Good starting point before optimization 🔹 Complexity Time: O(n²) Space: O(1) 📌 Consistency over intensity—one problem, one step forward every day. #LeetCode #Day1 #Python #DSA #CodingPractice #ProblemSolving #DeveloperJourney
To view or add a comment, sign in
-
-
Daily LeetCode Question | Day 1 ✅ LeetCode 1351: Count Negative Numbers in a Sorted Matrix ✔️ Used the two-pointer (staircase) approach starting from the top-right corner of the matrix. At each step, I leveraged the row-wise and column-wise sorted property to eliminate multiple elements at once instead of checking every cell. 🔹 Approach: Two Pointers (Staircase Search) 🔹 Time Complexity: O(m + n) 🔹 Space Complexity: O(1) This optimized approach avoids brute force and binary search, making it both efficient and interview-friendly. #LeetCode #DSA #TwoPointers #ProblemSolving #Python #CodingJourney
To view or add a comment, sign in
-
-
Daily LeetCode Progress | Day 14✅ LeetCode #3 | Longest Substring Without Repeating Characters ✔️ 🧠 Approach: • Applied a sliding window (two pointers) technique to maintain a substring with all unique characters. • Used a set to track characters in the current window for constant-time duplicate checks. • When a duplicate was encountered, shifted the left pointer until the window became valid again 🔁 • Continuously updated the maximum window size while expanding the right pointer for optimal results 📈 ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(n) “Efficiency is not about doing more, it’s about doing it right.” #LeetCode #DataStructures #SlidingWindow #Python #Consistency
To view or add a comment, sign in
-
-
Each December, Advent of Code issues a series of coding challenges for programmers to solve. This article looks at the twelfth (and final) problem for 2025, and a suggestion for solving from Andreas Hiltebrand: https://bit.ly/4qiAGVl #ansys #simulation #engineering #python #pyansys #adventofcode
To view or add a comment, sign in
-
-
#Day3 of #100DaysofAI Day 3 was packed with Python control flow mastery and function building! Revised if/elif/else, for/while loops with break/continue, list comprehensions, then wrote 8 practical functions (add/subtract/multiply/divide, even/odd checker, prime tester, reverse number, Fibonacci generator). Built a Simple Calculator and Number Guessing Game as mini-projects. Key takeaway: print() shows output, return computes values — functions must return, never assign print() to variables. Control flow is logic's backbone! #AIJourney #LearningInPublic #Python #ArtificialIntelligence #BuildInPublic
To view or add a comment, sign in
-
🎮✋🏻Built a gesture-controlled game🔥 using Python and OpenCV. This project transforms a webcam into a game controller by mapping real-time hand gestures to movement actions such as left, right, jump, and duck—eliminating the need for a keyboard. 🔑Key features include: - Compatibility with Python 3.13 - Smooth gesture filtering using Exponential Moving Average (EMA) and frame voting - A computer vision-based control system 👉🏻For more details, visit the GitHub repository: https://lnkd.in/gUd5zP3u #Python #OpenCV #ComputerVision #AIProjects #GitHub #LearningByDoing
To view or add a comment, sign in
-
✅ Day 1 of 100 Covered Python variables and string manipulation—loved the conceptual "necklace" analogy for strings. Applied it by building a Band Name Generator: a script that prompts for your city and pet's name, then prints a combined result. Hands-on practice with print(), input handling, and basic debugging. A well-structured first lesson that blends theory with immediate application. #python #100DaysOfCode
To view or add a comment, sign in
-
-
Played around with FastAPI, Python threading, Streamlit, and Matplotlib to compare Sequential vs Threading. Same workload, same processing only the execution model changed. Put together a small Streamlit dashboard with Matplotlib charts to visualize the difference instead of relying on logs. Chect it out on Github , will extend this next with more advanced threading patterns. Github link : https://lnkd.in/gXZDsX3h #Python #FastAPI #Threading #Streamlit #Performance
To view or add a comment, sign in
-
-
✨ Day 69 of #100DaysOfDSA 📌 LeetCode 961: N-Repeated Element in Size 2N Array A neat problem that highlights how problem constraints can guide us to an optimal solution. 🧩 Problem Insight: The array has 2n elements Only one element repeats n times The rest appear exactly once 🧠 Approach & How It Works: Use a hash set to track visited elements Traverse the array once The first element that appears again must be the answer due to the given constraints ⚡ This guarantees a single-pass solution with immediate detection. ⚙️ Performance: 🚀 Runtime: 0 ms (beats 100%) 📦 Memory: 13.28 MB (beats 85.16%) ✅ Testcases Passed: 103 / 103 📘 What I Learned: ✔ Leveraging problem constraints for faster solutions ✔ Efficient use of hash sets ✔ Writing clean O(n) time complexity code ✔ Early exit strategies for optimization Consistency > Motivation. One problem at a time 💪 #LeetCode #DSA #Array #RepeatedElements #100DaysOfDSA #100DaysOfCode #Python #ProblemSolving #CodingPractice #TechJourney
To view or add a comment, sign in
-
-
Today I solved the Longest Common Prefix problem, which focuses on string comparison and edge-case handling. 🔹 Problem: Given an array of strings, find the longest prefix common to all strings. If no common prefix exists, return an empty string. 🔹 Approach: ✔️ Take the first string as a reference ✔️ Compare characters index-by-index with all other strings ✔️ Stop immediately when a mismatch occurs #DSA #Python #ProblemSolving #CodingPractice #LeetCode #LearningJourney #SoftwareEngineering #Consistency
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