Coding Exercise Posts - page 25 of 43

Recent posts

Shortest String

less than 1 minute read

Given a string s consisting only of "1"s and "0"s, you can delete any two adjacent letters if they are different.

Shift to Create Range

1 minute read

You are given a list of integers nums of length n. Return whether you can make a list [1, 2, ..., n] or [n, n - 1, ..., 1] by shifting nums to the right any ...

Set

1 minute read

Implement a set data structure with the following methods:

Sentence Reversal

less than 1 minute read

Given a list of strings sentence where each sentence[i] is a string with single character, reverse the order of the words in the sentence.

Selling Products

1 minute read

You are given a list of integers items and an integer n. A salesperson has items in a bag with random IDs. The salesperson can remove as many as n items from...

Second Place

less than 1 minute read

Given a binary tree root, return the depth of the second deepest leaf. Note that if there are multiple deepest leaves, the second deepest leaf is the next hi...

Search in a Virtually Complete Binary Tree

1 minute read

Consider a complete binary tree of n nodes whose values are 1 to n. The root has value of 1, its left child is 2 and its right child is 3. In general, nodes’...

Search in a Binary Search Tree

less than 1 minute read

Given a binary search tree root and an integer val, determine whether val is in the tree.

Run-Length Encoding

less than 1 minute read

Given a string s, return its run-length encoding. You can assume the string to be encoded have no digits and consists solely of alphabetic characters.

Run-Length Decoding

less than 1 minute read

Given a string s, consisting of digits and lowercase alphabet characters, that’s a run-length encoded string, return its decoded version.

Run-Length Decoded String Iterator

less than 1 minute read

Given a run-length encoded lowercase alphabet string s, implement an iterator which is the decoded version of s:

Rotation of Another String

1 minute read

Given two alphabet (can be lower and/or uppercase) strings s0 and s1, determine if one is a rotation of the other.