Learning to write efficient and effective algorithm.

 Hi, I am Aman Kumar pursuing BCA II. I have decided to write what i learn daily.

I request you to please go through this program and feel free to write me if you have any advice/suggestions for me at 2022amankumar@gmail.com 


I recently solved a question on CodeChef with Problem Code:ALEXNUMB. 

My designed solution was:


#include <iostream>

#include <set>

using namespace std;

typedef unsigned long long LL;

int main() {

    LL T,n,m,a,result;

    cin>>T;

    while(T--)

    {

        cin>>n;

        set<LL>temp;

        for(int i=0;i<n;i++)

        {

            cin>>a;

            temp.insert(a);

        }

        m=temp.size();

        result=((m-1)*m)/2; //to find total no pairs,i used set theory

        cout<<result<<endl;

    }

return 0;

}

My solution was correct and hence got accepted.
Output:


Comments

  1. Hey there,
    I am Thomas Shelby and I am from New Jersy,USA. I am glad to see your hard work and your intrest toward it. I will be very glad if you work with me as I need a assistant and you are aware what's happening in the world many staff of our company left fue to this panademic. I really hope you will not decline this offer as also it will help you to guide you in field of coding. Further things I will talk when you will free and post a prompt reply to me....

    ReplyDelete

Post a Comment