You are given two non-empty linked lists where each node contains a single digit representing a non-negative integer. Add the two numbers and return the sum as a linked list, ensuring the most significant digit is at the head of the list.
You are given n distinct points in the 2D plane. A boomerang is defined as a tuple of three points (i, j, k) where the distance between points i and j equals the distance between points i and k. Count the total number of boomerangs that can be formed from the given points.
Design an algorithm to serialize and deserialize a binary search tree (BST). Serialization is converting the tree to a string format, while deserialization reconstructs the tree from this string. The goal is to ensure that the BST can be serialized to a compact string and can be accurately deserialized back into the original tree structure.
Given a string, sort its characters based on their frequency of occurrence in descending order. If multiple solutions are possible, any valid answer is acceptable. The frequency of each character refers to how many times it appears in the string.
There are several balloons attached to a flat wall, represented as intervals along the x-axis. Each balloon’s horizontal span is given by a pair of integers [xstart, xend], and you must find the minimum number of arrows required to burst all the balloons. An arrow travels infinitely upwards and bursts any balloon that overlaps with its path.
You are given four integer arrays nums1, nums2, nums3, and nums4 all of length n. Your task is to find the number of quadruples (i, j, k, l) such that nums1[i] + nums2[j] + nums3[k] + nums4[l] == 0. The indices i, j, k, and l should be between 0 and n-1.