L-Shaped String Transformation
Given a string s and a number of rows numRows, arrange the string in an L-shaped pattern from top to bottom, left to right. Then, read the characters row by row from left to right to produce a new string. Implement this transformation with the function signature:
transform(s: string, numRows: number) => string
For example, with input string ...
Posted on Thu, 14 May 2026 21:23:58 +0000 by LDusan
L2-002 Linked List Deduplication
Given a linked list L with integer keys, you need to remove nodes with duplicate absolute key values. That is, for each key K, only the first node with absolute value K is kept. Meanwhile, all removed nodes must be saved in another linked list. For example, given L as 21→-15→-15→-7→15, you should output the deduplicated list 21→-15→-7 and the r ...
Posted on Wed, 13 May 2026 21:51:45 +0000 by nolos
Practical Applications of Binary Search and Fractional Programming
Binary search is a fundamental algorithm with applications in various computational problems. The key considerations when implementing binary search include identifying the search target, determining search boundaries, and designing the validation function.
Music Notes Timing Analysis
Determine the number of songs played within a given time fra ...
Posted on Wed, 13 May 2026 19:18:36 +0000 by Ghost_81st
Validating Balanced Parentheses in Strings
Given a string s containing only the characters '(', ')', '{', '}', '[', and ']', determine if the string is valid. A valid string satisfies:
Every opening bracket must be closed by a matcihng bracket of the same type.
Brackets must close in the correct order.
Each closing bracket croresponds to an opening bracket of the same type.
Example 1: ...
Posted on Wed, 13 May 2026 17:47:57 +0000 by joaca
Validating Structural Properties of Binary Search Trees
A Binary Search Tree (BST) is defined as either an empty tree or a tree satisfying these conditions: for any node, all values in its left subtree are less than its own value, and all values in its right subtree are greater. Both subtrees must also be BSTs.
Given a sequence of unique integers, insert them sequentially into an initial empty BST. ...
Posted on Wed, 13 May 2026 14:51:39 +0000 by vaanil
Greedy Algorithm: Minimum Cameras to Monitor a Binary Tree
Greedy Algorithm: Minimum Cameras to Monitor a Binary Tree
Given a binary tree, we need to place cameras on nodes such that every node in the tree is monitored. A camera placed on a node monitors itself, its parenet, and its immediate children. Determine the minimum number of cameras required.
Approach
We can solve this problem using a greedy a ...
Posted on Wed, 13 May 2026 14:26:44 +0000 by TPerez
Pairwise Node Swapping, Removing the Nth Node from End, Intersection of Linked Lists, and Detecting Cycles in Linked Lists
Pairwise Swapping of Adjacetn Nodes in a Linked List
Given a linked list, swap every two adjacent nodes and return the head of the modified list. The operation must be performed by exchanging nodes, not by altering their internal values.
Implementation approach: Use a dummy head node to simplify edge cases. Iterate through the list, adjusting p ...
Posted on Wed, 13 May 2026 12:01:00 +0000 by Averice
Understanding the Bubble Sort Algorithm
Algorithm Overview
Bubble sort is a foundational comparison-based sorting technique. It operates by iterating through a list, examining adjacent elements, and swapping them if they are in the incorrect order. This process causes the larger values to gradually "bubble" to the end of the array with each complete pass. The algorithm cont ...
Posted on Wed, 13 May 2026 10:39:47 +0000 by dbair
Solutions for Blue Bridge Cup C++ B Group Problems
Date Statistics
The first four digits are fixed. Generate the last four digits using nested loops, record valid dates, then verify if these dates can be formed.
Verification method:
Since it's a subsequence problem, we can skip elements but maintain relative order. For the given 100 numbers, match each digit sequentially with the 8-digit date. ...
Posted on Wed, 13 May 2026 03:48:22 +0000 by mebar3
Two Algorithm Problems: Ring Position Simulation and Game Theory Analysis
Problem 1: Ring Position Simulation
Description:
There are $2n$ people standing in two rings of size $n$ each. They are numbered from $1$ to $2n$, where positions $1$ to $n$ form ring 1 and positions $n+1$ to $2n$ form ring 2.
Both rings start counting from $1$ simultaneously. Ring 1 starts from person $1$, and ring 2 starts from person $n+1$. ...
Posted on Wed, 13 May 2026 03:15:34 +0000 by Canadian