[Marisa OJ] DivisibilityRead more
[LeetCode] Convert 1D Array Into 2D Array

2022. Convert 1D Array Into 2D Array

You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with m rows and n columns using all the elements from original.

The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D array, the elements from indices n to 2 * n - 1 (inclusive) should form the second row of the constructed 2D array, and so on.

Return an m x n 2D array constructed according to the above procedure, or an empty 2D array if it is impossible.

Read more
[LeetCode] Minimum Amount of Damage Dealt to Bob

3273. Minimum Amount of Damage Dealt to Bob

You are given an integer power and two integer arrays damage and health, both having length n.

Bob has n enemies, where enemy i will deal Bob damage[i] points of damage per second while they are alive (i.e. health[i] > 0).

Every second, after the enemies deal damage to Bob, he chooses one of the enemies that is still alive and deals power points of damage to them.

Determine the minimum total amount of damage points that will be dealt to Bob before all n enemies are dead.

Read more
[LeetCode] Find the Count of Good Integers

3272. Find the Count of Good Integers

You are given two positive integers n and k.

An integer x is called k-palindromic if:

  • x is a palindrome.

  • x is divisible by k.

An integer is called good if its digits can be rearranged to form a k-palindromic integer. For example, for k = 2, 2020 can be rearranged to form the k-palindromic integer 2002, whereas 1010 cannot be rearranged to form a k-palindromic integer.

Return the count of good integers containing n digits.

Note that any integer must not have leading zeros, neither before nor after rearrangement. For example, 1010 cannot be rearranged to form 101.

Read more
[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