Skip to content

Commit 60f1489

Browse files
committed
Add solution #1256
1 parent 116ad1a commit 60f1489

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,7 @@
11651165
1253|[Reconstruct a 2-Row Binary Matrix](./solutions/1253-reconstruct-a-2-row-binary-matrix.js)|Medium|
11661166
1254|[Number of Closed Islands](./solutions/1254-number-of-closed-islands.js)|Medium|
11671167
1255|[Maximum Score Words Formed by Letters](./solutions/1255-maximum-score-words-formed-by-letters.js)|Hard|
1168+
1256|[Encode Number](./solutions/1256-encode-number.js)|Medium|
11681169
1260|[Shift 2D Grid](./solutions/1260-shift-2d-grid.js)|Easy|
11691170
1261|[Find Elements in a Contaminated Binary Tree](./solutions/1261-find-elements-in-a-contaminated-binary-tree.js)|Medium|
11701171
1262|[Greatest Sum Divisible by Three](./solutions/1262-greatest-sum-divisible-by-three.js)|Medium|

solutions/1256-encode-number.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* 1256. Encode Number
3+
* https://leetcode.com/problems/encode-number/
4+
* Difficulty: Medium
5+
*
6+
* Given a non-negative integer num, Return its encoding string.
7+
*
8+
* The encoding is done by converting the integer to a string using a secret function that
9+
* you should deduce from the following table:
10+
*/
11+
12+
/**
13+
* @param {number} num
14+
* @return {string}
15+
*/
16+
var encode = function(num) {
17+
return (num + 1).toString(2).slice(1);
18+
};

0 commit comments

Comments
 (0)