<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Amruta</title>
    <description>The latest articles on DEV Community by Amruta (@codealchemy).</description>
    <link>https://dev.to/codealchemy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3163574%2F8b2cab25-1c29-4ea9-81ea-c0b8d35c881d.png</url>
      <title>DEV Community: Amruta</title>
      <link>https://dev.to/codealchemy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codealchemy"/>
    <language>en</language>
    <item>
      <title>DSA Chronicles Day 4: Hashing &amp; Stacks Continued</title>
      <dc:creator>Amruta</dc:creator>
      <pubDate>Mon, 19 May 2025 18:00:05 +0000</pubDate>
      <link>https://dev.to/codealchemy/dsa-chronicles-day-4-hashing-stacks-continued-5hl5</link>
      <guid>https://dev.to/codealchemy/dsa-chronicles-day-4-hashing-stacks-continued-5hl5</guid>
      <description>&lt;p&gt;Today was a solid day — tackled 4 more problems that deepened my understanding of hashing and stack-based logic. Covered some variety: hash frequency, prefix sum tricks, and even a stack-based temperature-wait problem. Here’s the breakdown: &lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Search in Sorted Array
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; &lt;br&gt;
There is an integer array nums sorted in ascending order (with distinct values).&lt;/p&gt;

&lt;p&gt;Prior to being passed to your function, nums is possibly rotated at an unknown pivot index k (1 &amp;lt;= k &amp;lt; nums.length) such that the resulting array is &lt;a href="https://dev.to0-indexed"&gt;nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]&lt;/a&gt;. For example, [0,1,2,4,5,6,7] might be rotated at pivot index 3 and become [4,5,6,7,0,1,2].&lt;/p&gt;

&lt;p&gt;Given the array nums after the possible rotation and an integer target, return the index of target if it is in nums, or -1 if it is not in nums.&lt;/p&gt;

&lt;p&gt;You must write an algorithm with O(log n) runtime complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/search-in-rotated-sorted-array/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/search-in-rotated-sorted-array/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a modified binary search that considers the rotation. &lt;/li&gt;
&lt;li&gt;At each step, determine which half of the array is properly sorted. &lt;/li&gt;
&lt;li&gt;Based on the sorted half and the target’s value, decide whether to search left or right. &lt;/li&gt;
&lt;li&gt;This keeps the time complexity at O(log n).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Binary Search in rotated arrays&lt;/li&gt;
&lt;li&gt;Identifying sorted subarrays within rotated arrays&lt;/li&gt;
&lt;li&gt;Time-efficient searching (O(log n))&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 2: Daily Temperatures
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer temperature. If there is no future day for which this is possible, keep answer[i] == 0 instead.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/daily-temperatures/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/daily-temperatures/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Utilized a monotonic stack to keep track of indices of decreasing temperatures. &lt;/li&gt;
&lt;li&gt;For each temperature, pop from the stack until a warmer day is found, then calculate the difference in days.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Monotonic stack pattern&lt;/li&gt;
&lt;li&gt;Stack-based array traversal&lt;/li&gt;
&lt;li&gt;Efficient future-lookups in O(n) time&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 3: Find the Duplicate Number
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.&lt;/p&gt;

&lt;p&gt;There is only one repeated number in nums, return this repeated number.&lt;/p&gt;

&lt;p&gt;You must solve the problem without modifying the array nums and using only constant extra space.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/find-the-duplicate-number/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/find-the-duplicate-number/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Implemented Floyd's Cycle Detection Algorithm (Tortoise and Hare). &lt;/li&gt;
&lt;li&gt;Interpreted the array as a linked list where indices are nodes and values are pointers. &lt;/li&gt;
&lt;li&gt;The cycle formed by the duplicate is detected.&lt;/li&gt;
&lt;li&gt;Later the entry point is the repeated number.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics Learned:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Cycle detection in arrays using Floyd’s algorithm&lt;/li&gt;
&lt;li&gt;Interpreting array problems as graph traversal&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 4: Longest Consecutive Sequence
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.&lt;/p&gt;

&lt;p&gt;You must write an algorithm that runs in O(n) time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/longest-consecutive-sequence/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/longest-consecutive-sequence/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a priority queue (max-heap) to sort the elements in descending order.&lt;/li&gt;
&lt;li&gt;Iterated through the queue, popping elements and counting consecutive sequences.&lt;/li&gt;
&lt;li&gt;Skipped duplicates. Maintained a running maximum length of consecutive sequences found.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics learned:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Identifying consecutive sequences in a sorted context&lt;/li&gt;
&lt;li&gt;Understanding time complexity trade-offs (O(n log n) vs O(n))&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Link to my code:&lt;/strong&gt; &lt;a href="https://github.com/Amruta-25/dsa_chronicles.git" rel="noopener noreferrer"&gt;https://github.com/Amruta-25/dsa_chronicles.git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cpp</category>
      <category>coding</category>
      <category>datastructures</category>
    </item>
    <item>
      <title>DSA Chronicles Day 3: Solidifying the Core – 5 Problems, 5 Learnings</title>
      <dc:creator>Amruta</dc:creator>
      <pubDate>Sat, 17 May 2025 15:09:46 +0000</pubDate>
      <link>https://dev.to/codealchemy/dsa-chronicles-day-3-solidifying-the-core-5-problems-5-learnings-4laj</link>
      <guid>https://dev.to/codealchemy/dsa-chronicles-day-3-solidifying-the-core-5-problems-5-learnings-4laj</guid>
      <description>&lt;h2&gt;
  
  
  Problem 1 Longest Substring Without Repeating Characters
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.&lt;/p&gt;

&lt;p&gt;You must write an algorithm that runs in O(n) time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/longest-consecutive-sequence/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/longest-consecutive-sequence/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a basic count[256] array to track frequency of characters.&lt;/li&gt;
&lt;li&gt;Tried checking frequency and updating start directly if a duplicate was found.&lt;/li&gt;
&lt;li&gt;Misplaced order of start++ and count[s[start]]--, which caused logic errors for overlapping characters.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used Sliding Window technique with two pointers start and end.&lt;/li&gt;
&lt;li&gt;Maintained a count array to track how many times a character appeared in the current window.&lt;/li&gt;
&lt;li&gt;On detecting a duplicate character (count[s[end]] &amp;gt; 1), shrunk the window using a while loop. Then decreased count[s[start]] and moved start forward.&lt;/li&gt;
&lt;li&gt;Calculated current window size.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What I Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sliding Window is a powerful technique to maintain a valid subarray or substring within two moving pointers.&lt;/li&gt;
&lt;li&gt;You must shrink the window properly using a loop to remove duplicate characters until the substring becomes valid.&lt;/li&gt;
&lt;li&gt;Frequency map or array helps in quickly checking if a character is repeating inside the window.
This approach avoids unnecessary recomputation and gives O(n) time complexity. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 2 Merge Intervals
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/merge-intervals/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/merge-intervals/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Comparing ending times first and merging based on that.&lt;/li&gt;
&lt;li&gt;Considered checking if the current interval starts before the previous one ends and adjusting the range accordingly.&lt;/li&gt;
&lt;li&gt;Realized that sorting by start times is essential to group potential overlapping intervals effectively. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sort all intervals based on their starting times using a lambda function.&lt;/li&gt;
&lt;li&gt;Initialize a new list to hold merged intervals.&lt;/li&gt;
&lt;li&gt;Traverse the sorted intervals.&lt;/li&gt;
&lt;li&gt;If the merged list is empty or there is no overlap, simply add the interval.&lt;/li&gt;
&lt;li&gt;If the current interval overlaps with the last merged interval, update the end of the last merged interval to the maximum of both ends.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What I Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;How to use a lambda function in C++ to sort a 2D vector based on specific criteria (start time here).&lt;/li&gt;
&lt;li&gt;The importance of sorting before greedy merging&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 3 Top K Frequent Elements
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/top-k-frequent-elements/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/top-k-frequent-elements/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I knew I had to count frequencies but wasn’t clear on how to extract top k efficiently.&lt;/li&gt;
&lt;li&gt;Thought of sorting the full hash map, but it’s inefficient (O(n log n)).&lt;/li&gt;
&lt;li&gt;Forgot to actually create the (frequency, number) pair before pushing into the heap.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Build a hash_map where the key is the number and the value is its frequency.&lt;/li&gt;
&lt;li&gt;Create a max heap with the frequency as the first element so that the most frequent elements come first.&lt;/li&gt;
&lt;li&gt;Traverse the map, push each (frequency, number) pair into the heap.&lt;/li&gt;
&lt;li&gt;Pop the top k elements from the heap and store the numbers in a result vector. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What I Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Realized that (frequency, element) should be the order in the pair if I want to sort based on frequency using the default max-heap behavior.&lt;/li&gt;
&lt;li&gt;Understood how a heap helps simulate the behavior of a dynamic “Top K” structure—automatically. They maintain the most relevant (frequent) elements at the top.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 4 Subarray Sum Equal K
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.&lt;/p&gt;

&lt;p&gt;A subarray is a contiguous non-empty sequence of elements within an array.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/subarray-sum-equals-k/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/subarray-sum-equals-k/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Maintained a running prefix sum while traversing the array.&lt;/li&gt;
&lt;li&gt;Used a hash map to store frequency of each prefix sum encountered.&lt;/li&gt;
&lt;li&gt;At each step, checked if (prefixSum - k) exists in the map — indicating a subarray that sums to k.&lt;/li&gt;
&lt;li&gt;Initialized the map with {0: 1} to account for subarrays starting at index 0.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What I Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prefix sum helps reduce nested loops by tracking accumulated values.&lt;/li&gt;
&lt;li&gt;Hash maps enable quick lookups for previous prefix sums — making the algorithm linear time.&lt;/li&gt;
&lt;li&gt;This technique is a common pattern in problems that involve subarrays with given sum.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 5 3Sum
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.&lt;/p&gt;

&lt;p&gt;Notice that the solution set must not contain duplicate triplets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/3sum/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/3sum/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used prefix sum to keep track of cumulative sums while traversing the array.&lt;/li&gt;
&lt;li&gt;Maintained a hash map to store frequency of each prefix sum.&lt;/li&gt;
&lt;li&gt;For every index, I checked if a subarray ending there has a sum of k using: prefix_sum - k&lt;/li&gt;
&lt;li&gt;If yes, I increased the count by how many times this difference has appeared before.&lt;/li&gt;
&lt;li&gt;Initialized the hash map with {0: 1} to handle edge cases when subarray starts at index 0.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;What I Learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Prefix sums are powerful tools for subarray problems.&lt;/li&gt;
&lt;li&gt;Hash maps can efficiently track previous prefix sums to find subarrays in O(n) time.&lt;/li&gt;
&lt;li&gt;This approach improves over brute-force which is O(n²). &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Link to my code:&lt;/strong&gt; &lt;a href="https://github.com/Amruta-25/dsa_chronicles.git" rel="noopener noreferrer"&gt;https://github.com/Amruta-25/dsa_chronicles.git&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>DSA Chronicles Day 2: 5 More Problems, 5 Core Logics</title>
      <dc:creator>Amruta</dc:creator>
      <pubDate>Fri, 16 May 2025 10:33:15 +0000</pubDate>
      <link>https://dev.to/codealchemy/dsa-chronicles-day-2-5-more-problems-and-the-logic-that-stuck-4ifp</link>
      <guid>https://dev.to/codealchemy/dsa-chronicles-day-2-5-more-problems-and-the-logic-that-stuck-4ifp</guid>
      <description>&lt;p&gt;I'm back with another set of 5 DSA problems I tackled today! Today, I’ve focused on explaining both my first approach and final solution. Along with this I have also mentioned what each technique actually enables you to do. Hopefully, this helps anyone who's also in the middle of building their intuition. &lt;/p&gt;

&lt;h2&gt;
  
  
  Problem 1: Group Anagrams
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an array of strings strs, group the anagrams together. You can return the answer in any order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/group-anagrams/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/group-anagrams/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tried comparing all strings against each other for anagram checks. I t was too slow.
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sort each string alphabetically and use it as a key in a hash map.&lt;/li&gt;
&lt;li&gt;Group all original strings under the same sorted key.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hash maps allow grouping items based on custom logic (like sorted strings).&lt;/li&gt;
&lt;li&gt;Sorting gives a unique "signature" to each anagram group. &lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 2: Kth Largest Element in Array
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an integer array nums and an integer k, return the kth largest element in the array.&lt;br&gt;
Note that it is the kth largest element in the sorted order, not the kth distinct element.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt;  &lt;a href="https://leetcode.com/problems/kth-largest-element-in-an-array/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/kth-largest-element-in-an-array/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sorted the whole array and picked the (n-k)th largest —  wasteful.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a min-heap (priority queue) of size k.&lt;/li&gt;
&lt;li&gt;Pushed elements while maintaining only the k largest; top of the heap is the answer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Heaps are great for finding the top/bottom k elements in O(n log k) time.&lt;/li&gt;
&lt;li&gt;Min-heaps automatically remove the smallest element when full — perfect for this case.&lt;/li&gt;
&lt;li&gt;Use priority queues when you need constant-time access to the current best/worst element.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 3: Valid Parentheses
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt;  &lt;a href="https://leetcode.com/problems/valid-parentheses/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/valid-parentheses/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tried overly complicated edge checks before thinking about a stack.&lt;/li&gt;
&lt;li&gt;Manually compared character positions instead of thinking in terms of a data structure.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a stack to push opening brackets.&lt;/li&gt;
&lt;li&gt;For closing brackets, checked the top of the stack for a valid match and popped it. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Stacks are ideal for problems with nested structures or LIFO (last-in-first-out) logic.&lt;/li&gt;
&lt;li&gt;Helps easily manage matching pairs (e.g., open/close).&lt;/li&gt;
&lt;li&gt;Stacks are good for dealing with balancing or backtracking logic.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 4: Longest Repeating Character Replacement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
You are given a string s and an integer k. You can choose any character of the string and change it to any other uppercase English character. You can perform this operation at most k times.&lt;/p&gt;

&lt;p&gt;Return the length of the longest substring containing the same letter you can get after performing the above operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt;  &lt;a href="https://leetcode.com/problems/longest-repeating-character-replacement/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/longest-repeating-character-replacement/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Used nested loops to check every possible substring — too slow for large inputs.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used a sliding window to track the longest substring that can be made valid by replacing ≤ k characters.&lt;/li&gt;
&lt;li&gt;Maintained a character frequency map and window size.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sliding Window is great for efficiently processing substrings in linear time. In particular when problem asks for "longest/shortest substring with constraint".&lt;/li&gt;
&lt;li&gt;When coupled with a frequency map, it helps avoid redundant calculations and keep state within the window.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Problem 5: Rotate Array
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt;  &lt;a href="https://leetcode.com/problems/rotate-array/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/rotate-array/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First Thought:&lt;/em&gt; &lt;/p&gt;

&lt;p&gt;Shifted each element manually in a loop — messy and O(n²).&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Final Approach:&lt;/em&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Used the reverse technique:&lt;/li&gt;
&lt;li&gt;Reverse the full array&lt;/li&gt;
&lt;li&gt;Reverse the first k elements&lt;/li&gt;
&lt;li&gt;Reverse the rest&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Array reversal tricks are clean and efficient (O(n) time, O(1) space).&lt;/li&gt;
&lt;li&gt;Understanding in-place algorithms improves space efficiency without using extra data structures.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;My code link:&lt;/strong&gt; &lt;a href="https://github.com/Amruta-25/dsa_chronicles.git" rel="noopener noreferrer"&gt;https://github.com/Amruta-25/dsa_chronicles.git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Can’t wait to continue this journey on Day 3.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>datastructures</category>
      <category>coding</category>
    </item>
    <item>
      <title>ML-chronicles: Day 1 Understanding KNN with Iris Dataset</title>
      <dc:creator>Amruta</dc:creator>
      <pubDate>Thu, 15 May 2025 18:10:02 +0000</pubDate>
      <link>https://dev.to/codealchemy/ml-chronicles-day-1-understanding-knn-with-iris-dataset-3e1f</link>
      <guid>https://dev.to/codealchemy/ml-chronicles-day-1-understanding-knn-with-iris-dataset-3e1f</guid>
      <description>&lt;h2&gt;
  
  
  Understanding KNN with Iris Dataset – A Beginner's Visual Guide
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
As part of my ml-chronicles series, I decided to start things off with a foundational yet powerful algorithm: K-Nearest Neighbors (KNN).&lt;br&gt;
Before diving in, I skimmed through some great GFG articles to grasp the theory. Later I followed a YouTube tutorial to understand how it’s applied practically. I wanted this project to be more interactive. So, I added several features to visualize the model's behavior.And also explored its evaluation metrics interactively.&lt;br&gt;
This post covers follwing stuff:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Building a KNN model from scratch,&lt;/li&gt;
&lt;li&gt;Applying it to the Iris dataset,&lt;/li&gt;
&lt;li&gt;Visualizing the results,&lt;/li&gt;
&lt;li&gt;Testing with custom inputs, and&lt;/li&gt;
&lt;li&gt;Optimizing the best value of k.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Credits and resources:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;GFG article:&lt;/strong&gt; &lt;a href="https://www.geeksforgeeks.org/k-nearest-neighbours/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/k-nearest-neighbours/&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Youtube tutorial:&lt;/strong&gt; &lt;a href="https://youtu.be/mpfU9n4MzBE?feature=shared" rel="noopener noreferrer"&gt;https://youtu.be/mpfU9n4MzBE?feature=shared&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is KNN ?&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
KNN stands for K-Nearest Neighbors. It is also called as lazy learning algorithm. It doesn’t train a model explicitly. It doesn't learn from the training set immediately but stores the dataset and at the time of classification performs action on the dataset. It looks at the k nearest data points around a query and returns the most common class among them.&lt;br&gt;
If dataset has significant outliers or noise a higher k helps smooth out predictions and noise.. However very high k can often cause underfitting. &lt;br&gt;
There are various statistical methods for selecting best value of k : cross-validation, elbow method, odd values for k etc.&lt;br&gt;
Also the distances can be measured in some of the famous methods: Euclidean distance, Manhattan distance, Minkowski distance etc. &lt;br&gt;
Steps involved:&lt;br&gt;
1.Measure distance (usually Euclidean) to all training points.&lt;br&gt;
2.Pick the k closest ones.&lt;br&gt;
3.Vote on the class label.&lt;br&gt;
KNN works best with normalized data and small to medium datasets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Dataset: IRIS&lt;/strong&gt;&lt;br&gt;
The classic Iris dataset has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;150 samples across 3 classes: Setosa, Versicolor, and Virginica.&lt;/li&gt;
&lt;li&gt;4 numerical features: Sepal Length, Sepal Width, Petal Length, and Petal Width.&lt;/li&gt;
&lt;li&gt;For my project:
I removed the Id column and normalized all features using MinMaxScaler.
Further I Mapped class labels to numeric codes (1, 2, 3) for internal processing.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;My Model Architecture&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Preprocessing&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Normalized all feature columns to [0, 1].&lt;/li&gt;
&lt;li&gt;Mapped species to numeric values for classification.&lt;/li&gt;
&lt;li&gt;Used 3D scatter plots to visualize separability among classes.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Custom KNN from Scratch&lt;/strong&gt;&lt;br&gt;
I implemented KNN in a separate module (kNN_modules.py).&lt;br&gt;
It includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A distance function to measure closeness: formula for euclidean distance is used.&lt;/li&gt;
&lt;li&gt;A KNN() function that predicts the class using statistics.mode() from nearest neighbors.&lt;/li&gt;
&lt;li&gt;Optional print to view selected neighbors.
This helped me build intuition about how predictions are formed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Visualizations:&lt;/strong&gt; Following visuals were implemented .. I am attaching the results&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Confusion Matrix&lt;/em&gt;&lt;br&gt;
Used sklearn’s ConfusionMatrixDisplay to evaluate predictions visually for a fixed k=5.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foafmt2o5y7gbezty2yff.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foafmt2o5y7gbezty2yff.png" alt="Image description" width="712" height="574"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Accuracy Heatmap&lt;/em&gt;&lt;br&gt;
I ran 10 random train-test splits (30% test) and varied k from 1 to 15.&lt;br&gt;
Then visualized accuracy trends across combinations using a heatmap.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoba9gjyh32k0vcqgi0m.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoba9gjyh32k0vcqgi0m.png" alt="Image description" width="800" height="555"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Best k – Average Accuracy Plot&lt;/em&gt;&lt;br&gt;
I Computed average accuracy for each k value across runs.&lt;br&gt;
Thus found the best_k using .idxmax().&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy8h6mauotpw3l6rjrad.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzy8h6mauotpw3l6rjrad.png" alt="Image description" width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Export&lt;/strong&gt;&lt;br&gt;
Saved all accuracy results to CSV for later inspection.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interactive Query Input&lt;/strong&gt;&lt;br&gt;
One of my favorite parts was enabling this command-line prediction:&lt;br&gt;
User can input 4 features like:  SepalL SepalW PetalL PetalW&lt;br&gt;
Input is scaled and classified using the custom KNN function&lt;br&gt;
It prints the predicted species!&lt;/p&gt;

&lt;p&gt;(It might skip in non-interactive environments — I handled that too.)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Results &amp;amp; Observations&lt;/strong&gt;&lt;br&gt;
The model performed best at k = 9, with average accuracy peaking there.&lt;br&gt;
Visualization helped reveal class boundaries and overlaps&lt;br&gt;&lt;br&gt;
Writing the KNN logic from scratch gave me a hands-on view of its behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Features I Added&lt;/strong&gt; &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Normalization using MinMaxScaler&lt;/li&gt;
&lt;li&gt;Confusion Matrix using sklearn&lt;/li&gt;
&lt;li&gt;Heatmap of accuracy vs. k&lt;/li&gt;
&lt;li&gt;Interactive command-line query support&lt;/li&gt;
&lt;li&gt;CSV export for tracking experimental results&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;My code link:&lt;/strong&gt; &lt;a href="https://github.com/Amruta-25/ML_chronicles_KNN.git" rel="noopener noreferrer"&gt;https://github.com/Amruta-25/ML_chronicles_KNN.git&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This was Day 1 of my ml-chronicles.&lt;br&gt;
If you're just starting out in ML — try building this from scratch.&lt;br&gt;
What would you add or change in this project? &lt;/p&gt;

</description>
      <category>programming</category>
      <category>machinelearning</category>
      <category>coding</category>
      <category>beginners</category>
    </item>
    <item>
      <title>DSA Chronicles Day 1 : 5 Essential Problems I Solved</title>
      <dc:creator>Amruta</dc:creator>
      <pubDate>Thu, 15 May 2025 07:43:54 +0000</pubDate>
      <link>https://dev.to/codealchemy/dsa-chronicles-day-1-5-essential-problems-i-solved-6a</link>
      <guid>https://dev.to/codealchemy/dsa-chronicles-day-1-5-essential-problems-i-solved-6a</guid>
      <description>&lt;p&gt;Today was a productive day in my DSA journey! I tackled five important problems, each teaching me something new about logic, data structures, and implementation. Some problems I cracked independently, and others with some help — but all were solid learning experiences. Here's a breakdown of what I solved and what I learned:&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 1:&lt;/strong&gt; &lt;strong&gt;Top K Frequent Elements in Array&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Problem:&lt;br&gt;
Given a non-empty integer array arr[] of size n, find the top k elements which appear most frequently. If two numbers have the same frequency, prefer the larger one. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://www.geeksforgeeks.org/problems/top-k-frequent-elements-in-array/1" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/problems/top-k-frequent-elements-in-array/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use an unordered_map to count the frequency of each number.&lt;/li&gt;
&lt;li&gt;Push the entries into a priority_queue (max-heap) that prioritizes higher frequency (and higher value in case of ties).&lt;/li&gt;
&lt;li&gt;Extract the top k elements from the heap.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unordered map: Helped me count frequencies in linear time—essential for frequency-based problems.&lt;/li&gt;
&lt;li&gt;Priority queue (max-heap): Learned how to structure a custom comparator and use a heap to get the most frequent or largest values efficiently.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 2: Reduce Array Size to Half&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Problem:&lt;br&gt;
Given an array arr, remove as few elements as possible (completely) so that the size of the remaining array is at most half the original.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/reduce-array-size-to-the-half/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/reduce-array-size-to-the-half/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Count element frequencies using a hashmap.&lt;/li&gt;
&lt;li&gt;Use a max-heap to remove the most frequent elements first.&lt;/li&gt;
&lt;li&gt;Keep removing until the remaining elements are ≤ half the array size.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Greedy selection with heaps: Understood that removing elements with the highest frequency first ensures minimal removal steps.&lt;/li&gt;
&lt;li&gt;Hashmap + heap pattern: Reinforced how this duo helps in optimizing decisions based on frequency.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 3: Remove K Digits&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Problem:&lt;br&gt;
Given a number as a string num and an integer k, remove k digits to form the smallest possible number.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem :&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/remove-k-digits/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/remove-k-digits/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Traverse left to right, greedily remove digits where the left digit is larger than the right.&lt;/li&gt;
&lt;li&gt;If k is still &amp;gt; 0, remove from the end.&lt;/li&gt;
&lt;li&gt;Finally, trim leading zeros.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Greedy stack-based approach: Learned how removing bigger digits early helps form a smaller number.&lt;/li&gt;
&lt;li&gt;String and digit manipulation: Got familiar with trimming zeros and using stack-like behavior on strings.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 4: Longest Substring with Distinct Characters&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Problem:&lt;br&gt;
Given a string s, return the length of the longest substring with all unique characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://www.geeksforgeeks.org/problems/longest-distinct-characters-in-string5848/1" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/problems/longest-distinct-characters-in-string5848/1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Use a sliding window and an ASCII array to track last-seen indices of characters.&lt;/li&gt;
&lt;li&gt;Shift the window forward whenever a repeating character is found inside the current window.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Sliding window technique: Understood how to dynamically maintain a substring using two pointers and optimize space.&lt;/li&gt;
&lt;li&gt;Character-index tracking: Practiced using arrays to map ASCII values for fast lookups.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Problem 5: Sum of Digits of String After Convert&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Problem:&lt;br&gt;
Given a lowercase string s and an integer k, convert each character to its alphabet position, sum the digits, and repeat k times.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Link to problem:&lt;/strong&gt; &lt;a href="https://leetcode.com/problems/sum-of-digits-of-string-after-convert/description/" rel="noopener noreferrer"&gt;https://leetcode.com/problems/sum-of-digits-of-string-after-convert/description/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Convert characters to numbers using 'char' - 'a' + 1 rule.&lt;/li&gt;
&lt;li&gt;Sum digits repeatedly k times.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Topics I learned:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;ASCII to int conversion: Learned how to map characters like 'a' to 1 using basic arithmetic.&lt;/li&gt;
&lt;li&gt;Digit transformation: Practiced repeatedly converting and summing numbers using string manipulation.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;My code link:&lt;/strong&gt; &lt;a href="https://github.com/Amruta-25/dsa_chronicles.git" rel="noopener noreferrer"&gt;https://github.com/Amruta-25/dsa_chronicles.git&lt;/a&gt;&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>dsa</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
