Solution to problems on arrays