{{ message }}

Instantly share code, notes, and snippets.

# Jiahao Liu Liu jiahaoliuliu

Created Nov 17, 2018
SImple algorithm to find the number of islands in a matrix
View NumberOfIslands.java
 /** * Given a matrix of 0 and 1, where 0 represents water and 1 represent land. * Two pieces of land are connected if they are touching each other(vertical, horizontal or diagonal) * Please write a method that counts the number of islands. * * Here is an example : * 0 (1 1) 0 0 0 [1] * 0 (1) 0 0 [1 1] 0 * 0 (1 1) 0 0 [1] 0 * 0 0 0 0 0 0 0
Created Nov 12, 2018
View SimpleRxJava2Test.java
 package com.emirates; import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.hasItems; import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; import io.reactivex.Observable; import io.reactivex.observers.TestObserver;
Created Oct 26, 2018
Permutation using recursive on Java
View recursivePermutations.java
 package com.jiahaoliuliu.tools; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; public class Permutations { private List> generatePermutations(List seedLists) { return generatePermutations(new ArrayList<>(), seedLists);
Created Nov 13, 2015
A simple solution to split a list into two and the sum of the elements are similar
View ListSplitterSum
 package com.jiahaoliuilu.testing.toptal; import java.util.ArrayList; import java.util.Collections; import java.util.List; public class Test1 { // Testing array private static int[] array = {5, 5, 1, 7, 2, 3, 5};
Last active Aug 29, 2015
Sudoku checker. Simple checker for Sudoku with complexity O(N^2)
View SudokuChecker.java
 package com.jiahaoliuliu.sudokuchecker; import java.util.ArrayList; import java.util.HashSet; import java.util.Set; /** * A class to check the if the content of a Sudoku is correct or not. The complexity of the algorithm * has been kept to O(N^2), instead of O(N^3) for the cube check. *
Last active Aug 29, 2015 — forked from casidiablo/SimpleCursorLoader.java