Maze Problems

We observe that left = r-1, c and right = c, r-1. For counting the total ways just return left + right. Including all paths (Using Backtracking) Output

How Many Numbers Are Smaller Than the Current Number

1365. How Many Numbers Are Smaller Than the Current Number (Easy) Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of valid j’s such that j != i and nums[j] < nums[i]. Return the answer in an array. Example 1: Input: nums = [8,1,2,2,3] Output: … Read more

Number of Good Pairs (LeetCode)

1512. Number of Good Pairs (Easy) Given an array of integers nums, return the number of good pairs. A pair (i, j) is called good if nums[i] == nums[j] and i < j. Example 1: Input: nums = [1,2,3,1,1,3] Output: 4 Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed. Example 2: Input: nums = [1,1,1,1] Output: 6 Explanation: Each pair in the array are good. … Read more