All Posts

Leetcode 861: Score After Flipping Matrix

You are given a binary matrix where each row and column can be toggled independently. A toggle operation flips all values in a row or column (changing 0s to 1s and 1s to 0s). The matrix’s score is calculated by interpreting each row as a binary number and summing up these values. Your task is to determine the maximum score possible after performing any number of toggle operations.

Leetcode 863: All Nodes Distance K in Binary Tree

Given a binary tree, a target node within the tree, and a non-negative integer k, determine all the nodes that are exactly k edges away from the target node. Return these node values as a list in any order.

Leetcode 865: Smallest Subtree with all the Deepest Nodes

Given the root of a binary tree, return the smallest subtree that contains all the nodes with the maximum depth in the tree. A node is considered the deepest if it has the greatest distance to the root among all nodes. The subtree of a node consists of the node itself and all its descendants.

Leetcode 866: Prime Palindrome

Given an integer n, find the smallest integer that is both a prime number and a palindrome, and is greater than or equal to n. A prime number is an integer greater than 1 with no divisors other than 1 and itself. A palindrome is a number that reads the same forwards and backwards.

Leetcode 869: Reordered Power of 2

Given an integer n, check if it is possible to reorder its digits (in any order, including the original order) to form a number that is a power of two. Leading digits cannot be zero in the reordered number.

Leetcode 870: Advantage Shuffle

Given two integer arrays nums1 and nums2 of the same length, the goal is to permute nums1 in a way that maximizes the number of indices i where nums1[i] > nums2[i]. Return any permutation of nums1 that achieves this.