Today we are going to take a look at slightly mathematical problem: Find Whether a Number Can Be the Sum of Two Squares. Being asked this question, our first step, as always, should be to clear out assumptions. As I’ve mentioned in my Find Two...

## How to Find Two Primes Whose Sum is Equal to a Number N

How to Find Two Primes Whose Sum is Equal to a Number N? I have been asked questions about primes in many, many interviews and this is definitely one of the questions that have stuck with me. First thing first, as always, let us clear...

## Rotate a 2D Matrix by 90 Degrees in Java

Today we are going to take a look at a fairly common interview question! How to Rotate a 2D Matrix by 90 Degrees in Java has a lot to do with basic linear algebra / geometry. Basically we are asked to rotate a rectangular object...

## How to Find Duplicate Number From Continuous Array

How to Find Duplicate Number From Continuous Array? I got asked this very question a long time ago at an on-site interview. It is supposed to be one of the easier questions, but I can see how certain nuances of it can become hard. First...

## How To Count Numbers Having Unique Digits In Java

How To Count Numbers Having Unique Digits In Java? This is a fairly simple looking question that gets used a lot in interviews. But although it looks simple, it has quite a bit of maths involved. We are going to take a look at a...

## Find Intersection Point of 2 Linked Lists in Java

Today we will take a look at a simple question I was asked some years ago when interviewing for an internship! The question is called “Find Intersection Point of 2 Linked Lists in Java”. Basically, we will try to write a program that takes two...

## Check if a binary tree is a BST in Java

This is a question that comes quite often as a preliminary / phone interview question. How do we check if a binary tree is a BST in Java? In other words we need to validate if a binary tree is a binary search tree. As...

## Find repeated 10 char sequences in DNA sample

FindĀ repeated 10 char sequences in DNA sampleĀ is just a modified version of Find all repeated substrings of size K, which is a pretty common question that gets asked in interviews. Since I did not find appropriate information about this question online, I decided to take...

## Merge Multiple Sorted Lists of Strings in Java

How would you Merge Multiple Sorted Lists of Strings into one list? I got asked this very question in an interview myself. And to my surprise I was not very sharp on it. The question is about developing an algorithm to find how to merge...

## Zig Zag Tree Traversal in Java

Write a method to find the zig zag tree traversal in a tree. I got asked this question once in an interview. Now I found a few solutions to this problem over the internet, but none was really explaining how to get to the solution,...