Page 1 of 1

You are given a binary string S consisting of O's and 1's. You have to tell whether it is possible to split the string i

Posted: Mon May 09, 2022 7:14 am
by answerhappygod
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 1
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 1 (222.75 KiB) Viewed 147 times
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 2
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 2 (252.65 KiB) Viewed 147 times
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 3
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 3 (239.52 KiB) Viewed 147 times
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 4
You Are Given A Binary String S Consisting Of O S And 1 S You Have To Tell Whether It Is Possible To Split The String I 4 (127.01 KiB) Viewed 147 times
I want code in Javascript node .js v 16.4 version only
You are given a binary string S consisting of O's and 1's. You have to tell whether it is possible to split the string into exactly K substrings such that each character belongs to exactly one substring and the decimal value of each substring is the same. Task Determine whether it is possible to split the string S into exactly K substrings such that each character belongs to exactly one substring and the decimal value of each substring is the same. Example Assumptions S = 010100101 • K = 2 Approach o S can be split into 0101 and 00101. Both substrings have a decimal value of 5. • Thus, the answer is YES. 11 Function doccrintion
value of 5. • Thus, the answer is YES. Function description Complete the function Split_the_String. This function takes the following 2 parameters and returns the required answer: • S. Represents the string S • K. Represents the integer K (Number of substrings S has to be split into) Input format Note: This is the input format that you must use to provide custom input (available above the Compile and Test button). • The first line contains string S. АР • The second line contains integer K. Output format If it is possible to split the string then print "YES" otherwise print "NO". 1 Constraints
If it is possible to split the string then print "YES" otherwise print "NO". Constraints 15 S1 < 105 1<K S Code Snippets(also called starter code/boilerplate code) This question has code snippets for C, CPP, Java, and Python. Sample input E Sample output 1100110110 YES 3 ho 4 10
Save JavaScript (Node.js v16.4) 5 OD 1 /* 2 // Sample code to perform I/O: 3 4 process. stdin.resume(); 5 process. stdin.setEncoding("utf-8"); 6 var stdin_input = ""; 7 process.stdin.on("data", function (input) { 9 stdin_input += input; 10 }); 11 I 12 process.stdin.on("end", function () { main(stdin_input); 8 // Reading input from 13 14 15 16 17 function main(input) { process.stdout.write("Hi, } + input + ". \n"); // Writing output to STDO 18 19 20 // Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail