Skip to main content

Posts

Showing posts from 2019

Data Structures - Arrays

1) Move all Negative numbers to the beginning of the Array Move all the Negative elements to the beginning of the given Array. The solution is to take two pointers slowPointer, fastPointer. SlowPointer starting at position 0 and fastPointer starting at position 1. The required condition is to have all negatives at the beginning, so keep slowPointer at beginning as long as the element is positive and move it only incase the element is negative. For the fastPointer move it as long as the number is negative and stop when the number is positive and do a comparison with the slowPointer, if slowPointer is positive and fastPointer is negative swap the elements at both the positions and move both the pointers. When the Iteration is completed all the negative elements get moved to the beginning and all the positive elements to the end. Rotate an Image represented as a 2D matrix in place To rotate an image represented as a 2D Matrix in place we first need to transpose the matrix(move row

Java Productivity tools

Here are the list of Java Productivity tools that help in simplifying the daily life of a developer. Eclipse as an IDE simplifies the development life cycle which has a lots of plugins to support different programming languages and frameworks. Some of useful Eclipse plugins are - Sonarlint that helps to do static code analysis and give suggestions as we go along the development life cycle. JDGUI - Is the Eclipse Plugin that supports the decompilation of the Java application within eclipse, this is very handy when debugging and need to look at the out of the box code from a framework/library. JUnit is the unit testing framework that supports Unit Testing of Java Applications. Mockito is the framework that supports the Mock Unit Testing of the Java Application.

Install Open JDK 10 on Mac

Downloading and Installing Open JDK 10 is easy, and does not need to uninstall the existing version of the JDK. Here are the steps to install Open JDK 10 1) Download Open JDK 10 from https://download.java.net/java/GA/jdk10/10.0.2/19aef61b38124481863b1413dce1855f/13/openjdk-10.0.2_osx-x64_bin.tar.gz 2) Go to the downloaded file's parent folder, and extract the JDK using $tar -xvf openjdk-10.0.2_osx-x64_bin.tar.gz     3) Copy the extracted  JDK to the Mac JDK installations folder $sudo cp -R  ~/Downloads/jdk-10.0.2.jdk  /Library/Java/JavaVirtualMachines/ 4) Update, and export JAVA_HOME, PATH in the ~/.bash_profile (or) ~/.bashrc file. JAVA_HOME=" /Library/Java/JavaVirtualMachines/jdk-10.0.2.jdk/Contents/Home " PATH="$PATH:${JAVA_HOME}/bin" export JAVA_HOME  PATH  5) Source the bash_profile/bashrc file to detect the changes. $ source ~/.bash_profile 6) Open a new Terminal and verify open JDK installation for javac, and java,