• Courses
  • Tutorials
  • DSA
  • Data Science
  • Web Tech
November 03, 2024 |290 Views

PROBLEM OF THE DAY : 02/11/2024 | Kth distance

Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Shivam Sharma We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but also build up problem-solving skills.

Given an unsorted array arr. Also given the number k which is smaller than the size of array. Find if the array contains duplicates within k distance.

Examples:

Input: arr[] = [1, 2, 3, 4, 1, 2, 3, 4] and k = 3
Output: false
Explanation: All duplicates are more than k distance away.
 

Give the problem a try before going through the video. All the best!!!
Problem Link: https://practice.geeksforgeeks.org/problems/kth-distance3757/1