Update appNew update is available. Click here to update.
About
Chitkara University 2025
Java - Default language
My Stats
EXP gained
yellow-spark
1010
Level
5 (Champion)
Community stats
Discussions
0
Upvotes
0
Know more
18
Total problems solved
18
Easy
0
Moderate
0
Hard
0
Ninja
Jan Jan Feb Feb Mar Mar Apr Apr May May Jun Jun Jul Jul Aug Aug Sep Sep Oct Oct Nov Nov Dec Dec

Current streak:

0 days

Longest streak:

2 days

Less

More

Discussions
What is the problem in this??
Interview problems

import java.util.*;

public class Solution {

 

    public static String read(int n, int []book, int target){

        // Write your code here.

 

        Arrays.sort(book);

        int left = 0;

        int right = n-1;

 

        while(left<right)

        {

            if(book[left]+book[right] == target)

            {

                return "YES";

            }

            else if(book[left]+book[right] < target) left++;

            else right++;

        }

        return "NO";

    }

}

profile
Brijesh Gaba
Published On 12-Sep-2023
68 views
1 replies
0 upvotes