NOTATRI - Not a Triangle - SPOJ Solution C++

  Problem Link : NOTATRI 


👉 Hint : Sort input array and solve using binary search

 


✅ C++ Solution :

 
#include
using namespace std;
#define ll long long int
ll fact(int n)
{
    if ((n==0)|| (n==1))
        return 1;
    return n*fact(n-1);
}
ll comb(int n)
{
    return fact(n)/(fact(n-3)*6);
}
int main()
{
    int j,i,n;
    while(1)
    {
        ll ans=0;
        cin>>n;
        if(n==0)
            break;
        ll arr[n];
        vector >v;
        for(i=0;i>arr[i];
        sort(arr,arr+n);
        for(i=0;i

 

Thank you for your patience reading. If you enjoyed this post, I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Whatsapp or Facebook. 

😇Happy Learning!!