You can read the full story on The Swift Nerd blog with the link above.

Given a rectangular cake with height `h`

and width `w`

, and two arrays of integers `horizontalCuts`

and `verticalCuts`

where `horizontalCuts[i]`

is the distance from the top of the rectangular cake to the `ith`

horizontal cut and similarly, `verticalCuts[j]`

is the distance from the left of the rectangular cake to the `jth`

vertical cut.

*Return the maximum area of a piece of cake after you cut at each horizontal and vertical position provided in the arrays **horizontalCuts** and **verticalCuts**. *…

You can read the full story on The Swift Nerd blog with the link above.

You are given an `m x n`

binary matrix `grid`

. An island is a group of `1`

's (representing land) connected **4-directionally** (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water.

The **area** of an island is the number of cells with a value `1`

in the island.

Return *the maximum **area** of an island in *`grid`

. If there is no island, return `0`

.

**Example 1:**

Read the full story on The Swift Nerd blog with the link above.

Evaluate the value of an arithmetic expression in Reverse Polish Notation.

Valid operators are `+`

, `-`

, `*`

, and `/`

. Each operand may be an integer or another expression.

**Note** that division between two integers should truncate toward zero.

It is guaranteed that the given RPN expression is always valid. That means the expression would always evaluate to a result, and there will not be any division by zero operation.

Input:tokens = ["2","1","+","3","*"]Output:9Explanation:((2 + 1) * 3) = 9Input:tokens = ["4","13","5","/","+"]Output…

Check out the full story on The Swift Nerd blog with the link above.

Given a list of strings `words`

and a string `pattern`

, return *a list of* `words[i]`

*that match* `pattern`

. You may return the answer in **any order**.

A word matches the pattern if there exists a permutation of letters `p`

so that after replacing every letter `x`

in the pattern with `p(x)`

, we get the desired word.

Recall that a permutation of letters is a bijection from letters to letters: every letter maps to another letter, and no two letters map to the same letter.

**Input:** words…

You can read the full story on The Swift Nerd blog with the link above.

Given the `root`

of a binary tree, return *the level order traversal of its nodes’ values*. (i.e., from left to right, level by level).

You can read the full story on The Swift Nerd blog with the link above.

Given an integer array `nums`

of size `n`

, return *the minimum number of moves required to make all array elements equal*.

In one move, you can increment or decrement an element of the array by `1`

.

Input:nums = [1,2,3]Output:2Explanation:

Only two moves are needed (remember each move increments or decrements one element):

[1,2,3] => [2,2,3] => [2,2,2]Input:nums = [1,10,2,9]Output:16

`n == nums.length`

`1 <= nums.length <= 105`

`-109 <= nums[i] <= 109`

One brute force approach can…

If you are preparing for coding interviews, then check the amazing Swift Leetcode series on The Swift Nerd blog.

Given a list of words, each word consists of English lowercase letters.

Let’s say `word1`

is a predecessor of `word2`

if and only if we can add exactly one letter anywhere in `word1`

to make it equal to `word2`

. For example, `"abc"`

is a predecessor of `"abac"`

.

A *word chain *is a sequence of words `[word_1, word_2, ..., word_k]`

with `k >= 1`

, where `word_1`

is a predecessor of `word_2`

, `word_2`

is a predecessor of `word_3`

, and so on.

Return the…

You checkout the full story on The Swift Nerd blog with the link above.

A **valid number** can be split up into these components (in order):

- A
**decimal number**or an**integer**. - (Optional) An
`'e'`

or`'E'`

, followed by an**integer**.

A **decimal number** can be split up into these components (in order):

- (Optional) A sign character (either
`'+'`

or`'-'`

). - One of the following formats:
- At least one digit, followed by a dot
`'.'`

. - At least one digit, followed by a dot
`'.'`

, followed by at least one digit. - A dot
`'.'`

, followed by at least one digit.

An…

Check the full story on The Swift Nerd blog with the link above.

Given the `root`

of a binary tree, flatten the tree into a “linked list”:

- The “linked list” should use the same
`TreeNode`

class where the`right`

child pointer points to the next node in the list and the`left`

child pointer is always`null`

. - The “linked list” should be in the same order as a
**pre-order traversal**of the binary tree.

You can read the full story on The Swift Nerd blog along with other interesting ones.

You are given two lists of closed intervals, `firstList`

and `secondList`

, where `firstList[i] = [starti, endi]`

and `secondList[j] = [startj, endj]`

. Each list of intervals is pairwise **disjoint** and in **sorted order**.

Return *the intersection of these two interval lists*.

A **closed interval** `[a, b]`

(with `a < b`

) denotes the set of real numbers `x`

with `a <= x <= b`

.

The **intersection** of two closed intervals is a set of real numbers that are either empty or represented as a closed interval…

Senior iOS Engineer. Writer at https://theswiftnerd.com