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,...

Continue reading »

Remove duplicates from a LinkedList in PHP

The question we are going to take a look at today is how to remove duplicates from a LinkedList. We’re going to be using PHP for the coding part, just because it’s the language I use more these days. Remember, languages don’t matter as much...

Continue reading »

Swap Node Pairs

Hello again everyone! Been sometime since I wrote here. Today I wanted to take a peek at a simple Linked List problem – Swap Node Pairs. Took me a bout 5 mins to write it out so it should be a cup of tea! Given...

Continue reading »

Mergesort implementation

I was asked to write a simple merge-sort implementation as the initial warm-up part of an interview. (Meaning knowing how to implement merge-sort is a must-have requirement rather than an optional knowledge). So what’s the algorithm for Merge Sort? We need to divide and conquer!...

Continue reading »

Reverse Integer

Today we are going to be visiting a very simple problem, which need some basic maths though. Given an integer, reverse it and return the reversed integer. Sample runs are: 135 -> 531, -12 -> -21, 0 -> 0. /* * @Author: Ajk Palikuqi *...

Continue reading »

Find Longest Path in Tree

Today’s question is going to be a quick one. We want to find longest path in tree. What does Path mean in a Tree context? The Tree wikipedia page and Tree/Graph Theory shed some light. Longest Path is the longest path from any two nodes...

Continue reading »

Print all sets of factors

Today we will take a look at a problem I personally got asked in an interview! It is called “Print all sets of factors”. Basically, we will try to write a program that takes an integer as input and print all sets of factors (i.e....

Continue reading »