Fading Coder

One Final Commit for the Last Sprint

Validating Palindrome Linked Lists

Problem StatementGiven the head of a singly linked list, determine whether the sequence of values reads identically forward and backward.Example 1:Input: 1 -> 2 Output: falseExample 2:Input: 1 -> 2 -> 2 -> 1 Output: trueApproach 1: Fast and Slow Pointers with In-Place ReversalThis method achieves O(...

Removing Duplicates from Sorted Array II Using Two Pointers

Problem Statement Given a sorted integer array nums, remove duplicates in-place sothat each unique element appears no more than twice. Return the new length of the array. Key constraints: Must modify the input array in-place Space complexity must be O(1) The function receives the array by reference...

Reviewing Array and Linked List Fundamentals

This review focuses on core techniques for arrays and linked lists, including practical C++ implementations. Arrays The most important concept for array problems is the two-pointer technique. Fast and Slow Pointers When removing or manipulating elements, nested loops lead to O(n²) time complexity. U...

Removing Duplicates from Sorted Arrays In-Place Using the Two‑Pointer Technique

Removing Duplicates from Sorted Arrays In-Place Using the Two‑Pointer Technique
Problem Description Given a sorted array, remove the duplicates in-place such that each element appears only once and return the new length. Do not allocate extra space for another array; you must modify the input array in-place with O(1) extra memory. Example 1: Given numbers = [1, 1, 2], The funct...

Circular Counting and Multi-Source Dijkstra on Graphs

D. On AtCoder Conference Problem Statement There is a circular pond with circumference (M). A hut and (N) people are located around the pond. For a real number (x) ((0\leq x < M)), the point (x) is defined as the position clockwise at distance (x) from the hut. The (i)-th person is at point (A_i)...