Home

Kth Smallest Instructions

1643. Kth Smallest Instructions Bob is standing at cell (0, 0), and he wants to reach destination: (row, column). He can only travel right and down. You are going to help Bob by providing instructions for him to reach destination. The instructions are represented as a string, where each character is either: ‘H’, meaning move horizontally (go r...

Read more

Furthest Building You Can Reach

1642. Furthest Building You Can Reach You are given an integer array heights representing the heights of buildings, some bricks, and some ladders. You start your journey from building 0 and move to the next building by possibly using bricks or ladders. While moving from building i to building i+1 (0-indexed), If the current building’s height ...

Read more

Count Sorted Vowel Strings

1641. Count Sorted Vowel Strings Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted. A string s is lexicographically sorted if for all valid i, s[i] is the same as or comes before s[i+1] in the alphabet. Solution def countVowelStrings(self, n: int) -> int...

Read more

Check Array Formation Through Concatenation

1640. Check Array Formation Through Concatenation You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct. Your goal is to form arr by concatenating the arrays in pieces in any order. However, you are not allowed to reorder the integers in each array pieces[i]. Return true...

Read more

Count Substrings That Differ by One Character

1638. Count Substrings That Differ by One Character Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting substring is a substring of t. In other words, find the number of substrings in s that differ from some substring in t by ...

Read more

Path With Minimum Effort

1631. Path With Minimum Effort You are a hiker preparing for an upcoming hike. You are given heights, a 2D array of size rows x columns, where heights[row][col] represents the height of cell (row, col). You are situated in the top-left cell, (0, 0), and you hope to travel to the bottom-right cell, (rows-1, columns-1) (i.e., 0-indexed). You can m...

Read more

Arithmetic Subarrays

1630. Arithmetic Subarrays A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. More formally, a sequence s is arithmetic if and only if s[i+1] - s[i] == s[1] - s[0] for all valid i. Solution - Brute Force Find and sort the subarray. ...

Read more