All Posts

Leetcode 1310: XOR Queries of a Subarray

You are given an array of positive integers arr and an array of queries. For each query [lefti, righti], calculate the XOR of elements from index lefti to righti (inclusive). Return an array answer where each element corresponds to the XOR result of the respective query.

Leetcode 1318: Minimum Flips to Make a OR b Equal to c

You are given three positive integers, a, b, and c. Your task is to find the minimum number of bit flips required in a and b to make the result of (a OR b) equal to c. A bit flip consists of changing any bit from 0 to 1 or from 1 to 0.

Leetcode 1356: Sort Integers by The Number of 1 Bits

You are given an array of integers. Sort the array based on the number of 1’s in the binary representation of each integer. If two integers have the same number of 1’s, sort them in ascending order of the integer value.

Leetcode 1371: Find the Longest Substring Containing Vowels in Even Counts

Given a string s, find the size of the longest substring containing each vowel (‘a’, ’e’, ‘i’, ‘o’, ‘u’) an even number of times.

Leetcode 1386: Cinema Seat Allocation

A cinema has multiple rows, each with ten seats arranged in a line. Some seats are already reserved. You need to determine the maximum number of four-person groups that can be seated in the available seats. A four-person group requires four adjacent seats in one row. If an aisle splits a group in the middle, they can still be seated if there are two consecutive seats on both sides of the aisle.

Leetcode 1404: Number of Steps to Reduce a Number in Binary Representation to One

You are given a binary string representing a non-negative integer. The task is to determine the number of steps required to reduce this number to 1, following the rules: divide by 2 if the number is even, or add 1 if it is odd. Return the total number of steps required.