Skip to content

Instantly share code, notes, and snippets.

public class Solution {
public IList<int> FindClosestElements(int[] arr, int k, int x) {
int startIndex = binarySearch(arr, x);
int l=startIndex, r=startIndex;
for(int i=0;i<k-1;i++)
{
if (l == 0)
{
r = k;