SMU Spring 2023 Trial Contest Round 9
A. Incorrect Subtraction
Simulate the process of subtracting 1 from the last digit of a number for k times. If the last digit is 0, remove it instead.
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 2e3 + 10, mod = 1e9 +7;
typedef pair<int,int> PII;
int n,m,t,k;
vector<int& ...
Posted on Fri, 03 Jul 2026 16:28:51 +0000 by mella
Stacks and Queues
Stacks follow the Last-In-First-Out (LIFO) principle (like a magazine of bullets). Insertions and deletions occur only at the top of the stack. A common application is the implementation of recursive calls.
Queues follow the First-In-First-Out (FIFO) principle (like a line for a COVID test). Insertions occur at the rear and deletions occur at t ...
Posted on Thu, 02 Jul 2026 17:10:02 +0000 by knox203
Implementing Circular Linked Lists and Function Variants in Go
Circular Linked Lists in Go
package main
import (
"container/ring"
"fmt"
)
func main() {
// Initialize a circular list with 5 elements
circularList := ring.New(5)
circularList.Value = 10
circularList.Next().Value = 20
circularList.Next().Next().Value = 30
circularList.Prev().Value = 40
circularList.Prev().Prev().V ...
Posted on Thu, 02 Jul 2026 16:36:48 +0000 by GBahle
Essential Algorithms for Coding Interviews: Merging Arrays, Linked Lists, and Tree Operations
Arrays and Strings
Merging Sorted Arrays
Naive Merge and Sort
class Solution {
public:
void combineArrays(vector<int>& arr1, int m, vector<int>& arr2, int n) {
for(int i = 0; i < n; ++i) {
arr1[m + i] = arr2[i];
}
sort(arr1.begin(), arr1.end());
}
};
Two-Pointer Forward Merg ...
Posted on Wed, 01 Jul 2026 18:08:43 +0000 by byronwells
Codeforces Round 894 (Div. 3) Solution Analysis
Problem A
Given n strings each of length m, determine whether there exist four columns satisfying 1 ≤ i < j < k < l ≤ m such that these four columns contain characters 'v', 'i', 'k', 'a' respectively.
Approach: Iterate through columns left to right, searching for each required character sequentially. For each column, scan all strings t ...
Posted on Wed, 01 Jul 2026 16:54:31 +0000 by zhahaman2001
Mastering Python's Sorted() Function for Efficient Data Sorting
In Python programming, the sorted() function is a built-in utility that allows you to sort various iterable objects. This function can be applied to lists, tuples, strings, and other iterable types, returning a new sorted list. The sorted() function provides several parameters that enable different sorting approaches, including custom sorting f ...
Posted on Tue, 30 Jun 2026 17:39:10 +0000 by Toy
Implementing Common Array Sorting and Manipulation Algorithms in Java
Array Sorting Techniques
Bubble Sort
Bubble sort is a fundamental sorting algorithm that repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. The process resembles bubbles rising to the surface, with larger values sinking to the end of the array.
Core Logic:
Iterate through the array com ...
Posted on Tue, 30 Jun 2026 16:31:28 +0000 by shaundunne
Optimizing Salesman Route with Greedy Approach
This document outlines a greedy strategy for a sales optimization problem.
Let's consider the sample input:
6
1 2 3 4 5 6
4 2 3 5 3 1
Assume the current location is at point X = 1. We define an array F, where F[i] represents the additional contribtuion to the total answer by visiting user a[i] without any detours. ans will store the cumulative ...
Posted on Sat, 27 Jun 2026 17:53:43 +0000 by MadTechie
Efficient Array Processing Using Two-Pointer Techniques
In-place modification refers to operations pefrormed directly on the original data structure without allocating new storage. For duplicate removal, a naive approach would involve creating a new array to store unique elements, but in-place constraints require modifying the existing array and returning its new effective length.
When dealing with ...
Posted on Sat, 27 Jun 2026 17:33:44 +0000 by jigsawsoul
Redis Explained: Core Concepts, Data Models, and Advanced Features
Understanding Redis Performance
Redis is renowned for its exceptional speed, a characteristic derived from several fundamental design choices:
In-Memory Operation: As a memory-based data store, Redis inherently benefits from the much faster read and write speeds of RAM compared to disk I/O.
Optimized Data Structures: It leverages highly effici ...
Posted on Sat, 27 Jun 2026 17:25:07 +0000 by bloo