Posts

Leetcode 78 : Subsets

Subsets on the Stack Recursion · Backtracking · The call stack Subsets on the Stack Every subset of a set is one path through a tree of yes/no decisions. Watch the machine walk that tree — pushing a frame each time it goes deeper, popping one each time it comes back. Input set { 1, 2, 3 } → expect 2³ = 8 subsets The machine Step through it The tree shows where you are. The stack shows how you got there — one frame per unfinished call, each one paused mid-line, waiting for the call above it to finish. start Press Play, or step with the arrow keys. Code · current line 1 void findSubsets( int index) { 2 if (index == nums.length) { 3 results.add( new ArrayList<>(current)); 4 return ; 5 } 6 current.add(nums[index]); // TAKE 7 findSubsets(index + 1); // explore 8 current.remove(current.size()-1); // UN-TA...

Download binaries like pom, jar and dependencies from an artifactory and save it in a local directory | Migrate dependencies from one repository to another | Using maven , pom.xml

Structure of pom.xml https://github.com/shankhadeepk/dependencydownloader/blob/main/pom.xml Then go the location where the project is and run command mvn clean install A folder will be created at the location ([project]/target/[location as shown below]) which is given by following properties in the pom.xml <outputDirectory>${project.build.directory}/lib</outputDirectory>

Enable newly installed java for your favorite browsers

For Mozilla 64 bit Jdk sudo ln -s /usr/lib/jvm/jdk1.8.0/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins 32 bit jdk sudo ln -s /usr/lib/jvm/jdk1.8.0/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins For Chrome 64 bit jdk sudo mkdir /opt/google/chrome/plugins sudo ln -s /usr/lib/jvm/jdk1.8.0/jre/lib/amd64/libnpjp2.so /opt/google/chrome/plugins 32 bit jdk sudo mkdir /opt/google/chrome/plugins sudo ln -s /usr/lib/jvm/jdk1.8.0/jre/lib/i386/libnpjp2.so /opt/google/chrome/plugins

Install any oracle java in your Ubuntu 15.10

Step 1: Download the preferable jdk from oracle web site. Here we will use             jdk version as jdk-8-linux-x64 Step 2: Keep the tar.gz file in a folder of your choice in /home/ directory. Step 3: Extract the tar.gz file                       tar -xvzf jdk-8-linux-x64.tar.gz Step 4: Create JVM folder in /usr/lib folder like:                         sudo mkdir /usr/lib/jvm Step 5: Move the extracted jdk to the above location like :             sudo mv jdk1.8.0 /usr/lib/jvm/jdk1.8.0 Step 6: Install new java sources in system like:           sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0/bin/javac 1           sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0/bin/java 1      ...

Change the Heap Size and Stack size in Java's JVM

In order to change the heap size, there are two parameters that need to be updated : -Xms512m -Xmx1024m These parameters can be found in eclipse.ini file in the eclipse folder. To change the stack size, there is a parameter that need to be updated : -Xss512m

Code for reversing a string in Java

package com.reverse; public class ReverseWords { public static String reverseTheString(String input) { if(input.length()>1) return input.substring(input.length()-1, input.length()) + reverseTheString(input.substring(0,input.length()-1)); else { return input.substring(0, 1); } } public static void main(String args[]) { System.out.println(reverseTheString("hello")); } }

Enable java plugin for firefox in Ubuntu

The java run time environment can be downloaded from the java site. Run the command for make the plugin work for Firefox in Ubuntu $cd /usr/lib/mozilla/plugins $sudo ln -s /usr/lib/jvm/jre1.6.0_30/plugin/i386/ns7/libjavaplugin_oji.so