✅ Day 96 of 100 Days LeetCode Challenge Problem: 🔹 #2278 – Percentage of Letter in String 🔗 https://lnkd.in/g8fEbrKG Learning Journey: 🔹 Today’s problem focused on calculating the percentage of a specific character in a string. 🔹 I iterated through the string and counted how many times the given letter appears. 🔹 Simultaneously tracked the total length of the string. 🔹 Then computed the percentage using the formula: (count / length) * 100. 🔹 Used floor division (via math.floor) to round down the result to the nearest integer. Concepts Used: 🔹 String Traversal 🔹 Counting Frequency 🔹 Basic Math Computation 🔹 Floor Operation Key Insight: 🔹 The problem is straightforward counting, but careful handling of rounding is important. 🔹 Using a single pass keeps the solution efficient and clean. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge: Percentage of Letter in String
More Relevant Posts
-
🚀 Exploring Python Performance: List vs NumPy Array Recently, I experimented with comparing execution time and memory usage between Python lists and NumPy arrays using Jupyter Notebook. 🔍 Key Observations: • List comprehension took significantly more time for computation • NumPy arrays performed the same operation much faster ⚡ • Memory usage was also more efficient with NumPy arrays 💡 Conclusion: When working with large datasets or numerical computations, NumPy is clearly the better choice due to its optimized performance and lower memory consumption. This small experiment reinforced how choosing the right data structure can make a huge difference in performance! #Python #NumPy #DataScience #MachineLearning #Coding #PerformanceOptimization #JupyterNotebook
To view or add a comment, sign in
-
-
🚀 Day 33 – LeetCode Journey Today’s problem: Move Zeroes ✔️ Used two-pointer technique for in-place modification ✔️ Moved all non-zero elements forward efficiently ✔️ Maintained relative order of elements 💡 Key Insight: By keeping a pointer for non-zero elements, we can swap values in a single pass and avoid extra space — making the solution both clean and optimal. This problem improved my understanding of array manipulation and in-place algorithms. Consistency is building confidence day by day 💪🔥 #LeetCode #Day33 #Arrays #TwoPointers #Python #ProblemSolving #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Today: LeetCode 88 — Merge Sorted Array. Saw "sorted arrays" in the problem. My brain immediately said: two pointers. Started coding. Got stuck pretty fast. The issue? When you're merging into an existing array without extra space, two pointers aren't enough — you need a third one tracking where to place elements. And you have to go backwards through nums1, or you'll overwrite values you still need. Took longer than I'd like to admit. Used hints. Eventually got it — and it beat 100% on runtime. The real lesson wasn't the algorithm. It was this: pattern recognition gets you to the door, but you still have to figure out which version of the pattern fits. "Two pointers" is a family of techniques, not a single move. Knowing the name isn't the same as understanding the shape of the problem. Day 36 of #1000DaysOfLearning #DSA #Python #LearningInPublic
To view or add a comment, sign in
-
-
From “it works” to “it won’t break” While writing a code, Getting it to work is one thing, 𝗠𝗮𝗸𝗶𝗻𝗴 𝘀𝘂𝗿𝗲 𝗶𝘁 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗯𝗿𝗲𝗮𝗸 is another. price = products["Laptop"] This works fine… until the 𝗸𝗲𝘆 𝗱𝗼𝗲𝘀𝗻’𝘁 𝗲𝘅𝗶𝘀𝘁 . That’s when the program crashes. So instead of assuming every piece of data is present, Its better to start thinking about what happens when it isn’t. In college projects, we often focus on making things work. In real-world scenarios, 𝗲𝗱𝗴𝗲 𝗰𝗮𝘀𝗲𝘀 matter just as much. 𝗗𝗮𝘆 𝟭𝟮/𝟯𝟬 #Python #LearningInPublic #Day12 #30DaysOfCode #SoftwareEngineering
To view or add a comment, sign in
-
Day 2/100: Logic & Math in Python! 🐍💸 Day 2 of my #100DaysOfCode challenge is in the books! Today’s focus was on handling user input, data types, and mathematical operations. I built a Tip Calculator project that handles bill splitting and percentage calculations—a simple but essential exercise in ensuring data accuracy and clean logic. What I practiced today: ->Type conversion (String to Float/Int) ->F-strings for clean output ->Floating-point precision 🔗 GitHub: https://lnkd.in/gWWzMYdn Small wins every day lead to big victories! Onward to Day 3. ⚔️ #Python #100DaysOfCode #LogicBuilding #CodingChallenge #GrowthMindset #DevCommunity
To view or add a comment, sign in
-
Excited to share my latest project: Page Replacement Algorithm Simulator Built using Python, this interactive application visualizes how memory management works in Operating Systems by simulating FIFO, LRU, LFU, and Optimal algorithms. It provides step-by-step execution, real-time metrics (page faults, hits, hit ratio), and insightful graphical analysis using matplotlib. With a clean dark-themed UI, playback controls, and comparative dashboards, the project transforms theoretical concepts into an intuitive, hands-on learning experience. This project helped me strengthen my understanding of OS concepts while also enhancing my skills in Python, GUI development, and data visualization. #Python #OperatingSystems #Algorithms #Projects #Learning #SoftwareDevelopment
To view or add a comment, sign in
-
Day 43/100 – #100DaysOfCode 🚀 Solved LeetCode #2610 – Convert an Array Into a 2D Array With Conditions (Python). Today I practiced hashmap (frequency counting) to construct a 2D array based on given conditions. Approach: 1) Create a frequency map to count occurrences of each element. 2) Initialize an empty result list. 3) While the frequency map is not empty: 4) Create a new row. 5) Iterate through keys and add each number once to the row. 6) Decrease its frequency and remove it if it becomes zero. 7) Add the row to the result. 8) Return the final 2D array. Time Complexity: O(n) Space Complexity: O(n) Learning how frequency maps help in structuring data efficiently 💪 #LeetCode #Python #DSA #HashMap #Arrays #ProblemSolving #100DaysOfCode
To view or add a comment, sign in
-
-
🚀 Just solved the “Valid Number” problem on LeetCode! This problem looks simple at first glance—but handling edge cases like decimals, signs, and exponents makes it a great test of attention to detail and logical thinking. ✅ Key takeaways: Careful handling of edge cases is crucial Validating input step-by-step can simplify complex parsing problems Writing clean, readable logic beats overcomplicated solutions 💡 Performance: ⚡ Runtime: 3 ms 🧠 Efficient space usage ✅ All test cases passed Problems like this remind me that consistency in practice is what builds strong problem-solving skills. On to the next one! 🔥 #LeetCode #Coding #Python #ProblemSolving #SoftwareEngineering #AIEngineerJourney link of #Solution :- https://lnkd.in/ga9b5pVb
To view or add a comment, sign in
-
-
𝗧𝗵𝗿𝗲𝗲 𝗻𝘂𝗺𝗯𝗲𝗿𝘀. 𝗢𝗻𝗲 𝗽𝗮𝘀𝘀. 𝗢𝗻𝗲 𝗴𝗵𝗼𝘀𝘁 𝘃𝗮𝗿𝗶𝗮𝗯𝗹𝗲. Day 28 of #1000DaysOfLearning Today's problem: 𝗦𝗼𝗿𝘁𝗲𝗱 𝗦𝘂𝗯𝘀𝗲𝗾𝘂𝗲𝗻𝗰𝗲 𝗼𝗳 𝗦𝗶𝘇𝗲 𝟯 (GFG Medium) Find arr[i] < arr[j] < arr[k] where i < j < k — in a single pass. Track the smallest first, then the smallest second after it. The moment you see x > second, you've got your triplet. The tricky part: if first gets updated 𝗮𝗳𝘁𝗲𝗿 second is already set, it's no longer positionally before second. So you keep a prevFirst — 𝘁𝗵𝗲 𝘃𝗮𝗹𝘂𝗲 first 𝗵𝗲𝗹𝗱 𝘄𝗵𝗲𝗻 second 𝘄𝗮𝘀 𝗹𝗮𝘀𝘁 𝘂𝗽𝗱𝗮𝘁𝗲𝗱. Even if first moves to something smaller later, prevFirst still holds the element that actually appeared before second in the array. That's what makes the returned triplet 𝗽𝗼𝘀𝗶𝘁𝗶𝗼𝗻𝗮𝗹𝗹𝘆 𝘃𝗮𝗹𝗶𝗱, not just value-valid. 𝗢(𝗻) time. 𝗢(𝟭) space. #DSA #Python #DataScience #GFG #1000DaysOfLearning #LearningInPublic
To view or add a comment, sign in
-
-
📌 Problem: Merge Strings Alternately 💡 Approach: Used a simple two-pointer / iteration technique to merge both strings character by character. First, iterate up to the minimum length of both strings and append alternately. Then, append the remaining characters from the longer string. ⚙️ Key Insight: Handle unequal string lengths separately Avoid index out-of-bounds by iterating till min(len(word1), len(word2)) ⏱️ Time Complexity: O(n + m) 📦 Space Complexity: O(n + m) merg 📚 What I learned: String manipulation efficiently Handling edge cases when lengths differ #LeetCode #DSA #Coding #ProblemSolving #Python #SoftwareDevelopment #CodingJourney
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