<?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: ramnayan</title>
    <description>The latest articles on DEV Community by ramnayan (@ram1234).</description>
    <link>https://dev.to/ram1234</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%2F559200%2Fbd036a1c-f0e5-40ba-9ac3-9ee2e187dbd2.jpeg</url>
      <title>DEV Community: ramnayan</title>
      <link>https://dev.to/ram1234</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ram1234"/>
    <language>en</language>
    <item>
      <title>2487. Remove Nodes From Linked List</title>
      <dc:creator>ramnayan</dc:creator>
      <pubDate>Sat, 30 May 2026 18:22:34 +0000</pubDate>
      <link>https://dev.to/ram1234/2487-remove-nodes-from-linked-list-42bb</link>
      <guid>https://dev.to/ram1234/2487-remove-nodes-from-linked-list-42bb</guid>
      <description>&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%2Fcjfms8t5qwbyrq8m9pe4.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%2Fcjfms8t5qwbyrq8m9pe4.png" alt=" "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In this post i'm gone explain liked list an famous leetcode problem that is "&lt;strong&gt;Remove Nodes from linked list&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;Problem Statement:&lt;br&gt;
You are given the head of a linked list.&lt;/p&gt;

&lt;p&gt;Remove every node which has a node with a greater value anywhere to the right side of it.&lt;/p&gt;

&lt;p&gt;Return the head of the modified linked list.&lt;/p&gt;

&lt;p&gt;Example 1:&lt;/p&gt;

&lt;p&gt;Input: head = [5,2,13,3,8]&lt;br&gt;
Output: [13,8]&lt;br&gt;
Explanation: The nodes that should be removed are 5, 2 and 3.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node 13 is to the right of node 5.&lt;/li&gt;
&lt;li&gt;Node 13 is to the right of node 2.&lt;/li&gt;
&lt;li&gt;Node 8 is to the right of node 3. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Explanation:&lt;br&gt;
In this problem statement state that remove the nodes which have the right side (any place) element greater than. let's understand with given example. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Node 13 is the right side of the 5,2 nodes thats why 2,5 should be remove.&lt;/li&gt;
&lt;li&gt;Node 8 is the right side of 3 node thats why 3 should be remove.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;final result would be [13,8]&lt;/p&gt;

&lt;p&gt;Solution of the problem:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="s2"&gt;`/**
 * Definition for singly-linked list.
 * function ListNode(val, next) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.next = (next===undefined ? null : next)
 * }
 */
/**
 * @param {ListNode} head
 * @return {ListNode}
 */

const reverList = function(head){
    let prev = null;
    let curr = head;
    let next = null;

    while(curr!=null){
        next = curr.next;
        curr.next = prev;
        prev = curr;
        curr = next;
    }

    return prev;
}

var removeNodes = function(head) {
    // reverse list
    let reversList = reverList(head);

    let maxNode =  reversList;
    let prevNode = reversList;
    let currNode = reversList.next;
    // removed list
    while(currNode != null){
        if(maxNode.val &amp;gt; currNode.val){
            currNode = currNode.next;
        }else{
            maxNode = currNode;
            prevNode.next = currNode;
            prevNode = prevNode.next;
            currNode = currNode.next;
        }
    }

    prevNode.next = null;
    // reverse list
    return reverList(reversList);
};`&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you have any query or suggestions leave your expression👨🏿‍💻🙌.&lt;/p&gt;

</description>
      <category>leetcode</category>
      <category>javascript</category>
      <category>algorithms</category>
      <category>coding</category>
    </item>
    <item>
      <title>Longest Repeating Character Replacement Explanation</title>
      <dc:creator>ramnayan</dc:creator>
      <pubDate>Sun, 26 Oct 2025 01:54:51 +0000</pubDate>
      <link>https://dev.to/ram1234/longest-repeating-character-replacement-4bb0</link>
      <guid>https://dev.to/ram1234/longest-repeating-character-replacement-4bb0</guid>
      <description>&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%2Fmc99umxgt7ftqns187fa.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%2Fmc99umxgt7ftqns187fa.png" alt=" " width="800" height="323"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm writing this post about an specific data structure and algorithm well known problem that is &lt;strong&gt;"Longest Repeating Character Replacement"&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I have tried to solve this problem with javascript and using two popular algorithm that is Two-Pointer &amp;amp; Sliding-Window.&lt;/p&gt;

&lt;p&gt;I hope you are aware of these two algorithms. if you don't know don't worry bellow i have  mention the blogs link you can explore or you can find on the google.&lt;/p&gt;

&lt;p&gt;Two Pointer - &lt;a href="https://www.geeksforgeeks.org/dsa/two-pointers-technique/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/dsa/two-pointers-technique/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sliding Window - &lt;a href="https://www.geeksforgeeks.org/dsa/window-sliding-technique/" rel="noopener noreferrer"&gt;https://www.geeksforgeeks.org/dsa/window-sliding-technique/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem start here********
&lt;/h2&gt;

&lt;p&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;Example 1:&lt;/p&gt;

&lt;p&gt;Input: s = "ABAB", k = 2&lt;br&gt;
Output: 4&lt;br&gt;
Explanation: Replace the two 'A's with two 'B's or vice versa.&lt;br&gt;
Example 2:&lt;/p&gt;

&lt;p&gt;Input: s = "AABABBA", k = 1&lt;br&gt;
Output: 4&lt;br&gt;
Explanation: Replace the one 'A' in the middle with 'B' and form "AABBBBA".&lt;br&gt;
The substring "BBBB" has the longest repeating letters, which is 4.&lt;br&gt;
There may exists other ways to achieve this answer too.&lt;/p&gt;
&lt;h2&gt;
  
  
  Explanation*************
&lt;/h2&gt;

&lt;p&gt;Initialise the required variables left right maxLength maxChar and count.&lt;/p&gt;

&lt;p&gt;first loop start from string zero index that is right &amp;amp; right. left start when K become zero or (r-l+1)-maxChar&amp;gt;K condition true it means window shrinking.&lt;/p&gt;

&lt;p&gt;count variable stores the character frequency to find the maxChar.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var characterReplacement = function(s, k) {
        if(s.length==1) return 1;
        let l=r=maxChar=maxLength=0;
        let count={};

        for(let r=0; r&amp;lt;s.length;r++){
             if(s[r] in count){
                ....
            }else ....;
            maxChar = Math.max(maxChar, count[s[r]]);
            while((r-l+1)-maxChar&amp;gt;k){
                .....
            }
            maxLength=Math.max(maxLength, (r-l+1));
        }
        return maxLength;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the my best approach that i have used if you have any suggestions please put your thought.&lt;/p&gt;

&lt;p&gt;Thanks for stay to the end👍🙈&lt;/p&gt;

</description>
      <category>programming</category>
      <category>javascript</category>
      <category>slidingwindow</category>
      <category>twopointer</category>
    </item>
  </channel>
</rss>
