Day 47 — #100DaysOfLeetCode 🚀 Problem: Reverse Words in a String (LeetCode 151) ✅ Approach: Trim spaces, split the string, reverse the words, and join them back. ⚡ Complexity: O(n) Learning: Improved string handling and manipulation efficiency 🔁 Every line of code adds clarity and confidence 💪 #LeetCode #100DaysOfCode #DSA #Strings #ProblemSolving #CodingJourney
Reversing words in a string with LeetCode 151
More Relevant Posts
-
Day 46 — #100DaysOfLeetCode 🚀 Problem: Remove Duplicate Letters (LeetCode 316) ✅ Approach: Used a Stack + Greedy approach to build the smallest lexicographical string with unique letters. ⚡ Complexity: O(n) Learning: Strengthened understanding of stack-based string manipulation and greedy logic 🔠 #LeetCode #100DaysOfCode #DSA #Strings #Stack #GreedyAlgorithm #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🚀 Day 37 of #100DaysOfCode Challenge 🚀 🧠 Problem: 🧩 LeetCode 282 — Expression Add Operators (Hard) This problem was all about exploring backtracking with arithmetic logic. We’re given a string of digits and need to insert +, -, or * between them to reach a target value. ⚙️ Approach Used backtracking to: -Pick every possible substring as the next number. -Try adding each operator before it (+, -, *). -Track three things: -current value → total so far -previous operand → to handle multiplication correctly -expression → the string we’re building -Also skipped invalid paths like numbers with leading zeros. 📘 Learning -Understood how to evaluate expressions on the fly without using eval(). -Learned to manage operator precedence (* before +/-) using recursion and previous operand adjustment. -Realized that some problems can’t be optimized further — they test how well you can prune and organize recursion. #100DaysOfCode #DSA #CodingChallenge #StriversSheet #ProblemSolving #TakeUForward #Recursion #CodingInterview #ProgrammingTips #LeetCode #Backtracking
To view or add a comment, sign in
-
-
🔹 Day 70 of #100DaysOfLeetCodeChallenge 🔹 🚀 Problem: Combination Sum III 🔑 Topic: Backtracking 🧠 Approach: We need to find all combinations of k distinct numbers (1–9) that sum to n. Here’s how I solved it 👇 Use backtracking to explore all combinations starting from 1 to 9. Add the number and move forward recursively, reducing both k (count) and n (target). Stop when k == 0 and n == 0 → valid combination found! Backtrack by removing the last number and continue exploring. ⏳ Time Complexity: O(2⁹) ≈ O(512) 💾 Space Complexity: O(k) (recursion + temp list) 📌 Example: Input: k = 3, n = 9 Output: [[1,2,6],[1,3,5],[2,3,4]] ✅ 🎯 Takeaway: This problem teaches the power of controlled recursion — when both depth and sum conditions guide the search efficiently. 💡 #LeetCode #DSA #Backtracking #ProblemSolving #CodingChallenge #100DaysOfLeetCodeChallenge 🚀
To view or add a comment, sign in
-
-
🔹 Day 69 of #100DaysOfLeetCodeChallenge 🔹 🚀 Problem: Subsets II 🔑 Topic: Backtracking 🧠 Approach: The task is to find all unique subsets of an array that may contain duplicates. Here’s the step-by-step logic 👇 Sort the array first to bring duplicates together. Use backtracking to explore every possible subset. Skip duplicates by checking if the current element equals the previous one at the same recursion depth. Add every subset (including empty) to the result list. ⏳ Time Complexity: O(2^n) 💾 Space Complexity: O(n) (recursion stack + temp list) 📌 Example: Input: nums = [1,2,2] Output: [[], [1], [1,2], [1,2,2], [2], [2,2]] ✅ 🎯 Takeaway: Sorting and skipping duplicates isn’t just for combinations — it’s the secret weapon for clean subset generation too! ⚡ #LeetCode #DSA #Backtracking #Subsets #ProblemSolving #CodingChallenge #100DaysOfLeetCodeChallenge 🚀
To view or add a comment, sign in
-
-
🚀 Day 7 of #120DaysOfCode Challenge 💡 Problem: Reverse Integer (LeetCode #7 | Medium) 📄 Problem Statement: Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes it to go outside the signed 32-bit integer range [-2³¹, 2³¹ - 1], then return 0. 🧩 My Approach: Extract the last digit of x using % 10. Build the reversed number step by step using rev = rev * 10 + digit. Carefully check for overflow before multiplying or adding — using INT_MAX and INT_MIN limits to ensure the reversed number stays valid. If overflow is detected, return 0. 🔍 Key Learnings: How to handle integer overflow without using 64-bit variables. Importance of edge case testing and boundary conditions. Reinforced understanding of modulus (%) and integer division (/) operations. 🔥 Progress: Day 7 / 120 📚 Language: C 🏁 Problem Solved: Reverse Integer (LeetCode #7) Every problem is a small step toward stronger logic and cleaner code! 💪 #100DaysOfCode #120DaysOfCode #CodingChallenge #LeetCode #CProgramming #ProblemSolving #LearnEveryday #BuildInPublic
To view or add a comment, sign in
-
-
💡 Day 78 of #100DaysOfCode 💡 🔹 Problem: Find Closest Number to Zero – LeetCode ✨ Approach: Traversed through the array while keeping track of the number closest to zero using absolute difference comparison. Handled ties by preferring the positive number — because even in code, positivity wins 😉 📊 Complexity Analysis: ⏱ Time Complexity: O(n) — single pass through the array 💾 Space Complexity: O(1) — no extra space used ✅ Runtime: 3 ms (Beats 44.80%) ✅ Memory: 46.87 MB 🔑 Key Insight: Even the smallest differences matter — especially when you’re finding what’s closest to zero! ⚡ #LeetCode #100DaysOfCode #DSA #ProblemSolving #CodingChallenge #JavaProgramming #AlgorithmDesign #CodeJourney #StayPositive
To view or add a comment, sign in
-
-
Day 36 — #100DaysOfLeetCode 🚀 Problem: Average Salary Excluding the Minimum and Maximum Salary (LeetCode 1491) ✅ Approach: Remove min & max, then calculate the average of remaining elements. ⚡ Complexity: O(n) Learning: Practiced clean logic writing and handling edge cases with arrays 🔥 #LeetCode #100DaysOfCode #DSA #Arrays #ProblemSolving #CodingJourney
To view or add a comment, sign in
-
-
🔥 Day 92 of My LeetCode Journey — Problem 28: Find the Index of the First Occurrence in a String 💡 Problem Insight: Today’s problem was about finding the first occurrence of a substring (needle) inside another string (haystack). Essentially, it’s like implementing your own version of the strStr() function — a classic problem in string searching. 🧠 Concept Highlight: This challenge sharpens understanding of string traversal and pattern matching. The intuitive solution uses simple iteration and substring comparison, while the optimized approach can involve algorithms like KMP (Knuth-Morris-Pratt) for efficient searching. 💪 Key Takeaway: Sometimes, even built-in functions hide deep logic beneath simplicity — mastering these fundamentals builds confidence for more advanced string algorithms. ⚙️ Daily Reflection: Every search begins with clarity — whether in code or in life. Precision and patience always lead to the right match. #Day92 #LeetCode #100DaysOfCode #StringSearch #PatternMatching #ProblemSolving #DSA #CodingJourney #LearnByDoing #SoftwareEngineering
To view or add a comment, sign in
-
-
✅ LeetCode Top 150 – Day 43 | Revision Day Today was all about reinforcing fundamentals and strengthening problem-solving intuition. I revisited 3 problems across difficulty levels and focused on patterns + intuition rather than just code. 🍬 1. Candy (Hard) Key Takeaways: Classic greedy + two-pass problem Maintain fairness by checking left → right and then right → left When values increase, give more; when values decrease, adjust backwards Intuition: Local constraints + global minimum 📌 Learning: Greedy isn't always one-directional — sometimes symmetry is the key. 💧 2. Trapping Rain Water (Hard) Key Takeaways: Key insight: Water trapped depends on min(maxLeft, maxRight) Approaches: Prefix-suffix arrays (O(n) space) Two-pointer optimal approach (O(1) space) Great example of thinking in constraints, not brute force 📌 Learning: Recognize patterns where global boundaries influence local results. 🏛️ 3. Roman to Integer (Easy) Key Takeaways: Understand subtraction rule: If current < next → subtract else add Efficient use of mapping Good revision of string traversal + conditional logic 📌 Learning: Small problems build intuition for bigger greedy patterns. #LeetCode #dsa #coding #softwareengineering #leetcode150 #learningjourney #consistencyWins
To view or add a comment, sign in
-
⚡ Day 97 of My LeetCode Journey — Problem 328: Odd Even Linked List 💡 Problem Insight: Today’s problem focused on rearranging a singly linked list so that all nodes at odd indices come first, followed by all even-indexed nodes — while maintaining their relative order. A great challenge to test how well you understand pointer manipulation! 🧠 Concept Highlight: The solution revolves around re-linking nodes using two pointers — one tracking odd nodes and another for even nodes. By carefully connecting them, we achieve the rearrangement in-place without extra space. It’s a smart exercise in linked list restructuring and pointer logic. 💪 Key Takeaway: Organizing efficiently — whether in data or in life — often means rearranging, not replacing. A small change in order can create big clarity. ✨ Daily Reflection: Linked lists truly train the mind to think sequentially and structurally — every link counts, just like every day of consistent learning. #Day97 #LeetCode #100DaysOfCode #LinkedList #ProblemSolving #DSA #CodingJourney #LearnByDoing #SoftwareEngineering #Pointers
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