All Posts

Leetcode 1232: Check If It Is a Straight Line

You are given an array of coordinates, where each coordinate represents a point in the 2D plane. Your task is to check if all the points in the array lie on the same straight line.

Leetcode 1237: Find Positive Integer Solution for a Given Equation

You are given a callable function f(x, y) with a hidden formula and a target value z. Your task is to find all pairs of positive integers x and y such that f(x, y) == z. The function is monotonically increasing, meaning: f(x, y) < f(x + 1, y) and f(x, y) < f(x, y + 1). Return a list of all such pairs. If no valid pairs are found, return an empty list.

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 1247: Minimum Swaps to Make Strings Equal

You are given two strings s1 and s2 of equal length consisting only of ‘x’ and ‘y’. Your task is to make these two strings equal by swapping characters between the two strings. Return the minimum number of swaps required to make s1 and s2 equal, or return -1 if it is impossible.

Leetcode 1248: Count Number of Nice Subarrays

You are given an array of integers nums and an integer k. A subarray is considered ’nice’ if it contains exactly k odd numbers. Your task is to return the number of nice subarrays in the given array.

Leetcode 1266: Minimum Time Visiting All Points

You are given an array of points with integer coordinates. Calculate the minimum time to visit all points in the given order using vertical, horizontal, or diagonal movements.