Coding Exercise Posts - page 9 of 43

Recent posts

Airplane Seat Shuffling

1 minute read

You are given an integer n representing the number of seats in an airplane. The first person has lost their ticket, so they pick a random seat. Everyone else...

Sort a Linked List

less than 1 minute read

Given a singly linked list of integers node, sort the nodes by their values in ascending order.

XOR Range Queries

1 minute read

You are given a list of integers nums and a two-dimensional list of integers queries. Each element in queries contains [i, j] and asks what is the value of n...

K Distinct Window

less than 1 minute read

Given a list of integers nums and an integer k, return a list of count of distinct numbers in each window of size k.

Subtree with Maximum Value

less than 1 minute read

Given a binary tree root, return the maximum sum of a subtree. A subtree is defined to be some node in root including all of its descendants. A subtree sum i...

Stack Sequence

1 minute read

Given a list of distinct integers pushes, and another list of integers pops, return whether this is a valid sequence of stack push and pop actions.

Optimal Decrement

1 minute read

You are given a list of integers nums and an integer k. You must subtract 1 from any element in the list k times. Return the minimum possible maximum value i...

Minimum Starting Nodes to Visit Graph

less than 1 minute read

You are given a two-dimensional list of integers edges representing a connected, directed, acyclic graph. Each element in edges contains [u, v] meaning there...

Longest Bitonic Subsequence

1 minute read

A sequence is called bitonic if it’s strictly increasing and then strictly decreasing. A sequence that is only strictly increasing is bitonic. Also, a sequen...

Linked List Intersection

less than 1 minute read

Given two sorted linked lists l0, and l1, return a new sorted linked list containing the intersection of the two lists.

Split String with Same Distinct Counts

less than 1 minute read

You are given a lowercase alphabet string s. Return the number of ways to split the string into two strings such that the number of distinct characters in ea...