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

রবিবার, ৩০ আগস্ট, ২০১৫

UVA:10954 - Add All

#include <bits/stdc++.h>
#define READ freopen ("input.txt","r",stdin)
#define nnn 20

using namespace std;

typedef long long ll;
typedef vector < int > vi;

int main()
{
    //READ;
    priority_queue<int>A;
    int n;
    while(scanf("%d",&n)==1&&n)
    {
        for(int i=0; i<n; i++)
        {
            int x;
            scanf("%d",&x);
            A.push(-x);
        }
        ll sum=0;
        while(A.size()>1)
        {
            int p=A.top();
            A.pop();
            int q=A.top();
            A.pop();
            sum+=(ll)(abs(p)+abs(q));
            A.push(-1*(abs(p)+abs(q)));
          //  cout<<A.top()<<endl;


        }
        cout<<sum<<endl;
        while(!A.empty()) A.pop();
    }



    return 0;
}

UVA :11995 - I Can Guess the Data Structure!

#include <bits/stdc++.h>
#define READ freopen ("input.txt","r",stdin)
#define nnn 20

using namespace std;

typedef long long ll;
typedef vector < int > vi;

int main()
{
    //READ;
    int n;
    stack<int>st;
    queue<int>Q;
    priority_queue<int>pq;
    while(~scanf("%d",&n))
    {
        while(!st.empty())st.pop();
        while(!Q.empty()) Q.pop();
        while(!pq.empty())pq.pop();
        bool stk=true;
        bool que=true;
        bool pque=true;
        bool ccc=true;
        for(int k=0; k<n; k++)
        {
            int op,value;
            scanf("%d %d",&op,&value);
            if(op==1)
            {
                st.push(value);
                Q.push(value);
                pq.push(value);
            }
            else
            {
                if(st.size()==0||Q.size()==0||pq.size()==0)
                {
                    ccc=false;
                    continue;
                }
                if(st.top()!=value) stk=false;
                else st.pop();
                if(Q.front()!=value) que=false;
                else Q.pop();
                if(pq.top()!=value) pque=false;
                else pq.pop();

            }

        }
        if(ccc==false )
        {
            puts("impossible");
            continue;
        }
        if(stk==false&&que==false&&pque==false) puts("impossible");
        else if(stk==true&&que==false&&pque==false) puts("stack");
        else  if(stk==false&&que==true&&pque==false) puts("queue");
        else  if(stk==false&&que==false&&pque==true) puts("priority queue");
        else puts("not sure");

    }


    return 0;
}

মঙ্গলবার, ১৮ আগস্ট, ২০১৫

UVA :11040 - Add bricks in the wall

#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
#define n 20

using namespace std;

typedef long long ll;
typedef vector<int>vi;
vector< vi >v;

int main()
{
   // READ;
   // freopen("output.txt","w",stdout);

    int test;
    sc(test);
    int ary[100];
    while(test--)
    {
        v.assign(n,vi());

        for(int i=0; i<5; i++)
        {
            for(int j=0; j<=i; j++)
            {
                int x;
                cin>>x;
                v[i].push_back(x);

            }

        }

        for(int i=0; i<5; i++)
        {
            if(i==0)
            {
                cout<<v[0][0]<<endl;
                continue;

            }
            int in=0;
            for(int j=0; j<v[i].size()-1; j++)
            {

                int a=v[i][j]+v[i][j+1];
                int b=(v[i-1][j]-a)/2;
                int ss=v[i][j]+b;
                int sd=v[i][j+1]+b;
                ary[in++]=b;
                cout<<ss<<" "<<sd;
                if(j<v[i].size()-2) cout<<" ";

            }
            cout<<endl;
            int p=0;
            for(int j=0; j<v[i].size(); j++)
            {
                cout<<v[i][j];
                if(j<v[i].size()-1) cout<<" ";
                if(p<in) cout<<ary[p];
                if(j<v[i].size()-1) cout<<" ";

                p++;
            }
            cout<<endl;




        }
    }


    return 0;
}

সোমবার, ১৭ আগস্ট, ২০১৫

UVA 514 - Rails

#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)
#define N 4

using namespace std;

typedef long long ll;
typedef vector<int>vc;

int main()
{
   // READ;
    int n;
    stack<int>st;
    queue<int>Q,R;
    while(~sc(n)&&n)
    {

        int t;
        while(cin>>t)
        {
            while(!Q.empty()) Q.pop();
            while(!st.empty()) st.pop();
            while(!R.empty()) R.pop();

            if(t==0)
            {
                printf("\n");
                break;

            }
            R.push(t);
            for(int i=2; i<=n; i++)
            {
                int x;
                cin>>x;
                R.push(x);

            }
            for(int i=1; i<=n; i++) Q.push(i);
            for(int i=0; i<n; i++)
            {
                int r=R.front();
              //  cout<<r<<endl;
                bool flag=false;
                if(st.size()!=0&&st.top()==r)
                {
                    flag=true;
                    st.pop();
                    R.pop();
                }
                else
                {
                    while(Q.size()>0)
                    {
                        if(Q.front()==r)
                        {
                            flag=true;
                            R.pop();
                            Q.pop();
                            break;

                        }
                        else
                        {
                            st.push(Q.front());
                            Q.pop();
                        }


                    }
                }
                if(flag==false) goto L;


            }
L:
         //cout<<st.size()<<" "<<Q.size()<<endl;
         if(st.size()==0&&Q.size()==0)   puts("Yes");
         else  puts("No");

        }




    }



    return 0;
}

মঙ্গলবার, ৪ আগস্ট, ২০১৫

UVA Solution :10684-The Jackpot

#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)

using namespace std;

typedef long long ll;
typedef vector<int>vc;


int main()
{
    // READ;
    int n,ary[10004];
    ll temp,sum;
    while(~sc(n)&&n!=0)
    {

        for(int i=0; i<n; i++) sc(ary[i]);
        sum=0;
        temp=0;
        for(int i=0; i<n; i++)
        {
            temp+=ary[i];

            sum=max(sum,temp);
            if(temp<0) temp=0;
        }

        sum>0?printf("The maximum winning streak is %lld.\n",sum):printf("Losing streak.\n");

    }

    return 0;
}

সোমবার, ৩ আগস্ট, ২০১৫

UVA solution :446 - Kibbles "n" Bits "n" Bits "n" Bits

#include <bits/stdc++.h>
#define sc(a) scanf("%d",&a)
#define scd(a,b) scanf("%d%d",&a,&b)
#define sct(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define READ freopen ("input.txt","r",stdin)

using namespace std;

typedef long long ll;
typedef vector<int>vc;

int Int(string ss)
{
    int su=0;
    for(int i=ss.size()-1,j=0; i>=0; i--,j++)
    {
        su+=(ss[i]-'0')*pow(2,j);

    }

    return su;
}

string Tobin(string s)
{
    string res;
    // cout<<s<<endl;
    string ss[]=
    {
        "0000", "0001","0010","0011","0100","0101","0110","0111","1000","1001","1010","1011","1100","1101","1110","1111"
    };
    for(int i=0; i<s.size(); i++)
    {
        int in;
        if(s[i]>='0'&&s[i]<='9') in=(s[i]-'0');
        else in=(int)(s[i]-55);
        //   cout<<in<<endl;
        res+=ss[in];

    }

    return res;


}


int main()
{
    // READ;
    int test;
    sc(test);
    while(test--)
    {
        string a,b,c;
        cin>>a>>b>>c;
        string x=Tobin(a);
        string y=Tobin(c);

        int cc=13-x.size();
        while(cc--) cout<<"0";
        cout<<x;
        cout<<" "<<b<<" ";
        int ccc=13-y.size();
        while(ccc--) cout<<"0";
        cout<<y<<" = ";

        int p=Int(x);
        int q=Int(y);
        //  cout<<p<<" "<<q<<endl;
        if(b[0]=='+') cout<<p+q<<endl;
        else cout<<p-q<<endl;



    }

    return 0;
}