Questions tagged [binary-string]
21 questions
5
votes
4 answers
Reduce binary string to an empty string by removing subsequences with alternative characters
This was a question asked in the coding round for NASDAQ internship.
Program description:
The program takes a binary string as input. We have to successively remove sub-sequences having all characters alternating, till the string is empty. The task…

Bichu Ben
- 75
- 6
5
votes
2 answers
How do I convert an array of integers to binary?
for (int i = 0; i < n; i++) {
arr[i] = scanner.nextInt();
}
String[] bin = new String[n];
for (int i = 0; i < n; i++) {
bin[i] = Integer.toBinaryString(arr[i]);
}
The above code will convert the the whole array of integers into an array of…

Rashid Raza
- 53
- 1
- 8
2
votes
3 answers
Long.parseLong throws NumberFormatException for binary string
we have byte string s = "1111000000000111000000000001000000000010010000000000000000000000"(this value equal -1150951111012646912), if we use Long.parseLong(s, 2), we got "
java.lang.NumberFormatException: For input…

za1ra1za1
- 21
- 1
1
vote
2 answers
IterTools product in Julia
I would like to produce lists of 0 and 1 in Julia using IterTools.
For example, in Python I can do:
for bits in itertools.product([0, 1], repeat=5):
print(bits)
This will produce
(0, 0, 0, 0, 0)
(0, 0, 0, 0, 1)
(0, 0, 0, 1, 0)
(0, 0, 0, 1,…

MonteNero
- 143
- 1
- 6
1
vote
1 answer
Given a string which contains only ones and zeros, return the number of substrings with ones more than zeros
Suppose that S is a string containing only 0 and 1. I would like to count the number of not null substrings of S in which the number of 0s is less than the number of 1s.
Using brute-force method given below we can have an algorithm that solves this…

Adeeb HS
- 139
- 7
1
vote
1 answer
search for a binary string in binary file with python
Hi all am searching for a binary string in binary file using the python
my binary file looks like a as follows.
I want to find the bold text below.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00…

Madhu
- 15
- 8
1
vote
1 answer
Python: Given 2 binary strings s and t, print minimum number of adjacent swaps to convert s to t
For example if s = "1000000111" and t = "0111000001" the output should be 11. Below is my solution but it gives a time limit exceeded error so I am looking for a faster method. The length of string is less than 10^6.
T = int(input())
for _ in…

Archit
- 37
- 6
0
votes
0 answers
Generate all binary strings/patterns of a given length which are unique even when rotated
I need an algorithm that behaves like this:
In: 1
Out: 0, 1
In: 2
Out: 00, 01/10, 11
In: 3
Out: 000, 001/010/100, 011/110/101, 111
In: 4
Out: 0000, 0001/0010/0100/1000, 0011/0110/1100/1001, 0101/1010, 0111/1110/1101/1011, 1111
of the separated using…
0
votes
0 answers
How do I unpack big-endian data from a binary string in Javascript?
I need solution relavant answer of the function of php unpack("N*",$data);
return An array

Tazul Islam
- 1
- 1
0
votes
1 answer
does casting to a str decode a bitwise string
observe the following
signature = rsa.sign(str(message), private_key, 'SHA-1')
see how message is being casti to a str
would that decode a bit wise string?
why I ask.
the code snippet above is being used by the aws boto library which is using the…

Christopher Jakob
- 453
- 3
- 21
0
votes
1 answer
Vlang - convert int, u32, u64, f32, f64, etc. to array of bytes in LittleEndian format
I have various variables of different numeric datatypes(int,u32,u64,f32,f64, etc) and want to convert them to an array of bytes.
For example:
a := 120 // int datatype
a_bytes = some_function(a) // What to do here?
println(a_bytes)
// [ x, `\0`,…

impopularGuy
- 805
- 9
- 15
0
votes
1 answer
How can I upload a file that is a binary string to Amazon S3 using a signed URL and JavaScript?
I am not having any trouble getting the signed URL, and the file is actually getting uploaded to S3, but when I download the file I can't open it. I have tried PDF and image files.
I get the file like this, where 'e' is the file upload event from…

Craig Nakamoto
- 2,075
- 2
- 18
- 19
0
votes
1 answer
parameter substitution in a binary string in python
Python 3
I want to send a binary string over a socket. I am using
socket.send(b"Hello from {0}",client_id)
however I find the it is not properly substitution clientid.
what am I doing wrong? I do I accomplish this in a binary string

liv2hak
- 14,472
- 53
- 157
- 270
0
votes
1 answer
Check boxes values returned and added to string
I am trying to take a row of checkboxes in a table and for each TD in the table it needs to check if the checkbox is ticked, is so it is a 1 and else its 0.
I need a for loop where I will be able to loop over each td, determin if it is checked and…

Muckle Developer
- 7
- 3
0
votes
0 answers
How do I solve the below problem without reverse engineering the sample test cases
I solved the problem below Binary String Problem in Hackerearth the problem which says "Given four integers x,y,a and b. Determine if there exists a binary string having x 0's and y 1's such that the total number of sub-sequences equal to the…

served_raw
- 92
- 5