Category: coding exercise
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, …
Return the preorder traversal of a binary tree’s nodes’ values. The pre-order displays the root/current node’s value first, then recursively calling into its left sub tree and right sub …
Reverse a linked list from position m to n. For example: Given 1-2-3-4-5-NULL, m = 2 and n = 4, return 1-4-3-2-5-NULL. 1 ≤ m ≤ n ≤ length …
Write a function to reverse only the vowels of a string. Example: Given s = “hello”, return “holle”. A vowel is one of the following 10 letters (both uppercase …
Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: Almost every tree …