All Questions
Tagged with bitwise programming-challenge
24 questions
2
votes
1
answer
1k
views
LeetCode: Sum of Two Integers C#
https://leetcode.com/problems/sum-of-two-integers/
Calculate the sum of two integers a and b, but you are not allowed to
use the operator + and -.
Example 1:
Input: a = 1, b = 2 Output: ...
4
votes
2
answers
389
views
Find out whether number is of Power of Two
The task
is taken from leetcode
Given an integer, write a function to determine if it is a power of
two.
Example 1:
Input: 1
Output: true
Explanation: 20 = 1
Example 2:
...
3
votes
1
answer
483
views
Division without using division, multiplication, or modulus operators
The task
Implement division of two positive integers without using the
division, multiplication, or modulus operators. Return the quotient as
an integer, ignoring the remainder.
My solution
<...
4
votes
1
answer
7k
views
Hamming Distance in Python
I was solving this Leetcode challenge about Hamming Distance. Would love feedback on my syntax and code style. Here's the challenge description:
The Hamming distance between two integers is the ...
4
votes
5
answers
6k
views
Largest binary gap
I took a task from Codility to find longest sequence of zeros in binary representation of an integer.
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The ...
3
votes
1
answer
7k
views
Hackerrank "Strings: Making Anagrams" Javascript Solution
This is the original problem :
Input Format
The first line contains a single string, a. The second line contains a
single string, b.
Constraints
1<= |a|,|b| <= 10^4
It ...
3
votes
2
answers
1k
views
Codility “PermMissingElem” Solution
This is my solution to the PermMissingElem problem, I wonder what can be improved? Expected worst case time complexity is O(N), but the performance test shows that it's O(N) or O(N * log(N)), which I ...
6
votes
2
answers
5k
views
Codility binary gap solution
This is how I solved the binary gap problem: Find longest sequence of zeros, bounded by ones, in binary representation of an integer
I wonder how does it fare against solutions such as ones appeared ...
2
votes
0
answers
3k
views
Hackerrank: Max Score
Problem statement
Consider an n-element sequence of integers, A = {a0, a0, ..., an-1}. We want to perform \$n\$ operations on \$A\$, where each operation is defined by the following sequence of ...
11
votes
4
answers
27k
views
Find the binary gap of a number N
For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of ...
4
votes
1
answer
2k
views
Hackerrank Sum vs XoR
I'm in the process of improving my coding style and performance hence I decided to delve into bit manipulation on Hackerrank. I thought the question was straight forward but on large input, my ...
8
votes
2
answers
3k
views
Maximize result of bitwise AND
This was the problem from "30 Days of Code" on Hackerrank:
Given set \$S = \lbrace{1,2,3,\dots,N}\rbrace\$, find two integers \$A\$ and \$B\$ (where \$A \lt B\$), from set \$S\$ such that the value ...
12
votes
3
answers
6k
views
Codility binary gap solution using regex
Below is the code I implemented to solve the binary gap problem:
Find longest sequence of zeros, bounded by ones, in binary representation of an integer.
However, it seems to be different from the ...
6
votes
3
answers
10k
views
Printing longest sequence of zeroes
I am doing a coding exercise in codility and I came across this question:
A binary gap within a positive integer N is any maximal sequence of
consecutive zeros that is surrounded by ones at both ...
3
votes
1
answer
96
views
Testing for divisibility of numbers - follow-up
(Here is the follow up question)
I had another go at trying to speed up my program described in my previous question.
JS1's answer was particulary helpful and now my code is only about 20% slower ...