Coding Exercise Posts - page 24 of 43

Recent posts

Strictly Alternating List

1 minute read

You are given a list of integers nums. Return whether the list alternates from first strictly increasing to strictly decreasing and then strictly increasing ...

Square of a List

less than 1 minute read

Given a list of integers sorted in ascending order nums, square the elements and give the output in sorted order.

Split List

less than 1 minute read

Given a list of integers nums, return whether you can partition the list into two non-empty sublists such that every number in the left sublist is strictly l...

Sorting Mail

1 minute read

You are given a list of strings mailboxes. Each mailbox is a list of strings, where each string is either "junk", "personal", "work". Go through each mailbox...

Sorted Elements

less than 1 minute read

Give a list of numbers nums, return the number of elements that are in the correct indices, if the list were to be sorted.

Sort List by Reversing Once

1 minute read

You are given a list of integers nums. Given that you can first reverse one sublist in nums, return whether you can make the resulting list be arranged in as...

Sort List by Hamming Weight

1 minute read

You are given a lists of non-negative integers nums. Sort the list in ascending order by the number of 1s in binary representation for each number. If there ...

Social Distancing

1 minute read

You are given a string s and an integer k. Each character in the string is either '.' or 'x', where '.' represents an empty space and 'x' represents a person.

Smallest Number With No Adjacent Duplicates

less than 1 minute read

You are given a string s containing "1", "2", "3" and "?". Given that you can replace any “?” with "1", "2" or "3", return the smallest number you can make a...

Sibling Tree Value

1 minute read

You are given an integer k and a binary search tree root, where each node is either a leaf or contains 2 children.

Shortest Sublist With Max Frequency

1 minute read

You are given a list of integers nums. Let k be the frequency of a most frequent number in nums. Return the length of a shortest sublist such that the freque...

Shortest Sublist to Sort

1 minute read

Given a list of integers nums, return the length of the shortest sublist in nums which if sorted would make nums sorted in ascending order.