[LeetCode] Palindrome Rearrangement Queries

10034. Palindrome Rearrangement Queries

You are given a 0-indexed string s having an even length n.

You are also given a 0-indexed 2D integer array, queries, where queries[i] = [ai, bi, ci, di].

For each query i, you are allowed to perform the following operations:

  • Rearrange the characters within the substring s[ai:bi], where 0 <= ai <= bi < n / 2.
  • Rearrange the characters within the substring s[ci:di], where n / 2 <= ci <= di < n.

For each query, your task is to determine whether it is possible to make s a palindrome by performing the operations.

Each query is answered independently of the others.

Return a 0-indexed array answer, where answer[i] == true if it is possible to make s a palindrome by performing operations specified by the ith query, and false otherwise.

  • A substring is a contiguous sequence of characters within a string.
  • s[x:y] represents the substring consisting of characters from the index x to index y in s, both inclusive.
Read more
[LeetCode] Find Longest Special Substring That Occurs Thrice II

10033. Find Longest Special Substring That Occurs Thrice II

You are given a string s that consists of lowercase English letters.

A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.

Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.

A substring is a contiguous non-empty sequence of characters within a string.

Read more
[LeetCode] Find Longest Special Substring That Occurs Thrice I

10032. Find Longest Special Substring That Occurs Thrice I

You are given a string s that consists of lowercase English letters.

A string is called special if it is made up of only a single character. For example, the string "abc" is not special, whereas the strings "ddd", "zz", and "f" are special.

Return the length of the longest special substring of s which occurs at least thrice, or -1 if no special substring occurs at least thrice.

A substring is a contiguous non-empty sequence of characters within a string.

Read more
[LeetCode] Check if Bitwise OR Has Trailing Zeros

10031. Check if Bitwise OR Has Trailing Zeros

You are given an array of positive integers nums.

You have to check if it is possible to select two or more elements in the array such that the bitwise OR of the selected elements has at least one trailing zero in its binary representation.

For example, the binary representation of 5, which is "101", does not have any trailing zeros, whereas the binary representation of 4, which is "100", has two trailing zeros.

Return true if it is possible to select two or more elements whose bitwise OR has trailing zeros, return false otherwise.

Read more
[Codeforces] Alpha Round 21 (Codeforces format) C. Stripe 2Read more
[Codeforces] Beta Round 26 (Codeforces format) C. ParquetRead more
[Codeforces] Beta Round 27 (Codeforces format, Div. 2) E. Number With The Given Amount Of DivisorsRead more
[Codeforces] Beta Round 29 (Div. 2, Codeforces format) D. Ant on the TreeRead more
[LeetCode] Largest Substring Between Two Equal Characters

1624. Largest Substring Between Two Equal Characters

Given a string s, return the length of the longest substring between two equal characters, excluding the two characters. If there is no such substring return -1.

A substring is a contiguous sequence of characters within a string.

Read more
[Codeforces] Beta Round 31 (Div. 2, Codeforces format) D. ChocolateRead more