All Posts

Leetcode 1311: Get Watched Videos by Your Friends

You are given n people with unique IDs and two lists: watchedVideos and friends. For a given ID and a level k, find the list of videos watched by people at exactly level k from you. Return the videos ordered by their frequency (in increasing order), and alphabetically if there is a tie in frequency.

Leetcode 1314: Matrix Block Sum

Given a matrix of integers, where each element represents a value, you need to calculate the sum of all elements in a sub-matrix for each cell. For each cell, the sub-matrix includes all elements within a square grid of size (2k+1) x (2k+1) centered at that cell. If the sub-matrix extends beyond the boundaries of the matrix, only the valid elements within the matrix should be considered.

Leetcode 1315: Sum of Nodes with Even-Valued Grandparent

Given the root of a binary tree, return the sum of the values of the nodes that have an even-valued grandparent. If there are no nodes with an even-valued grandparent, return 0. A grandparent is defined as the parent of a node’s parent, if it exists.

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 1319: Number of Operations to Make Network Connected

You are given a network of computers, each labeled from 0 to n-1, and a list of direct connections between these computers. The network is initially connected in some way, but some computers are not directly connected. You can remove cables from existing direct connections and reconnect them between disconnected computers to minimize the number of operations required to make the entire network fully connected. The task is to determine the minimum number of operations needed. If it’s not possible to connect all the computers, return -1.

Leetcode 1325: Delete Leaves With a Given Value

You are given the root of a binary tree and an integer target. Your task is to remove all leaf nodes that have the value equal to the target. Once you remove a leaf node with the target value, if its parent node becomes a leaf node and has the same value, it should also be removed. This process should continue until no more leaf nodes with the target value are present.