7kyu Binary Addition
Posted tong24
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了7kyu Binary Addition相关的知识,希望对你有一定的参考价值。
题目:
Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.
The binary number returned should be a string.
答案:
// 1
function addBinary (a, b) {
return (a + b).toString(2);
}
// 2
function addBinary (a, b) {
return ((a + b) >>> 0).toString(2);
}
// 3
const addBinary = (a, b) => (a + b).toString(2);
以上是关于7kyu Binary Addition的主要内容,如果未能解决你的问题,请参考以下文章
7kyu (难度系数kyu阶段数值越大难度越低) 数组分组及求和
Codewars Solution:Get the Middle Character
Binary Tree和Binary Search Tree