All Posts

Leetcode 868: Binary Gap

Given a positive integer n, determine the maximum distance between any two adjacent 1’s in the binary representation of n. Two 1’s are adjacent if only 0’s separate them. If there are no two adjacent 1’s, return 0. The distance between two 1’s is the absolute difference in their positions when counting from the rightmost bit.

Leetcode 898: Bitwise ORs of Subarrays

Given an array of integers, return the number of distinct bitwise OR results from all the non-empty subarrays. A subarray is a contiguous sequence of elements from the array, and the bitwise OR of a subarray is the bitwise OR of each of the integers in that subarray.

Leetcode 957: Prison Cells After N Days

You are given a row of 8 prison cells, where each cell is either occupied or vacant. The state of the cells changes every day according to the following rules: If a cell has two adjacent neighbors that are either both occupied or both vacant, the cell becomes occupied; otherwise, it becomes vacant. The first and last cells don’t have two neighbors, so they are excluded from the rule. You need to determine the state of the cells after ’n’ days of changes.

Leetcode 1177: Can Make Palindrome from Substring

You are given a string s and an array of queries queries, where queries[i] = [lefti, righti, ki]. For each query, you can rearrange the substring s[lefti...righti] and replace up to ki characters in it with any lowercase English letters. Determine whether it is possible to form a palindrome from the resulting substring. Return an array of booleans answer where answer[i] is true if it is possible to form a palindrome for the i-th query, otherwise false.

Leetcode 1238: Circular Permutation in Binary Representation

Given two integers n and start, return a permutation of the integers from 0 to 2^n - 1 such that: p[0] = start, each pair of adjacent elements differ by exactly one bit in their binary representation, and p[0] and p[2^n - 1] also differ by exactly one bit.

Leetcode 1239: Maximum Length of a Concatenated String with Unique Characters

You are given an array of strings arr. Return the maximum possible length of a string s formed by concatenating a subsequence of arr such that all characters in s are unique.