Skip to content

Instantly share code, notes, and snippets.

View knasim's full-sized avatar

Khurrum Nasim knasim

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

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 {