✅ Day 78 of 100 Days LeetCode Challenge Problem: 🔹 #3110 – Score of a String 🔗 https://lnkd.in/g9jgxcdK Learning Journey: 🔹 Today’s problem involved calculating the score of a string based on the absolute differences between ASCII values of adjacent characters. 🔹 I iterated through the string starting from index 1 and computed the difference between the current and previous character using ord(). 🔹 For each pair, I added the absolute difference to a running total. 🔹 This approach efficiently accumulates the score in a single pass. Concepts Used: 🔹 String Traversal 🔹 ASCII Value Conversion (ord()) 🔹 Absolute Difference Calculation Key Insight: 🔹 The problem reduces to comparing adjacent elements, making it a straightforward linear scan. 🔹 Using ord() allows direct access to ASCII values, simplifying the computation. Complexity: 🔹 Time: O(n) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
LeetCode Challenge Day 78: Score of a String Problem
More Relevant Posts
-
✅ Day 79 of 100 Days LeetCode Challenge Problem: 🔹 #451 – Sort Characters By Frequency 🔗 https://lnkd.in/gMAzHVvS Learning Journey: 🔹 Today’s problem required sorting characters in a string based on their frequency in decreasing order. 🔹 I first built a frequency map (hash map) to count occurrences of each character. 🔹 Then I grouped characters by their frequency and stored them accordingly. 🔹 Finally, I sorted the frequencies in descending order and constructed the result string by repeating characters based on their counts. Concepts Used: 🔹 Hash Map (Frequency Counting) 🔹 Sorting (Descending Order) 🔹 String Construction Key Insight: 🔹 Instead of sorting characters directly, grouping them by frequency makes it easier to reconstruct the result efficiently. 🔹 Sorting only the frequency keys reduces unnecessary operations. Complexity: 🔹 Time: O(n log k) (k = unique characters) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 83 of 100 Days LeetCode Challenge Problem: 🔹 #832 – Flipping an Image 🔗 https://lnkd.in/ghfEcHHT Learning Journey: 🔹 Today’s problem involved two operations on a binary matrix: horizontal flip and bit inversion. 🔹 First, I reversed each row to achieve the horizontal flip. 🔹 Then, I inverted every bit (0 → 1 and 1 → 0) using a helper function. 🔹 This approach ensured the transformation was done in-place without extra space. Concepts Used: 🔹 Array Manipulation 🔹 Matrix Traversal 🔹 Two-Pointer / In-place Operations 🔹 Bit Manipulation Key Insight: 🔹 Instead of treating flipping and inversion as separate heavy operations, they can be efficiently combined or done sequentially in-place. 🔹 Using simple transformations keeps the solution clean and optimal. Complexity: 🔹 Time: O(n × m) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 88 of 100 Days LeetCode Challenge Problem: 🔹 #1252 – Cells with Odd Values in a Matrix 🔗 https://lnkd.in/g5eE9A-e Learning Journey: 🔹 Today’s problem focused on simulating row and column increment operations on a matrix. 🔹 I initialized an m × n matrix with all zeros. 🔹 For each index [ri, ci], I incremented: • All elements in row ri • All elements in column ci 🔹 After applying all operations, I traversed the matrix to count how many cells contain odd values. Concepts Used: 🔹 Matrix Simulation 🔹 Nested Loops 🔹 Conditional Counting 🔹 Basic Array Manipulation Key Insight: 🔹 Direct simulation works efficiently due to small constraints. 🔹 Each operation affects an entire row and column, so tracking increments carefully is key. Complexity: 🔹 Time: O(m × n + k × (m + n)) 🔹 Space: O(m × n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
🚀 Optimized Solution: Search in Rotated Sorted Array II Solved the problem "Search in Rotated Sorted Array II" using an optimized Binary Search approach! 🔍 Key Idea: Instead of using linear search, I applied a modified binary search to handle: ✔️ Rotated sorted array ✔️ Presence of duplicates ⚙️ Approach: Used binary search to divide the array Identified sorted halves even with duplicates Carefully handled edge cases where duplicates make it hard to decide the sorted side 📈 Complexity: ⏱️ Time Complexity: O(log n) (Worst case O(n) due to duplicates) 💾 Space Complexity: O(1) ✅ Result: ✔️ All test cases passed ⚡ Efficient and scalable solution This problem really helped me strengthen my understanding of edge cases in binary search and real-world problem-solving 💡 #leetcode #binarysearch #algorithms #coding #python #datastructures #softwaredeveloper #problemSolving
To view or add a comment, sign in
-
-
🗓 7 April 2026 LeetCode Problem #128 – Longest Consecutive Sequence Solved the problem of finding the longest consecutive sequence in an unsorted array. Key insight: use a set for O(1) lookups and only start counting sequences from numbers that are the beginning of a sequence. Takeaways: - Using the right data structure reduces time complexity from O(n²) to O(n). - Avoid redundant work while scanning arrays. - Handle edge cases like empty or single-element arrays efficiently. This problem reinforces how a smart approach beats brute force every time! #LeetCode #Algorithms #Python #DataStructures #ProblemSolving #Coding #TechLearning
To view or add a comment, sign in
-
-
✅ Day 97 of 100 Days LeetCode Challenge Problem: 🔹 #1281 – Subtract the Product and Sum of Digits of an Integer 🔗 https://lnkd.in/gxTAZc6U Learning Journey: 🔹 Today’s problem involved extracting digits of a number and performing two operations simultaneously. 🔹 I initialized two variables: one for product (pr) and one for sum (sm). 🔹 Using a while loop, I extracted each digit using n % 10. 🔹 Updated the product by multiplying the digit and updated the sum by adding it. 🔹 Reduced the number using integer division (n //= 10) after each step. 🔹 Finally returned the difference between product and sum. Concepts Used: 🔹 Digit Extraction 🔹 While Loop 🔹 Arithmetic Operations 🔹 Number Manipulation Key Insight: 🔹 Both product and sum can be computed in a single traversal of digits. 🔹 Efficient use of modulus and division avoids converting the number to a string. Complexity: 🔹 Time: O(d) 🔹 Space: O(1) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
✅ Day 87 of 100 Days LeetCode Challenge Problem: 🔹 #2840 – Check if Strings Can be Made Equal With Operations II 🔗 https://lnkd.in/gY73RBb5 Learning Journey: 🔹 Today’s problem extended the previous one, allowing swaps between indices where the difference is even. 🔹 I observed that this again partitions the string into two independent groups: • Even indices (0, 2, 4, …) • Odd indices (1, 3, 5, …) 🔹 I extracted characters from even and odd positions separately for both strings. 🔹 Then, I sorted these groups and compared them between s1 and s2. 🔹 If both even-index groups and odd-index groups match, the strings can be made equal. Concepts Used: 🔹 String Manipulation 🔹 Index Grouping (Parity-based) 🔹 Sorting 🔹 Greedy Observation Key Insight: 🔹 Since swaps are allowed only between indices with even distance, characters can only move within their parity group. 🔹 Therefore, the problem reduces to checking if both parity groups have identical character distributions. Complexity: 🔹 Time: O(n log n) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #CodingInterview #100DaysOfCode #SoftwareEngineering #Python #ProblemSolving #LearningInPublic #TechCareers
To view or add a comment, sign in
-
-
I just published a deep dive into how AI agents actually work. The "agent loop" behind Claude Code, Cursor, and every coding assistant—built from scratch. 🎥 Full video: https://lnkd.in/dms7uin5 💻 Code + notebook: https://lnkd.in/dCRFp8iC We go from the official SDK (easy) to building the loop manually (educational). Key insight: The model is the agent. The code is just the harness. #AIEngineering #ClaudeCode #LLM #Python #MachineLearning #SoftwareEngineering
To view or add a comment, sign in
-
📌 Problem: 1679. Max Number of K-Sum Pairs 💡 Approach: First, sort the array to efficiently apply the two-pointer technique. Initialize two pointers: one at the start (left) and one at the end (right). If the sum equals k, we found a valid pair → increment count and move both pointers If the sum is greater than k, move the right pointer to reduce the sum If the sum is smaller than k, move the left pointer to increase the sum Continue until both pointers meet. ⚙️ Key Insight: Sorting enables efficient pair finding Two-pointer approach avoids checking all pairs (O(n²)) Greedy selection ensures maximum number of operations ⏱️ Time Complexity: O(n log n) (due to sorting) 📦 Space Complexity: O(1) (ignoring sorting space) 📚 What I learned: Two-pointer technique on sorted arrays Optimizing pair problems from brute force to efficient solutions #LeetCode #DSA #Algorithms #Coding #ProblemSolving #Python #TwoPointers #Greedy #InterviewPreparation #CodingJourney
To view or add a comment, sign in
-
✅ Day 98 of 100 Days LeetCode Challenge Problem: 🔹 #338 – Counting Bits 🔗 https://lnkd.in/gXdNxX66 Learning Journey: 🔹 Today’s problem focused on counting the number of 1s in the binary representation of numbers from 0 to n. 🔹 I initialized an array ans of size n+1. 🔹 For each number i, I converted it to binary using bin(i)[2:]. 🔹 Counted the number of '1' bits by iterating through the binary string. 🔹 Stored the count in ans[i] and returned the final array. Concepts Used: 🔹 Bit Manipulation (Binary Representation) 🔹 Array Traversal 🔹 String Processing 🔹 Brute Force Approach Key Insight: 🔹 Each number’s bit count can be computed independently. 🔹 Converting to binary and counting '1' works, but can be optimized further using DP or bit tricks. Complexity: 🔹 Time: O(n log n) (binary conversion for each number) 🔹 Space: O(n) #LeetCode #Algorithms #DataStructures #100DaysOfCode #Python #CodingJourney #ProblemSolving #LearningInPublic
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