[LeetCode] Hash Divided String

3271. Hash Divided String

You are given a string s of length n and an integer k, where n is a multiple of k. Your task is to hash the string s into a new string called result, which has a length of n / k.

First, divide s into n / k substrings, each with a length of k. Then, initialize result as an empty string.

For each substring in order from the beginning:

  • The hash value of a character is the index of that character in the English alphabet (e.g., 'a' → 0, 'b' → 1, …, 'z' → 25).
  • Calculate the sum of all the hash values of the characters in the substring.
  • Find the remainder of this sum when divided by 26, which is called hashedChar.
  • Identify the character in the English lowercase alphabet that corresponds to hashedChar.
  • Append that character to the end of result.
Read more
[LeetCode] Find the Key of the Numbers

3270. Find the Key of the Numbers

You are given three positive integers num1, num2, and num3.

The key of num1, num2, and num3 is defined as a four-digit number such that:

  • Initially, if any number has less than four digits, it is padded with leading zeros.
  • The ith digit (1 <= i <= 4) of the key is generated by taking the smallest digit among the ith digits of num1, num2, and num3.

Return the key of the three numbers without leading zeros (if any).

Read more
[LeetCode] Convert Doubly Linked List to Array I

3263. Convert Doubly Linked List to Array I

You are given the head of a doubly linked list, which contains nodes that have a next pointer and a previous pointer.

Return an integer array which contains the elements of the linked list in order.

Read more
[LeetCode] Constructing Two Increasing Arrays

3269. Constructing Two Increasing Arrays

Given 2 integer arrays nums1 and nums2``nums1 and nums2, after doing the following.

Replace every 0 with an even positive integer and every 1 with an odd positive integer. After replacement, both arrays should be increasing and each integer should be used at most once.

Return the minimum possible largest number after applying the changes.

Read more
[Marisa OJ] GCD pairs countingRead more
[Codeforces] Helvetic Coding Contest 2024 online mirror (teams allowed, unrated) B1. Exact Neighbours (Easy)Read more
[Codeforces] Educational Round 165 (Rated for Div. 2) D. Shop GameRead more
[Codeforces] Round 943 (Div. 3) G1. Division + LCP (easy version)Read more
[Codeforces] Round 940 (Div. 2) and CodeCraft-23 D. A BIT of an InequalityRead more
[Codeforces] Round 938 (Div. 3) G. GCD on a gridRead more