Just solved “First Matching Character From Both Ends” 🚀 💡 My approach (simple & efficient): Instead of overcomplicating it, I used a two-pointer mindset without explicitly creating two pointers. Loop through the string from the start For each index i, compare: s[i] (from the front) s[n - i - 1] (from the back) The moment both match → return the index If no match → return -1 ✨ This works because we're checking symmetry from both ends in a single pass (O(n)) with O(1) space. Sometimes the best solutions aren’t fancy — they’re just clean and intuitive. 🔥 Consistency > Complexity. Small wins like this build strong problem-solving instincts. #LeetCode #DSA #Python #CodingJourney #ProblemSolving #TechGrowth #CodeDaily #WomenInTech #FutureEngineer #100DaysOfCode #KeepBuilding
Solving First Matching Character From Both Ends with Two Pointers
More Relevant Posts
-
🚀 Just solved the Power of Two problem on LeetCode — and here’s a quick look at my approach 👇 Instead of jumping straight into bit manipulation, I focused on a simple iterative logic: 🔹 Start from 2 🔹 Keep multiplying by 2 🔹 Check if we reach the given number 🔹 If yes → it’s a power of two ✅ 🔹 If we overshoot → it’s not ❌ 💡 This approach emphasizes clarity over cleverness — building intuition step-by-step before optimizing further. While there are more optimized solutions (like bit tricks), I believe: 👉 Strong fundamentals > premature optimization 📊 Result: ✔️ 100% runtime efficiency ✔️ Clean and readable logic Always aiming to improve not just what I solve, but how I think 💭 #LeetCode #DSA #ProblemSolving #Python #CodingJourney #100DaysOfCode #WomenInTech #FutureEngineer #TechGrowth #Consistency #LearnInPublic #CodingLife #SoftwareEngineering #DeveloperMindset
To view or add a comment, sign in
-
-
📝 Why I deliberately write "boring" code: Fancy code is impressive. Boring code is reliable. What boring code looks like: ✅ Clear variable names (customer_count not cc) ✅ Small functions that do one thing ✅ Comments that explain WHY, not WHAT ✅ Consistent formatting ✅ Error handling for edge cases Who benefits? → Future me (6 months from now, I won't remember) → My teammates (they can actually read it) → Production (less surprises at 2 AM) Clever code makes you feel smart. Boring code makes you effective. Which do you prefer to maintain? #CodeQuality #Python #DataEngineering #CleanCode
To view or add a comment, sign in
-
🚀 Day 28 of Problem Solving Journey Today, I worked on an interesting problem: Group Anagrams 🔍 Problem Statement: Given an array of strings, group the anagrams together. Anagrams are words that have the same characters but arranged differently. 💡 Approaches I explored: ✅ Approach 1: Character Frequency Count (Optimized) Used a fixed-size array (26 letters) to count character occurrences Converted the count into a tuple to use as a dictionary key Achieved an efficient time complexity of O(n * k) ✅ Approach 2: Sorting Strings Sorted each string and used it as a key Simple and intuitive approach Time complexity: O(n * k log k) 📌 Key Learning: Understanding how hashing works with different representations (frequency vs sorted string) helps in optimizing solutions. ⚡ Takeaway: There are always multiple ways to solve a problem, but choosing the most efficient one makes a difference in real-world applications and interviews. 💻 Tech Used: Python | HashMap | Arrays #Day28 #ProblemSolving #Python #DataStructures #Algorithms #CodingJourney #100DaysOfCode
To view or add a comment, sign in
-
-
Day 5 of #14DaysOfPython Completed Strings (core + advanced) and consolidated everything in one place. Strings are a major part of problem solving — most questions are based on text manipulation. Concepts Covered: Indexing and slicing Traversing using loops (for, while) Built-in methods: lower(), upper(), strip(), replace() ASCII basics using ord() and chr() String immutability Concatenation and repetition Membership operators (in, not in) String comparison Advanced methods: split(), join(), find(), count() String formatting (f-strings) Escape characters Validation methods: isalpha(), isdigit(), isalnum() Problems practiced: Palindrome check Reverse a string Count vowels and consonants Remove spaces Anagram check Character frequency Remove duplicate characters First non-repeating character Key takeaway: Most string problems follow the same pattern — iterate through characters, apply conditions, and keep track of counts. Understanding this pattern makes complex problems easier to solve. Strings topic completed. Moving to next. #HackerRank #Python #ProblemSolving #CodingJourney #Developer #LearningInPublic #codegnan
To view or add a comment, sign in
-
-
Most FastAPI codebases look clean at first glance. Until you try to change something. I’ve noticed a pattern — a lot of complexity doesn’t come from the problem itself, but from where the logic lives. When routes start handling more than just request/response, things get harder to reason about. Lately, I’ve been keeping one constraint: Routes should stay thin. They handle the HTTP layer. All business logic moves to services. It’s a small shift, but it changes a lot: 1) Clearer separation of concerns 2) Easier testing 3) Fewer side effects when making changes Also started appreciating dependency injection more. Not as a framework feature, but as a way to keep things decoupled and predictable. Nothing groundbreaking here. But in a time where a lot of code is being generated faster than it’s being designed, maintainability comes down to how consistently we apply these basics — not whether we know them. Curious how others approach structuring FastAPI projects at scale. #FastAPI #BackendDevelopment #CleanCode #SoftwareEngineering #Python
To view or add a comment, sign in
-
🚀 Day 75 of #100DaysOfCode 🔥 LeetCode 179 – Largest Number 💡 Problem: Given a list of non-negative integers, arrange them such that they form the largest possible number. 🧠 Key Insight: Normal sorting won't work here ❌ We need a custom comparator based on string concatenation. 👉 Compare: - ""a + b"" vs ""b + a"" - Whichever gives a larger value should come first. ⚙️ Approach: 1. Convert numbers to strings 2. Sort using custom comparison logic 3. Join the result 4. Handle edge case (like "[0,0] → "0"") ⚡ Complexity: - Time: O(n log n) - Space: O(n) 🎯 Result: ✅ Accepted ⚡ Runtime: 0 ms (100%) 📌 Lesson Learned: Sometimes sorting logic depends on combination, not value. #LeetCode #Python #CodingJourney #DSA #100DaysOfCode #Sorting #ProblemSolving
To view or add a comment, sign in
-
-
📌 Problem: Increasing Triplet Subsequence 💡 Approach: Traverse the array while maintaining two variables: first and second, representing the smallest and second smallest values found so far. If the current number is smaller than first, update first Else if it’s smaller than second, update second If a number is greater than both, we’ve found an increasing triplet This ensures an optimal single-pass solution. ⚙️ Key Insight: Track only two values instead of checking all triplets Greedy + optimization approach reduces complexity significantly ⏱️ Time Complexity: O(n) 📦 Space Complexity: O(1) 📚 What I learned: Greedy strategy for subsequence problems Reducing brute-force O(n³) to optimal linear solution #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #Greedy #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
Just solved a LeetCode problem with 100% runtime efficiency — but here’s the real strategy behind it 👇 When I approach problems like this, I don’t jump straight into code. I break it into patterns: 🔹 Identify what the problem really wants → Not just “digit sum & product” — it’s about processing numbers efficiently digit by digit 🔹 Optimize early → Instead of storing digits, I compute sum & product in a single pass (O(n) time, O(1) space) 🔹 Keep it simple → Clean logic > overcomplicated tricks 🔹 Validate edge thinking → What happens with 0? Single digits? Large numbers? This mindset is what I’m focusing on as I grow in problem-solving — not just solving, but solving smartly. #LeetCode #ProblemSolving #Python #CodingJourney #DataStructures #Algorithms #TechGrowth #Consistency #LearningInPublic #FutureEngineer
To view or add a comment, sign in
-
-
I was cleaning a dataset — filtering rows, transforming values, the usual. My 5-line for loop worked fine. But I wanted to be "Pythonic." So I compressed it into a one-liner. Then I added another layer. The next morning I stared at it for two full minutes trying to decode my own logic. If I couldn't read it, my future teammates had no chance. This carousel breaks down: → The mental model that makes list comprehensions click instantly → The reading order most beginners get backwards → The exact rule for when to stop using them and write a real loop What's the longest you've stared at your own code before realizing you had no idea what it does? #Python #DataAnalytics #DataAnalyst #PythonTips #LearnInPublic #AHAMoments #DataAnalystJourney
To view or add a comment, sign in
-
You don't need LangChain to build AI agents. You need to understand what's inside it. I spent the last month building agents from scratch just Python, Ollama, and the ReAct loop. No frameworks. No abstractions. Nothing I couldn't debug. 6 concepts kept coming back: → Anatomy — the 4 parts of every agent → The loop — how decisions actually happen → Tools — what they really are (not magic) → Memory — the illusion the harness creates → Scaling — what breaks at each stage → Orchestration — when one agent isn't enough I put them in a visual guide. 11 slides. Save it. Open it next time your framework does something weird. Share it with someone building their first agent. This is the reference I wish I had on day 1. 👇 Swipe through. #AIAgents #AIEngineering #LLM #MachineLearning #SoftwareEngineering #Python #BuildInPublic #FirstPrinciples #TechCareers
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