Java algorithms

I am sharing the code I did to solve code challenges and technical interview preparations as well as useful new techniques. Maybe you can enjoy the unit test in this repo in src directory

Set up for MacOS

Clone this repository in your prefered workspace

Run IntelliJ and open this project with IntelliJ. In IntelliJ select the name of the project algorithms and click on File / Project structure Menu and you will see some configurations.

Configure them as following:

Project Modules Libraries

Gradle installation

# brew install gradle

Talking about algorithms that I have learned:





  • How to add a number for an array without java.lang.String. For example:
int[] intArray = {1, 0, 0, 4};
//The challenge asks to add 1 to intArray and if you print the array the results as following:  
1, 
0, 
0, 
5


Unit tests framework comparation

In this scenario of a wrong number in the unit test and I am taking advantage to show you to compare how each framework show the evaluation or assert in the console.

First we can see how Hamcrest show in a console: Console As you can see here we have on line to describe what was expected and other below for your comparation of the array.

Second we can see how Junit 5 show in a console: Console As you can see here we have expected and actual array, in the same line. And you have to manage to compare the int array in a different way.

In the last example we can see how AssertJ show in a console: Console You can compare the expected with the actual int array one line above other aligned by each number. Another interesting point is related to the way AssertJ enable us to compare in a explicit and verbose way to clarify what you are doing when using .isEqualTo(...). There are many examples of methods for evaluation and assert to be used.

Maybe this Tutorial about AssertJ makes sense for you.

Finding a missing number in a progressive arithmetic

I am providing Algorithm to find a missing number in a sequence. Take a look at FindingTheMissingNumberInTheSequence.java