Blog Posts

How to Flip a Binary Matrix in Java

November 11, 2020

The challenge Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image.


Read More

How to Tilt a Binary Tree in Java

November 10, 2020

The challenge Given the root of a binary tree, return the sum of every tree node’s tilt.


Read More

How to solve the House Robber Challenge in Java

November 9, 2020

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


Read More

How to Solve the Bag of Tokens Challenge in Java

November 8, 2020

The challenge You have an initial power of P, an initial score of ``, and a bag of tokens where tokens[i] is the value of the i<sup>th</sup> token (0-indexed).


Read More

How to Find the Smallest Divisor Given a Threshold in Java

November 7, 2020

The challenge Given an array of integers nums and an integer threshold, we will choose a positive integer divisor and divide all the array by it and sum the result of the division.


Read More

How to Sort and Star a String Array in Java

November 6, 2020

The challenge You will be given a vector of strings. You must sort it alphabetically (case-sensitive, and based on the ASCII values of the chars) and then return the first value.


Read More

How to Count Consecutive Characters in Java

November 5, 2020

The challenge Given a string s, the power of the string is the maximum length of a non-empty substring that contains only one unique character.


Read More

How to Abbreviate a Two Word Name in Java

November 4, 2020

The challenge Write a function to convert a name into initials.


Read More

How to Sort a Linked List using Insertion Sort in Java

November 3, 2020

The challenge Sort a linked list using insertion sort. A graphical example of insertion sort.


Read More

How to Remove First and Last Character in a String in Java

November 2, 2020

The challenge The goal is to create a function that removes the first and last characters of a string.


Read More

How to Distribute Halloween Candies by Rating Value in Java

November 1, 2020

The challenge There are N children standing in a line. Each child is assigned a rating value.


Read More

How to Distribute Halloween Candies in Java

October 31, 2020

The challenge You have n candies, the i<sup>th</sup> candy is of type candies[i].


Read More

How to Solve the Maximize Distance to Closest Person Challenge in Java

October 30, 2020

The challenge You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the i<sup>th</sup> seat, and seats[i] = 0 represents that the i<sup>th</sup> seat is empty (0-indexed).


Read More

How to Get Character from ASCII Value in Java

October 29, 2020

The challenge Write a function which takes a number and returns the corresponding ASCII char for that value.


Read More

Finding a Needle in a Haystack in Java

October 28, 2020

The challenge Can you find the needle in the haystack?


Read More

How to Solve the Champagne Tower in Java

October 27, 2020

The challenge We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.


Read More

How to Solve the 132 Pattern in Java

October 26, 2020

The challenge Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].


Read More

How to Replace all Vowels in a String in Java

October 25, 2020

The challenge Replace all vowel to exclamation mark in the sentence.


Read More

How to Get the N-th Power in Java

October 24, 2020

The challenge You are given an array with positive numbers and a number N.


Read More

How to Count the Minimum Depth of a Binary Tree in Java

October 23, 2020

The challenge Given a binary tree, find its minimum depth.


Read More