Problem Statement Implement an algorithm to print all valid (e g , properly opened and closed) combinations of n-pairs of parentheses Example Input: 3 (e g , 3 pairs of parentheses) Output: ()()(), ()(()), (())(), ((())) Solution public class PrintAllValidParens { static void solve(int l, int r, int i, char[] . . . Read more

Problem Statement Write a method to compute all permutations of a string Solution Let’s assume a given string represented by the letters To permute set , we can select the first character, , permute the remainder of the string to get a new list Then, with that new list, we . . . Read more

Problem statement You are given two 32-bit numbers, and , and two bit positions, and . Write a method to set all bits between and in equal to (e g , becomes a substring of located at and starting at ) Example Input: , , , Output: Solution public class . . . Read more

Problem Statement Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height. Solution We will try to create a binary tree such that for each node, the number of nodes in the left subtree and the right subtree are equal, if possible Algorithm: . . . Read more

Problem statement Given an array of integers, find the second smallest integer in that array. Solution public class SecondSmallestInteger { public static int solve(int[] arr) { int smallest = Integer.MAX_VALUE; int secondSmallest = Integer.MAX_VALUE; ; for (int i = 0; i < arr.length; i++) { if (arr[i] < smallest) { . . . Read more

Problem statement There are stairs, a person standing at the bottom wants to reach the top. The person can climb either stair or stairs at a time. Count the number of ways, the person can reach the top. Solution We can solve this problem recursively. If the person were to . . . Read more

This article assumes you know how to setup an EC2 instance with a running Apache web server and SSL. If you don’t know how to setup an EC2 instance with an Apache web server and a Let’s Encrypt SSL certificate please refer to this link: Migrating WordPress site from a . . . Read more

This article assumes you know how to setup an EC2 instance with a running Apache web server and SSL. If you don’t know how to setup an EC2 instance with an Apache web server and a Let’s Encrypt SSL certificate please refer to this link: Migrating WordPress site from a . . . Read more

Over the last few years I have applied and interviewed at a number of tech firms such as Google, Yelp, Microsoft, Amazon, Adobe and other big names. I have received offers from Palantir, Workday, Flixbus, etc. In order to be successful during those interviews (but also as an engineer in . . . Read more

Problem statement Given a linked list, determine if it has a cycle in it. Solution For the solution we are going to use a technique known as the two-pointer technique. That is we will involve two pointers: one slow-runner and the other fast-runner. The slow-runner will move forward 1 list . . . Read more