## Java Program To Search For A Range In Sorted Array

Problem: We need to find first and last positions of an element in a sorted array.  In case element is not present, we need to return [-1, -1]. Input: A = [5, 7, 7, 8, 8, 10] B = 8Output: [3, 4] This is an interview question which is asked in companies like Google & … Read more

## Java Program to Invert the Binary Tree

Inverting a binary tree is common interview question. Input: 1 / 2 3 / / 4 5 6 7 Output: 1 / 3 2 / / 7 6 5 4 We can use recursion to swap left & right sub-trees. Time complexity would be O(n) as we will be doing a full traversal of the … Read more

## Java Program to Solve Median of Two Sorted Array Problem

Median of two sorted arrays is a common problem which is asked in companies like Amazon, Google, Microsoft & Goldman Sachs. You can find the question in InterviewBit or LeetCode. Problem:  We have two sorted arrays A and B of size m and n respectively. We need to find the median of these two sorted … Read more

## Java Program For Shortest Unique Prefix Problem

Shortest Unique Prefix is an interview question which you can find in websites like GeeksForGeeks & InterviewBit. It is asked in Google interviews. Basically we need to find shortest unique prefix to represent each word in the list. Input: [zebra, dog, duck, dove]Unique Prefix of each word is as below:zebra = zdog = dogduck = … Read more

## Better Explanation Of Order of People Heights Problem And Java Program To Solve It

Order of People Heights is an interview question that is asked in Google. You can find the question in websites like InterviewBit & CareerCup. But the problem is that you won’t find a good explanation of the problem anywhere. Let me try to describe the problem statement clearly. Input : Heights: 5 3 2 6 … Read more

## How To Use Flash Drive In Both macOS And Windows Laptop

I have Mac OS & Windows laptops. I use both of them quite frequently. Now I have an external hard drive that I want to use for both Mac & Windows laptops. Basically the flash drive should be able to transfer or copy/paste files from Windows laptop to MacOS. Or I should be able to … Read more

## Java Program For Sum Root to Leaf Numbers

Sum Root to Leaf Numbers is a popular interview problem which is asked in companies like Google & Microsoft. You can find this question in LeetCode & InterviewBit. We have been given a binary tree where each node can contain any number between 0-9. 2 / 4 8 For the above tree, there are two … Read more

## Java Program for Least Common Ancestor Of A Binary Tree

This is common interview question. There can be a variant where we would have to find Least Common Ancestor (LCA) of a Binary Search Tree (BST). But here we will concentrate our solution for a normal unordered Binary Tree. This question is asked in companies like FaceBook, Google, Adobe, Microsoft & Amazon. You can find … Read more