Blog Posts

How to Solve the House Robber II Challenge in Java

October 22, 2020

The challenge You are a professional robber planning to rob houses along a street.


Read More

How to Clone a Graph in Java

October 21, 2020

The challenge Given a reference of a node in a connected undirected graph.


Read More

How to Return Random Values in Java

October 20, 2020

The challenge Ghost objects are instantiated without any arguments. Ghost objects are given a random color attribute of white" or “yellow” or “purple” or “red” when instantiated


Read More

How to Compare Version Numbers in Java

October 19, 2020

The challenge Compare two version numbers version1 and version2. If <em>version1</em> > <em>version2</em> return 1; if <em>version1</em> < <em>version2</em> return -1;otherwise return ``.


Read More

How to Return the First N Elements in Java

October 18, 2020

The challenge Create a method take that accepts a list/array and a number n, and returns a list/array array of the first n elements from the list/array.


Read More

How to Search a 2d Matrix/Array in Java

October 17, 2020

The challenge Write an efficient algorithm that searches for a value in an m x n matrix.


Read More

Calculate the Surface Area and Volume of a Box with Java

October 16, 2020

The challenge Write a function that returns the total surface area and volume of a box as an array: [area, volume]


Read More

Find Numbers which are Divisible by given Number in Java

October 15, 2020

The challenge Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor.


Read More

How to Split a Subdirectory to a New Git Repository and Keep the History

October 14, 2020

There comes a time when you need to split out a subdirectory into it’s own git repo.


Read More

Get the Maximum XOR of Two Numbers in an Array in Java

October 13, 2020

The challenge Given a non-empty array of numbers, a, a1, a2, … , an-1, where 0 ≤ ai < 231.


Read More

How to Get the Opposite of a Number in Java

October 12, 2020

The challenge Given a number, find its opposite. Examples: 1: -1 14: -14 -34: 34 The solution in Java We return the number itself multiplied by a negative 1.


Read More

How to Find the Area or Perimeter of a 4-sided Polygon using Java

October 11, 2020

The challenge You are given the length and width of a 4-sided polygon.


Read More

How to Parse Int from Char in Java

October 10, 2020

The challenge We take in a String where the first place contains a number, write a function that takes in this String and returns an int containing it.


Read More

How to Search a Binary Tree in Java

October 9, 2020

The challenge Given a sorted (in ascending order) integer array nums of n elements and a target value, write a function to search target in nums.


Read More

How to Rotate a Singly Linked List in Java

October 8, 2020

The challenge Given a linked list, rotate the list to the right by k places, where k is non-negative.


Read More

How to Insert into a Binary Search Tree using Java

October 7, 2020

The challenge You are given the root node of a binary search tree (BST) and a value to insert into the tree.


Read More

Find the Complement of Base 10 Integer in Java

October 6, 2020

The challenge Every non-negative integer N has a binary representation. For example, 5 can be represented as "101" in binary, 11 as "1011" in binary, and so on.


Read More

Solve the Number of Recent Calls Challenge in Java

October 5, 2020

The challenge You have a RecentCounter class which counts the number of recent requests within a certain time frame.


Read More

How to Calculate the Summation of a Number in Java

October 4, 2020

The challenge Write a program that finds the summation of every number from 1 to num.


Read More

How to Calculate all Unique Combinations of a Target using Backtracking in Java

October 3, 2020

The challenge Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target.


Read More