All Posts
Leetcode 1572: Matrix Diagonal Sum
You are given a square matrix of integers. Your task is to calculate the sum of all the elements located on the primary diagonal and the secondary diagonal, excluding the element that appears on both diagonals (i.e., the center element in an odd-sized matrix).
Leetcode 1577: Number of Ways Where Square of Number Is Equal to Product of Two Numbers
Given two integer arrays, nums1 and nums2, return the total number of valid triplets that can be formed under two conditions:
Type 1: A triplet (i, j, k) is valid if nums1[i]^2 == nums2[j] * nums2[k] where 0 <= i < nums1.length and 0 <= j < k < nums2.length. Type 2: A triplet (i, j, k) is valid if nums2[i]^2 == nums1[j] * nums1[k] where 0 <= i < nums2.length and 0 <= j < k < nums1.length.