Skip to content

Commit

Permalink
[LeetCode] Add January 27.
Browse files Browse the repository at this point in the history
  • Loading branch information
pin3da authored Jan 27, 2021
1 parent 3344a4a commit ee47738
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions solved/LeetCode/Challenges/2020/January/27.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution {
fun concatenatedBinary(n: Int): Int {
var ans = 0
val mod = 1000_000_007
for (i in 1..n) {
val binary = Integer.toBinaryString(i)
for (bit in binary) {
ans = (ans * 2) % mod
if (bit == '1') {
ans = (ans + 1) % mod
}
}
}
return ans
}
}

1 comment on commit ee47738

@carolinajimenez26
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.