About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

বৃহস্পতিবার, ৫ নভেম্বর, ২০১৫

SPOJ Solution :AMR10G - Christmas Play

#include <bits/stdc++.h>
#define pi acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int>vc;
vector<vc>graph;
int xr[]= {-1,-1,-1,0,0,1,1,1};
int yc[]= {-1,0,1,-1,1,-1,0,1};


int main()
{
    //freopen("input.txt","r",stdin);

    int test,n,k,ary[20004];
    scanf("%d",&test);
   // map<int,int>mp;
    while(test--)//using two pointer
    {
        scanf("%d %d",&n,&k);
        for(int i=0;i<n;i++) scanf("%d",&ary[i]);
        sort(ary,ary+n);
        int i=0,j=k-1;
        int Min=INT_MAX;
        while(i<n&&j<n)
        {
             Min=min(Min,ary[j]-ary[i]);
             i++;j++;
        }
        cout<<Min<<endl;
    }
    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন