Time limit exceeded error!

hi i am facing the error of tle ; is there any changes which i can do?
problem : array target sum triplet

#include
#include<bits/stdc++.h>
using namespace std;

int main() {

short int n ,i , j ,k ;
int no;
cin>>n;
int a[1000];
for( i =0 ; i< n ;i++)
 cin>>a[i];
 
 sort(a, a+n);
 
cin>>no;
for( i=0 ;i<n-2; i++)
 {  
     for( j=i+1 ; j< n-1 ;j++)
      {
          for( k =j+1; k<n ; k++)
           {
               if(a[i]+a[j]+a[k]==no)
			   {
               	cout<<a[i]<<", "<<a[j]<<" and "<<a[k]<<endl;
			   	break;
			   }
           }
		
      }
 }

}

hi @aggarwal.naman21
U have used a brute force approach whose complexity is O(N^3)… hence it give TLE… u will have to optimize ur approach which can be done using 2 pointer method…
Refer this code -->

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.