Python Data Processing and String Manipulation Exercises

Selective Divisor Extraction Identify integers within a specified range that are divisible by either 5 or 6, but exclude those divisible by both (30). def find_special_divisors(limit=10000): results = [] for num in range(1, limit + 1): if (num % 5 == 0 or num % 6 == 0) and num % 30 != 0: results.append(num) retur ...

Posted on Fri, 03 Jul 2026 17:32:59 +0000 by Javizy

Optimizing Prisoner Allocation Using Union-Find and Binary Search

The problem involves distributing N prisoners into two separate prisons based on M pairs of conflicts. Each conflict pair is defined by two prisoner IDs and a conflict weight. The objective is to arrange the prisoners such that the maximum conflict weight among any two prisoners sharing the same prison is minimized. We need to determine this mi ...

Posted on Fri, 03 Jul 2026 16:29:09 +0000 by PHPSpirit

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

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

Essential Mathematical Algorithms for Programming

Fast Exponentiation Recursive Approach function fastExponentiation(base, exponent, modulus) { if (exponent === 0) return 1; const halfExp = fastExponentiation(base, Math.floor(exponent / 2), modulus); let result = (halfExp * halfExp) % modulus; if (exponent % 2 === 1) { result = (result * base) % modulus; ...

Posted on Wed, 01 Jul 2026 17:48:25 +0000 by varghesedxb

Graph Orientation, Permutation Cycle LCM, Interval Partitioning, and Card Sequence Matching

Directed Edge Orientation with Out-Degree ConstraintGiven an undirected graph, determine the number of ways to orient all edges such that every vertex has an out-degree of exactly 1. The result should be modulo 998244353.For such an orientation to exist, the number of edges must exactly equal the number of vertices, i.e., m = n. Furthermore, ev ...

Posted on Wed, 01 Jul 2026 17:40:45 +0000 by hairyjim

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

Find the Longest Consecutive Sequence in O(n) Time

To find the longest sequence of consecutive integers in an unsorted array with O(n) time complexity, use the following approach: Insert all elements into an unordered_set, which prvoides average O(1) lookup time and atuomatically removes duplicates. Iterate through each number in the set. Only start counting a sequence if the current number is ...

Posted on Tue, 30 Jun 2026 16:54:59 +0000 by manamino

Java Programming Fundamentals: Practical Exercises for Beginners

When entering the world of Java programming, a solid foundation is the first step toward success. To help you build a strong programming basse, we've designed a series of Java fundamental exercises aimed at mastering the core concepts and programming techniques of the language. Whether you're a beginner or a developer looking to strengthen your ...

Posted on Tue, 30 Jun 2026 16:39:12 +0000 by sjaccaud

Dynamic Programming Problem Solutions

Unique Substrings in Wraparound String Given a string p, find the number of unique non-empty substrings of p that are also substrings of the infinite wraparound string "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz...". The infinite string repeats the alphabet sequence cyclically. DP Solution: We'll use a DP array where dp[i] r ...

Posted on Mon, 29 Jun 2026 17:55:59 +0000 by eashton123