How To Find Time And Space Complexity In Java