Mon. Jun 5th, 2023

# Category: Coding

#### LeetCode – Strings – Make String Great

Given a string s of lower and upper case English letters. A good string is a string which doesn’t have two adjacent characters s[i] and s[i + 1] where: To make the string good, you can choose two…

#### LeetCode – Strings – Path Crossing

Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively. You start at the origin (0, 0) on a 2D plane and walk on the path…

#### LeetCode – Strings – Reformat Date

Given a date string in the form Day Month Year, where: Convert the date string to the format YYYY-MM-DD, where: Example 1: Input: date = "20th Oct 2052" Output: "2052-10-20" Example 2: Input: date…

#### LeetCode – Arrays – Last Stone Weight

We have a collection of stones, each stone has a positive integer weight. Each turn, we choose the two heaviest stones and smash them together.  Suppose the stones have weights x and y with x <= y.  The result…

#### LeetCode – Arrays – Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1‘s elements in the corresponding places of nums2. The Next Greater Number of a number x in nums1 is…

#### LeetCode – Stack – Remove All Adjacent Duplicates In String

Given a string S of lowercase letters, a duplicate removal consists of choosing two adjacent and equal letters, and removing them. We repeatedly make duplicate removals on S until we no longer can. Return the…

#### LeetCode – Stack – Build an Array With Stack Operations

Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}. Build the target array using the following operations: You are guaranteed that the target array is…

#### LeetCode – Stack – Remove Outermost Parentheses

Given an array target and an integer n. In each iteration, you will read a number from  list = {1,2,3..., n}. Build the target array using the following operations: You are guaranteed that the target array is…

#### LeetCode – Stack – Remove Outermost Parentheses

A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.  For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. A valid…

#### LeetCode – Hashtable – Number of Good Pairs

Given an array of integers nums. A pair (i,j) is called good if nums[i] == nums[j] and i < j. Return the number of good pairs. 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)…