Sherlock and Array HackerRank Solution

preview_player
Показать описание
Sherlock and Array hackerrank problem can be solved easily by deriving a linear equation. The complexity of Sherlock and Array hackerrank solution is O(n) which is a part of Practice | Algorithms | Search | Sherlock and array hackerrank challenge.

This video explains how to solve sherlock and array hackerrank problem in java. Here I have explained the algorithm to solve hackerrank sherlock and array problem separately and then implemented the same algorithm using java.

For simplicity, I have divided this hackerrank tutorial into 3 parts.
[00:00] Understanding the problem statement.
[03:57] Building the logic to solve the problem.
[12:52] Coding the logic using java (you can use your own preferred programming language).

✚ Join our community ►

📖 Resources ►

✅ Recommended playlists ►

🖐 Let’s Connect ►

#JAVAAID #HackerRankSolutions #HackerRankTutorials #sherlockandarray #seach #HackerRank #JavaAidTutorials #Programming #DataStructures #algorithms #coding #competitiveprogramming #JavaAidTutorials #Java #codinginterview #problemsolving #KanahaiyaGupta #hackerrankchallenges
Рекомендации по теме
Комментарии
Автор

Hello Coding Lover,
If you have any doubts or any better approach to solve this problem, let me know in comments.

JavaAidTutorials
Автор

Tq Bro, U explained in a very simpler way

prajwal
Автор

अति उत्तम! Better than the official editiorial.

md-ayaz
Автор

Thank you so much! This has given me a new way to look at these types of questions!

alokesh
Автор

Sir the explanation was awesome you explained it mathematically it was very cool to go through your solutions.
Thanks for your solutions.

amanrai
Автор

Thanks for this very explicit solution!

abdullahbezir
Автор

Bro how did you think and get the algorithm like this. Pls share some tips, it will useful to your followers. Wonderful and I'm impressed on your thinking. Super bro

balakumaran
Автор

Please Bring Videos Next On HackerEarth Question And Reply This Soon.

jatinbhardwaj
Автор

This is really cool and easy to understand. Nice way to implement :)

vijaykumarb
Автор

Your video thumbnail is awesome dude.. :)

codingfreek
Автор

India is my country, Music's good

vijayjangid
Автор

Bhai how to improve logical thinking 🙏🙏plz sir give suggestions

Coding_Student
Автор

Hey what's the background music at the beginning of the video?

xinjing
Автор

can you tell me how you reach this algorithm?? what idea you follow ??

engsalahmahmoud
Автор

Can u pls explain Sherlock and anagram problem in hackerank

ankurgupta
Автор

import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.regex.*;
import java.util.stream.*;
import static
import static

class Result {

/*
* Complete the 'balancedSums' function below.
*
* The function is expected to return a STRING.
* The function accepts INTEGER_ARRAY arr as parameter.
*/

public static String balancedSums(List<Integer> arr) {
// Write your code here
int x=0;
int sum=0;
for(int a:arr){
sum+=a;

}
for(int y:arr){
if(2*x==sum-y){
return "YES";
}

x=x+y;


}
return "NO";

}

public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new
BufferedWriter bufferedWriter = new BufferedWriter(new

int T =

IntStream.range(0, T).forEach(TItr -> {
try {
int n =

List<Integer> arr = Stream.of(bufferedReader.readLine().replaceAll("\\s+$", "").split(" "))
.map(Integer::parseInt)
.collect(toList());

String result = Result.balancedSums(arr);

bufferedWriter.write(result);
bufferedWriter.newLine();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});

bufferedReader.close();
bufferedWriter.close();
}
}

shraddhasaxena