Java-Internship The problem was solved using two methods: Naive method (Time complexity O(n^2)) Efficient method (Time complexity O(n))