Java solutions for common coding questions