<?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: Padma Priya R</title>
    <description>The latest articles on DEV Community by Padma Priya R (@padma_priya_815d0cd613d0c).</description>
    <link>https://dev.to/padma_priya_815d0cd613d0c</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%2F3837916%2Fc8f47062-cf9f-40ca-a292-573211d22388.png</url>
      <title>DEV Community: Padma Priya R</title>
      <link>https://dev.to/padma_priya_815d0cd613d0c</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/padma_priya_815d0cd613d0c"/>
    <language>en</language>
    <item>
      <title>How DNS resolver is happening?</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Fri, 27 Mar 2026 18:34:21 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/how-dns-resolver-is-happening-p59</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/how-dns-resolver-is-happening-p59</guid>
      <description>&lt;p&gt;&lt;strong&gt;WHAT IS DNS ?&lt;/strong&gt;&lt;br&gt;
DNS means Domain Name System&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;ROLE OF DNS *&lt;/em&gt;&lt;br&gt;
it converts the website name  into ip address&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROXY used in DNS&lt;/strong&gt;&lt;br&gt;
REVERSE PROXY - Mid man between the client and the servers it distributes the request.&lt;br&gt;
FORWARD PROXY - Multiple requests are converted into single request.&lt;/p&gt;

&lt;p&gt;what is DNS resolver ?&lt;br&gt;
A DNS resolver is a server that helps you find the IP address of a website.&lt;/p&gt;

&lt;p&gt;** FLOW OF DNS RESOLVER**&lt;/p&gt;

&lt;p&gt;USER - DNS QUERY INTIALIZATION - SUB RESOLVER (local machine internet cache DHCP) - RESOLVER - ISP (internet server provider it acts as a gateway between device and internet)&lt;/p&gt;

&lt;p&gt;EXAMPLE&lt;br&gt;
&lt;a href="http://www.wikipedia.org" rel="noopener noreferrer"&gt;www.wikipedia.org&lt;/a&gt;.&lt;br&gt;
here (.) - indicates the Root of DNS system.(even without the root the website can run )&lt;br&gt;
org - indicates the top level domain it will point the secondary level domain when we ask for the ip address&lt;br&gt;
wikipedia - idicates the secondary level domain holds the ip address&lt;br&gt;
www - indicates the subdomain even without sub domain also the website can run.&lt;/p&gt;

&lt;p&gt;how it works?&lt;br&gt;
step 1 - Receives request from machine &lt;br&gt;
step 2 - Checks if it already knows the answer like if we already search for it our machine has a memory of our search (cache) If not it will ask the:&lt;br&gt;
Root of DNS system&lt;br&gt;
TLD server&lt;br&gt;
SLD server &lt;br&gt;
Get the  IP address&lt;br&gt;
Hitback to our machine&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How a request originates from client and reaches the server ?</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Fri, 27 Mar 2026 18:07:24 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/how-a-request-originates-from-client-and-reaches-the-server--3b0k</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/how-a-request-originates-from-client-and-reaches-the-server--3b0k</guid>
      <description>&lt;p&gt;&lt;strong&gt;General Flow:&lt;/strong&gt;&lt;br&gt;
when the machine is connected in the same network, the machine send the request to the modem the modem searches wheather it able to read the request send by the other machine and the response got from the machine is send to modem the modem send back the response to the machine that arise the request.&lt;br&gt;
MACHINE 1 &amp;gt; REQ &amp;gt; SWITCH AND ROUTER &amp;gt;  MODEM &amp;gt; MACHINE 2 &amp;gt; RES &amp;gt; MODEM &amp;gt; MSG &amp;gt; MACHINE 1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;what is client and server ?&lt;/strong&gt;&lt;br&gt;
Client: Your machine  that requests information.&lt;br&gt;
Server: the system that stores and provides data based on our request basically it response for our request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
searching on Google&lt;/p&gt;

&lt;p&gt;we(user) ask the query Request goes to Google server the Server search the request results(response)come back to the user.&lt;/p&gt;

&lt;p&gt;user - Browser- request - DNS - Google Server - response - Display - user &lt;/p&gt;

</description>
    </item>
    <item>
      <title>HOW INTERNET WORKS ? WHAT IS IP ADDRESS,SUBNET and DNS 🤔💭</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Fri, 27 Mar 2026 17:48:58 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/how-internet-works-what-is-ip-addresssubnet-and-dns-2ck8</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/how-internet-works-what-is-ip-addresssubnet-and-dns-2ck8</guid>
      <description>&lt;p&gt;&lt;strong&gt;WHAT IS INTERNET ?&lt;/strong&gt;&lt;br&gt;
Internet is a wide range of system that allows the machines to connect world wide to share and communicate with each other using the standard Protocols.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;IP ADDRESS ?&lt;/strong&gt;&lt;br&gt;
AN IP address is a unique address for each and every device in Internet.&lt;br&gt;
It is used to send messages and communicate to the devices when it is connected in the same network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;THE IP ADDRESS IS DIVIDED INTO TWO PARTS NAMELY&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The Network Part &lt;br&gt;
The Host Part &lt;br&gt;
Example: 10.1.34.81/24&lt;br&gt;
here the /24 defines the network &lt;br&gt;
where 10.1.4 indicates the network part and remaining 81 denotes the host part.&lt;br&gt;
The ip holds till 32 bits it cannot be extended. It can be allocated from (0 to 255)&lt;br&gt;
The tool CIDR calculator is used to calculate The no of devices can be connected to the internet using the ip address.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;/blockquote&gt;
&lt;br&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;TYPES OF IP ADDRESS&lt;/strong&gt;&lt;br&gt;
Public ip address - will be standard (eg: a college holds a public ip from that the subnets were divided but the public ip for the college unique and   only that college has that ip in the world)&lt;br&gt;
Private ip address - Can be used in the closed area Network.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FLOW OF HOW INTERNET WORKS ?&lt;/strong&gt;&lt;br&gt;
when the machine is connected in the same network, the machine send the request to the modem the modem searches wheather it able to read the request send by the other machine and the response got from the machine is send to modem the modem send back the response to the machine that arise the request.&lt;br&gt;
MACHINE 1 &amp;gt; REQ &amp;gt; MODEM &amp;gt; MACHINE 2 &amp;gt; RES &amp;gt; MODEM &amp;gt; MSG &amp;gt; MACHINE 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;SUBNETS&lt;/strong&gt;&lt;br&gt;
The subnet is a smaller network inside the larger network&lt;br&gt;
example : an public ip can have multiple subnets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DNS&lt;/strong&gt;&lt;br&gt;
it converts the websites into ip address&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXAMPLE&lt;/strong&gt;&lt;br&gt;
&lt;a href="http://www.wikipedia.org" rel="noopener noreferrer"&gt;www.wikipedia.org&lt;/a&gt;.&lt;br&gt;
here (.) -  indicates the Root of DNS system.(even without the root the website can run )&lt;br&gt;
org - indicates the top level domain it will point the secondary level domain when we ask for the ip address&lt;br&gt;
wikipedia - idicates the secondary level domain holds the ip address&lt;br&gt;
www - indicates the subdomain even without sub domain also the website can run.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PROXY used in DNS&lt;/strong&gt;&lt;br&gt;
REVERSE PROXY - Mid man between the client and the servers it distributes  the request.&lt;br&gt;
FORWARD PROXY - Multiple requests are converted into single request.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Sorting Algorithms in Python</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 16:20:02 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/sorting-algorithms-in-python-5c8o</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/sorting-algorithms-in-python-5c8o</guid>
      <description>&lt;p&gt;**Sorting helps to  organize data efficiently and is frequently asked in coding interviews. In this post, we cover four commonly taught sorting algorithms: Bubble Sort, Selection Sort, Insertion Sort, and Merge Sort. Each is illustrated with a simple problem, Python implementation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Bubble Sort&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Given an integer array nums, sort it in ascending order using Bubble Sort.&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def bubbleSort(self, nums):&lt;br&gt;
        n = len(nums)&lt;br&gt;
        for i in range(n):&lt;br&gt;
            for j in range(0, n-i-1):&lt;br&gt;
                if nums[j] &amp;gt; nums[j+1]:&lt;br&gt;
                    nums[j], nums[j+1] = nums[j+1], nums[j]&lt;br&gt;
        return nums&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
nums = [5, 2, 3, 1]&lt;br&gt;
sol = Solution()&lt;br&gt;
print("Sorted array:", sol.bubbleSort(nums))&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Selection Sort&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Given an array of integers, sort it in ascending order using Selection Sort.&lt;/p&gt;

&lt;p&gt;def selection_sort(arr):&lt;br&gt;
    n = len(arr)&lt;br&gt;
    for i in range(n):&lt;br&gt;
        min_index = i&lt;br&gt;
        for j in range(i+1, n):&lt;br&gt;
            if arr[j] &amp;lt; arr[min_index]:&lt;br&gt;
                min_index = j&lt;br&gt;
        arr[i], arr[min_index] = arr[min_index], arr[i]&lt;/p&gt;

&lt;p&gt;arr = [64, 25, 12, 22, 11]&lt;br&gt;
selection_sort(arr)&lt;br&gt;
print("Sorted array:", arr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Insertion Sort&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Given an array of numbers, sort them in ascending order using Insertion Sort.&lt;/p&gt;

&lt;p&gt;def insertion_sort(arr):&lt;br&gt;
    for i in range(1, len(arr)):&lt;br&gt;
        key = arr[i]&lt;br&gt;
        j = i-1&lt;br&gt;
        while j &amp;gt;= 0 and arr[j] &amp;gt; key:&lt;br&gt;
            arr[j+1] = arr[j]&lt;br&gt;
            j -= 1&lt;br&gt;
        arr[j+1] = key&lt;/p&gt;

&lt;p&gt;arr = [12, 11, 13, 5, 6]&lt;br&gt;
insertion_sort(arr)&lt;br&gt;
print("Sorted array:", arr)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Merge Sort&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt;&lt;br&gt;
Given an array of integers, sort it using the divide-and-conquer approach (Merge Sort).&lt;/p&gt;

&lt;p&gt;def merge_sort(arr):&lt;br&gt;
    if len(arr) &amp;gt; 1:&lt;br&gt;
        mid = len(arr)//2&lt;br&gt;
        L = arr[:mid]&lt;br&gt;
        R = arr[mid:]&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    merge_sort(L)
    merge_sort(R)

    i = j = k = 0
    while i &amp;lt; len(L) and j &amp;lt; len(R):
        if L[i] &amp;lt; R[j]:
            arr[k] = L[i]
            i += 1
        else:
            arr[k] = R[j]
            j += 1
        k += 1

    while i &amp;lt; len(L):
        arr[k] = L[i]
        i += 1
        k += 1

    while j &amp;lt; len(R):
        arr[k] = R[j]
        j += 1
        k += 1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;arr = [38, 27, 43, 3, 9, 82, 10]&lt;br&gt;
merge_sort(arr)&lt;br&gt;
print("Sorted array:", arr)&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Merge Two Sorted Linked Lists</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 14:06:47 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/merge-two-sorted-linked-lists-418j</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/merge-two-sorted-linked-lists-418j</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You are given the heads of two sorted linked lists, list1 and list2. Your task is to merge the two lists into one sorted linked list by splicing together the nodes of the first two lists.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Input: list1 = [1,2,4], list2 = [1,3,4]&lt;br&gt;
Output: [1,1,2,3,4,4]&lt;/p&gt;

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

&lt;p&gt;Input: list1 = [], list2 = []&lt;br&gt;
Output: []&lt;br&gt;
Example 3:&lt;/p&gt;

&lt;p&gt;Input: list1 = [], list2 = [0]&lt;br&gt;
Output: [0]&lt;/p&gt;

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

&lt;p&gt;Create a dummy node to serve as the start of the merged list.&lt;br&gt;
Use a pointer current to track the last node in the merged list.&lt;br&gt;
Compare the nodes from both lists:&lt;br&gt;
Append the smaller node to current.next.&lt;br&gt;
Move the pointer of the list from which the node was taken.&lt;br&gt;
Once one list is exhausted, append the remaining nodes from the other list.&lt;br&gt;
Return dummy.next as the head of the merged list&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;class ListNode:&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self, val=0, next=None):&lt;br&gt;
        self.val = val&lt;br&gt;
        self.next = next&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def mergeTwoLists(self, list1: ListNode, list2: ListNode) -&amp;gt; ListNode:&lt;br&gt;
        dummy = ListNode(-1)&lt;br&gt;
        current = dummy&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while list1 and list2:
        if list1.val &amp;lt;= list2.val:
            current.next = list1
            list1 = list1.next
        else:
            current.next = list2
            list2 = list2.next
        current = current.next

    # Append remaining nodes
    if list1:
        current.next = list1
    elif list2:
        current.next = list2

    return dummy.next
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>coding</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Merge Sort on a Linked List</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:44:06 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/merge-sort-on-a-linked-list-2k30</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/merge-sort-on-a-linked-list-2k30</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given the head of a singly linked list, sort it using Merge Sort.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
10 -&amp;gt; 30 -&amp;gt; 20 -&amp;gt; 50 -&amp;gt; 40 -&amp;gt; 60&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
10 -&amp;gt; 20 -&amp;gt; 30 -&amp;gt; 40 -&amp;gt; 50 -&amp;gt; 60&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
9 -&amp;gt; 2 -&amp;gt; 5 -&amp;gt; 8&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
2 -&amp;gt; 5 -&amp;gt; 8 -&amp;gt; 9&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;Number of nodes: 1 ≤ n ≤ 10^5&lt;br&gt;
Node values: 0 ≤ node-&amp;gt;data ≤ 10^6&lt;br&gt;
Expected time complexity: O(n log n)&lt;br&gt;
Expected space complexity: O(log n) (due to recursion)&lt;br&gt;
Approach&lt;/p&gt;

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

&lt;p&gt;Base : If the list is empty or has only one node, it is already sorted.&lt;br&gt;
Divide: Find the middle of the linked list using the slow and fast pointer technique and split it into two halves.&lt;br&gt;
Conquer &amp;amp; Merge: Recursively sort both halves and merge them using a helper function that merges two sorted linked lists.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    # Function to merge two sorted linked lists&lt;br&gt;
    def merge(self, a, b):&lt;br&gt;
        if not a:&lt;br&gt;
            return b&lt;br&gt;
        if not b:&lt;br&gt;
            return a&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    if a.data &amp;lt;= b.data:
        result = a
        result.next = self.merge(a.next, b)
    else:
        result = b
        result.next = self.merge(a, b.next)

    return result

# Function to find the middle of the linked list
def getMiddle(self, head):
    if not head:
        return head

    slow = head
    fast = head.next

    while fast and fast.next:
        slow = slow.next
        fast = fast.next.next

    return slow

# Main function to sort linked list using merge sort
def mergeSort(self, head):
    # Base case: 0 or 1 node
    if not head or not head.next:
        return head

    # Step 1: Split the list into halves
    middle = self.getMiddle(head)
    next_to_middle = middle.next
    middle.next = None  # split the list

    # Step 2: Recursively sort the two halves
    left = self.mergeSort(head)
    right = self.mergeSort(next_to_middle)

    # Step 3: Merge the sorted halves
    sorted_list = self.merge(left, right)
    return sorted_list
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Finding the middle: The getMiddle() function uses slow and fast pointers. Slow moves one step, fast moves two steps. When fast reaches the end, slow points to the middle.&lt;br&gt;
Merging lists: The merge() function merges two sorted linked lists recursively.&lt;br&gt;
Recursive sorting: The mergeSort() function splits the list, sorts both halves, and merges them back together.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>computerscience</category>
      <category>interview</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Remove Duplicates from a Sorted Linked List</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:37:27 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/remove-duplicates-from-a-sorted-linked-list-2cff</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/remove-duplicates-from-a-sorted-linked-list-2cff</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given a singly linked list, remove all duplicate nodes so that only the first occurrence of each value remains.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
2 -&amp;gt; 2 -&amp;gt; 4 -&amp;gt; 5&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
2 -&amp;gt; 4 -&amp;gt; 5&lt;/p&gt;

&lt;p&gt;Input:&lt;br&gt;
2 -&amp;gt; 2 -&amp;gt; 2 -&amp;gt; 2 -&amp;gt; 2&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
2&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;Number of nodes: 1 ≤ n ≤ 10^5&lt;br&gt;
Node values: 1 ≤ data ≤ 10^5&lt;br&gt;
Expected time complexity: O(n)&lt;br&gt;
Expected space complexity: O(1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach&lt;/strong&gt;&lt;br&gt;
Start from the head node.&lt;br&gt;
Compare the current node with the next node.&lt;br&gt;
If they are equal, skip the next node by updating current.next.&lt;br&gt;
Otherwise, move to the next node.&lt;br&gt;
Repeat until the end of the list.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;def removeDuplicates(head):&lt;br&gt;
    current = head&lt;br&gt;
    while current and current.next:&lt;br&gt;
        if current.data == current.next.data:&lt;br&gt;
            current.next = current.next.next  # skip duplicate&lt;br&gt;
        else:&lt;br&gt;
            current = current.next&lt;br&gt;
    return head&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We use a pointer current to traverse the linked list.&lt;br&gt;
For each node, we check if its data is equal to the data of the next node.&lt;br&gt;
If yes, we skip the next node by pointing current.next to current.next.next.&lt;br&gt;
Otherwise, we move current forward.&lt;br&gt;
This ensures all duplicates are removed in one pass.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Reverse a Linked List</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:28:11 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/reverse-a-linked-list-2ec8</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/reverse-a-linked-list-2ec8</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given the head of a singly linked list, your task is to reverse the linked list and return the new head.&lt;/p&gt;

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

&lt;p&gt;Input: 1 -&amp;gt; 2 -&amp;gt; 3 -&amp;gt; 4 -&amp;gt; 5&lt;br&gt;
Output: 5 -&amp;gt; 4 -&amp;gt; 3 -&amp;gt; 2 -&amp;gt; 1&lt;/p&gt;

&lt;p&gt;Notes:&lt;/p&gt;

&lt;p&gt;The linked list may have any number of nodes.&lt;br&gt;
You can reverse it in-place or using extra space, depending on the approach.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 1: Iterative Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The iterative approach uses three pointers: prev, curr, and nextNode. At each step:&lt;/p&gt;

&lt;p&gt;Store curr.next in nextNode.&lt;br&gt;
Reverse the link: curr.next = prev.&lt;br&gt;
Move the pointers forward: prev = curr, curr = nextNode.&lt;br&gt;
Repeat until curr becomes None.&lt;br&gt;
Return prev as the new head.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;code&lt;/strong&gt;&lt;br&gt;
class Node:&lt;br&gt;
    def &lt;strong&gt;init&lt;/strong&gt;(self, data):&lt;br&gt;
        self.data = data&lt;br&gt;
        self.next = None&lt;/p&gt;

&lt;p&gt;def reverseList(head):&lt;br&gt;
    prev, curr = None, head&lt;br&gt;
    while curr:&lt;br&gt;
        nextNode = curr.next&lt;br&gt;
        curr.next = prev&lt;br&gt;
        prev = curr&lt;br&gt;
        curr = nextNode&lt;br&gt;
    return prev&lt;/p&gt;

&lt;p&gt;def printList(node):&lt;br&gt;
    while node:&lt;br&gt;
        print(node.data, end="")&lt;br&gt;
        if node.next:&lt;br&gt;
            print(" -&amp;gt; ", end="")&lt;br&gt;
        node = node.next&lt;br&gt;
    print()&lt;/p&gt;

&lt;p&gt;head = Node(1)&lt;br&gt;
head.next = Node(2)&lt;br&gt;
head.next.next = Node(3)&lt;br&gt;
head.next.next.next = Node(4)&lt;br&gt;
head.next.next.next.next = Node(5)&lt;/p&gt;

&lt;p&gt;head = reverseList(head)&lt;br&gt;
printList(head)&lt;/p&gt;

&lt;p&gt;Output:&lt;br&gt;
5 -&amp;gt; 4 -&amp;gt; 3 -&amp;gt; 2 -&amp;gt; 1&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach 2: Recursive Method&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The recursive approach works by:&lt;/p&gt;

&lt;p&gt;Recursively reaching the last node of the list.&lt;br&gt;
Making each node point back to its previous node as the recursion returns.&lt;br&gt;
Returning the new head of the reversed list. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;def reverseList(head):&lt;br&gt;
    if head is None or head.next is None:&lt;br&gt;
        return head&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;rest = reverseList(head.next)
head.next.next = head
head.next = None
return rest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Approach 3: Using a Stack&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The stack approach involves:&lt;/p&gt;

&lt;p&gt;Traversing the linked list and pushing all nodes onto a stack.&lt;br&gt;
Popping nodes from the stack and linking them in reverse order.&lt;br&gt;
Returning the new head.&lt;br&gt;
&lt;strong&gt;code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;def reverseList(head):&lt;br&gt;
    stack = []&lt;br&gt;
    temp = head&lt;br&gt;
    while temp:&lt;br&gt;
        stack.append(temp)&lt;br&gt;
        temp = temp.next&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;head = stack.pop()
temp = head
while stack:
    temp.next = stack.pop()
    temp = temp.next
temp.next = None
return head
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Comparison of Approaches&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Iterative: O(n) time, O(1) space – most efficient.&lt;br&gt;
Recursive: O(n) time, O(n) space – uses call stack.&lt;br&gt;
Stack: O(n) time, O(n) space – easy to use.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>beginners</category>
      <category>dsa</category>
      <category>python</category>
    </item>
    <item>
      <title>Majority Element</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:21:38 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/majority-element-57d6</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/majority-element-57d6</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given an array arr[], find the majority element in the array.&lt;/p&gt;

&lt;p&gt;A majority element is an element that appears strictly more than arr.size()/2 times.&lt;br&gt;
If no majority element exists, return -1.&lt;br&gt;
Examples&lt;br&gt;
Input: arr = [1, 1, 2, 1, 3, 5, 1]&lt;br&gt;
Output: 1&lt;/p&gt;

&lt;p&gt;Explanation: 1 appears more than 7/2 = 3.5 times.&lt;/p&gt;

&lt;p&gt;Input: arr = [7]&lt;br&gt;
Output: 7&lt;/p&gt;

&lt;p&gt;Explanation: Single element is trivially the majority.&lt;/p&gt;

&lt;p&gt;Input: arr = [2, 13]&lt;br&gt;
Output: -1&lt;/p&gt;

&lt;p&gt;Explanation: No element appears more than 2/2 = 1 times.&lt;/p&gt;

&lt;p&gt;Constraints&lt;br&gt;
1 ≤ arr.size() ≤ 10^5&lt;br&gt;
1 ≤ arr[i] ≤ 10^5&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach : Use Hash Map&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Count the frequency of each element using a dictionary. If an element count exceeds n//2, return it.&lt;/p&gt;

&lt;p&gt;from typing import List&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def majorityElement(self, arr: List[int]) -&amp;gt; int:&lt;br&gt;
        n = len(arr)&lt;br&gt;
        freq = {}&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    for num in arr:
        freq[num] = freq.get(num, 0) + 1
        if freq[num] &amp;gt; n // 2:
            return num

    return -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>algorithms</category>
      <category>coding</category>
      <category>computerscience</category>
      <category>python</category>
    </item>
    <item>
      <title>Search in Rotated Sorted Array</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:12:36 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/search-in-rotated-sorted-array-3j1f</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/search-in-rotated-sorted-array-3j1f</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You are given an integer array nums sorted in ascending order (with distinct values), which may be rotated at an unknown pivot index k (1 &amp;lt;= k &amp;lt; nums.length).&lt;/p&gt;

&lt;p&gt;Example of rotation: [0,1,2,4,5,6,7] rotated by 3 - [4,5,6,7,0,1,2].&lt;br&gt;
Given a target value, return the index of the target in nums, or -1 if it’s not present.&lt;/p&gt;

&lt;p&gt;You must achieve O(log n) runtime complexity.&lt;/p&gt;

&lt;p&gt;Examples&lt;br&gt;
Input: nums = [4,5,6,7,0,1,2], target = 0&lt;br&gt;
Output: 4&lt;br&gt;
Input: nums = [4,5,6,7,0,1,2], target = 3&lt;br&gt;
Output: -1&lt;br&gt;
Input: nums = [1], target = 0&lt;br&gt;
Output: -1&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;1 &amp;lt;= nums.length &amp;lt;= 5000&lt;br&gt;
-10^4 &amp;lt;= nums[i] &amp;lt;= 10^4&lt;br&gt;
All values of nums are unique&lt;br&gt;
nums is ascending but possibly rotated&lt;br&gt;
-10^4 &amp;lt;= target &amp;lt;= 10^4&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach: Modify the  Binary Search&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the array is rotated but sorted, a modified binary search works efficiently:&lt;/p&gt;

&lt;p&gt;Start with low = 0 and high = len(nums) - 1.&lt;br&gt;
While low &amp;lt;= high:&lt;br&gt;
Calculate mid = low + (high - low) // 2.&lt;br&gt;
If nums[mid] == target, return mid.&lt;br&gt;
Determine which side is sorted:&lt;br&gt;
If nums[low] &amp;lt;= nums[mid], the left side is sorted.&lt;br&gt;
If target lies within [nums[low], nums[mid]], search left (high = mid - 1), else search right.&lt;br&gt;
Else, the right side is sorted.&lt;br&gt;
If target lies within [nums[mid], nums[high]], search right (low = mid + 1), else search left.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;from typing import List&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def search(self, nums: List[int], target: int) -&amp;gt; int:&lt;br&gt;
        low, high = 0, len(nums) - 1&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while low &amp;lt;= high:
        mid = low + (high - low) // 2

        if nums[mid] == target:
            return mid

        # Left half is sorted
        if nums[low] &amp;lt;= nums[mid]:
            if nums[low] &amp;lt;= target &amp;lt; nums[mid]:
                high = mid - 1
            else:
                low = mid + 1
        # Right half is sorted
        else:
            if nums[mid] &amp;lt; target &amp;lt;= nums[high]:
                low = mid + 1
            else:
                high = mid - 1

    return -1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;Each iteration eliminates half of the search space by checking which half is sorted.&lt;br&gt;
Then we determine if the target lies in the sorted half.&lt;br&gt;
If yes, we search that half; otherwise, we search the other half.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>dsa</category>
      <category>interview</category>
      <category>leetcode</category>
    </item>
    <item>
      <title>First and Last Occurrences</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 08:02:25 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/first-and-last-occurrences-2pna</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/first-and-last-occurrences-2pna</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given a sorted array arr (which may contain duplicates), find the first and last occurrences of an element x.&lt;/p&gt;

&lt;p&gt;If x is not present in the array, return [-1, -1].&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;Input: arr = [1, 3, 5, 5, 5, 5, 67, 123, 125], x = 5&lt;br&gt;
Output: [2, 5]&lt;br&gt;
Input: arr = [1, 3, 5, 5, 5, 5, 7, 123, 125], x = 7&lt;br&gt;
Output: [6, 6]&lt;br&gt;
Input: arr = [1, 2, 3], x = 4&lt;br&gt;
Output: [-1, -1]&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;1 ≤ arr.size() ≤ 10^6&lt;br&gt;
1 ≤ arr[i], x ≤ 10^9&lt;/p&gt;

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

&lt;p&gt;Since the array is sorted, binary search allows us to efficiently find the first and last occurrences of x.&lt;/p&gt;

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

&lt;p&gt;First Occurrence:&lt;br&gt;
Perform binary search.&lt;br&gt;
If arr[mid] == x, move the high pointer to mid - 1 to check if x occurs earlier.&lt;br&gt;
Last Occurrence:&lt;br&gt;
Perform binary search.&lt;br&gt;
If arr[mid] == x, move the low pointer to mid + 1 to check if x occurs later.&lt;/p&gt;

&lt;p&gt;This ensures O(log n) time complexity for each search, perfect for large arrays.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python CODE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;from typing import List&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def find(self, arr: List[int], x: int) - List[int]:&lt;br&gt;
        n = len(arr)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    # Find first occurrence
    first, last = -1, -1
    low, high = 0, n - 1

    while low &amp;lt;= high:
        mid = low + (high - low) // 2
        if arr[mid] &amp;lt; x:
            low = mid + 1
        elif arr[mid] &amp;gt; x:
            high = mid - 1
        else:
            first = mid
            high = mid - 1  # Move left to find first occurrence

    # If element not found
    if first == -1:
        return [-1, -1]

    # Find last occurrence
    low, high = first, n - 1
    while low &amp;lt;= high:
        mid = low + (high - low) // 2
        if arr[mid] &amp;gt; x:
            high = mid - 1
        else:
            last = mid
            low = mid + 1  # Move right to find last occurrence

    return [first, last]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;How It Works:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Binary search allows skipping unnecessary elements.&lt;br&gt;
First occurrence moves left when arr[mid] == x.&lt;br&gt;
Last occurrence moves right when arr[mid] == x.&lt;br&gt;
Handles no occurrence by returning [-1, -1].&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>coding</category>
      <category>computerscience</category>
      <category>interview</category>
    </item>
    <item>
      <title>Squares of a Sorted Array</title>
      <dc:creator>Padma Priya R</dc:creator>
      <pubDate>Sun, 22 Mar 2026 07:57:04 +0000</pubDate>
      <link>https://dev.to/padma_priya_815d0cd613d0c/squares-of-a-sorted-array-383c</link>
      <guid>https://dev.to/padma_priya_815d0cd613d0c/squares-of-a-sorted-array-383c</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem Statement&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number, also sorted in non-decreasing order.&lt;/p&gt;

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

&lt;p&gt;Input: nums = [-4, -1, 0, 3, 10]&lt;br&gt;
Output: [0, 1, 9, 16, 100]&lt;/p&gt;

&lt;p&gt;Explanation:&lt;br&gt;
After squaring, the array becomes [16, 1, 0, 9, 100].&lt;br&gt;
After sorting, it becomes [0, 1, 9, 16, 100].&lt;/p&gt;

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

&lt;p&gt;Input: nums = [-7, -3, 2, 3, 11]&lt;br&gt;
Output: [4, 9, 9, 49, 121]&lt;/p&gt;

&lt;p&gt;Constraints:&lt;/p&gt;

&lt;p&gt;1 &amp;lt;= nums.length &amp;lt;= 10^4&lt;br&gt;
-10^4 &amp;lt;= nums[i] &amp;lt;= 10^4&lt;br&gt;
nums is sorted in non-decreasing order&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach: Two-Pointers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Since the array is sorted, negative numbers squared can be larger than positive numbers squared.&lt;br&gt;
A two-pointer approach allows us to place squares in the correct order without sorting:&lt;/p&gt;

&lt;p&gt;Initialize two pointers: left = 0 and right = len(nums) - 1.&lt;br&gt;
Compare abs(nums[left]) and abs(nums[right]).&lt;br&gt;
Place the larger square at the end of the result array.&lt;br&gt;
Move the corresponding pointer inward.&lt;br&gt;
Repeat until all elements are processed.&lt;/p&gt;

&lt;p&gt;This approach avoids the extra sorting step, giving O(n) complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Python Code&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;from typing import List&lt;/p&gt;

&lt;p&gt;class Solution:&lt;br&gt;
    def sortedSquares(self, nums: List[int]) - List[int]:&lt;br&gt;
        n = len(nums)&lt;br&gt;
        result = [0] * n&lt;br&gt;
        left, right = 0, n - 1&lt;br&gt;
        pos = n - 1&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    while left &amp;lt;= right:
        if abs(nums[left]) &amp;gt; abs(nums[right]):
            result[pos] = nums[left] ** 2
            left += 1
        else:
            result[pos] = nums[right] ** 2
            right -= 1
        pos -= 1

    return result
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;p&gt;The largest square is always at one of the ends.&lt;br&gt;
Fill the result array from right to left to maintain sorted order.&lt;br&gt;
Move the pointers inward until all elements are squared and placed correctly.&lt;/p&gt;

</description>
      <category>algorithms</category>
      <category>dsa</category>
      <category>interview</category>
      <category>leetcode</category>
    </item>
  </channel>
</rss>
