The flood fill problem is a way to fill a region of connected pixels with a new colour, starting from a given pixel in an image. You are given an image represented by an m x n grid of integers, where the image[i] represents the pixel value at position (i, j). You are also given the coordinates of a starting pixel (x, y) and a new colour to use for the flood fill operation.
Given two binary trees, write a program to merge them into a single binary tree. We need to merge them such that if two nodes overlap then add them and put them into the new tree at the same position. Otherwise, put the non-NULL node in the new tree. Note: This is an excellent problem to learn problem solving using iterative and recursive preorder traversal.
Subscribe to get well designed content on data structure and algorithms, machine learning, system design, object orientd programming and math.