Current streak:
0 days
Longest streak:
14 days
Less
More
sort(nums.begin() , nums.end());
int i=0;
int j= nums.size()-1;
while(i!=j){
int sum = nums[i] + nums[j];
if(sum==target){
return "YES";
// break;
}
else{
sum < target ? i++ : j--;
}
}
return "NO";
Though the code is correct and test cases are passing while submitting the code it shows error . Is it happening with everyone?
My code:
void bubbleSort(int arr[], int n)
{
//write your code here
if(n==0) return;
for(int i=0;i<n-1; i++){
if(arr[i] > arr[i+1]){
swap(arr[i] , arr[i+1]);
}
}
bubbleSort(arr , n-1);
}