Lowest Common Ancestor in a BST
Given a Binary Search Tree (with all values unique) and two nodes n1 and n2 (n1 != n2). You may assume that both nodes exist […]
Given a Binary Search Tree (with all values unique) and two nodes n1 and n2 (n1 != n2). You may assume that both nodes exist […]
Given a positive integer n, return the punishment number of n. The punishment number of n is defined as the sum of the squares of all integers i such that: 1
Design an algorithm that accepts a stream of integers and retrieves the product of the last k integers of the stream. Implement
Given the root of a Binary search tree(BST), where exactly two nodes were swapped by mistake. Your task is to fix (or correct) the
You are given a 0-indexed integer array nums, and an integer k. In one operation, you will: Take the two smallest integers x and y in nums. Remove x and y from nums. Add min(x,
Given a Binary Search Tree(BST) and a target. Check whether there’s a pair of Nodes in the BST with value summing
You are given a 0-indexed array nums consisting of positive integers. You can choose two indices i and j, such that i != j, and the sum of digits of
Given a BST and an integer k, the task is to find the kth smallest element in the BST. If there is no kth
Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Find the leftmost occurrence of the substring part and remove it from s. Return s after removing
You are given a string s. Your task is to remove all digits by doing this operation repeatedly: Delete the first digit and the closest non-digit character to
Given a binary tree and an integer k, determine the number of downward-only paths where the sum of the node values in the path equals k.
You are given two strings s1 and s2 of equal length. A string swap is an operation where you choose two indices in a string (not