Skip to content

Instantly share code, notes, and snippets.

Avatar

Khurrum Nasim knasim

  • let the machine write it
  • washington dc
View GitHub Profile
@knasim
knasim / gist:62f2bd1755739cb687f911d9ea801fa9
Last active Jul 3, 2018
Spiralize a 2D square matrix i.e nxn matrix
View gist:62f2bd1755739cb687f911d9ea801fa9
public class SpiralMatrix {
/*
Problem:
Spiralize a 2D square matrix i.e (nxn)
input: 123
456
789
View gist:e1200a7883cc2118ad417142a3cf53d5
this is my gist
this is my gist
this is my gist
View gist:09069e2a984a2e3f1598700e2df572a5

Java 8: java.util.Optional

private abstract Optional<String> methodThatReturnsOptionalString();

private void useOptionalString() {
	Optional<String> myOptionalString = methodThatReturnsOptionalString();
	if (myOptionalString.isPresent()) {
		String myUnboxedString = myOptionalString.get();
		System.out.format("Optional string had value: %s\n", myUnboxedString);

} else {