All Posts

Leetcode 1496: Path Crossing

You are given a string path where each character represents a movement direction (‘N’ for north, ‘S’ for south, ‘E’ for east, ‘W’ for west). Starting from the origin (0, 0), follow the path and check if you cross your own path at any point, meaning visiting a location more than once. Return true if the path crosses itself, and false otherwise.

Leetcode 1497: Check If Array Pairs Are Divisible by k

You are given an array of integers arr of even length n and an integer k. The task is to check if you can divide the array into exactly n / 2 pairs such that the sum of each pair is divisible by k. Return true if it’s possible to divide the array into valid pairs, otherwise return false.

Leetcode 1512: Number of Good Pairs

You are given an array of integers. A pair (i, j) is called a good pair if nums[i] == nums[j] and i < j. Your task is to find the number of good pairs in the array.

Leetcode 1519: Number of Nodes in the Sub-Tree With the Same Label

You are given a tree with n nodes, where each node has a label, and your task is to find the number of nodes in the subtree rooted at each node that have the same label as that node.

Leetcode 1525: Number of Good Ways to Split a String

You are given a string s. You need to determine the number of valid ways to split s into two non-empty substrings such that the number of distinct letters in the left and right substrings is the same.

Leetcode 1540: Can Convert String in K Moves

You are given two strings s and t and a number k. Your task is to convert string s into string t using no more than k moves. In each move, you can choose an index j (1-based) from string s and shift the character at that index by i positions, where i is the current move number.