-
Notifications
You must be signed in to change notification settings - Fork 1
/
getLucky.js
38 lines (32 loc) · 898 Bytes
/
getLucky.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/**
* @param {string} s
* @param {number} k
* @return {number}
*/
var getLucky = function(s, k) {
let num = '';
for (let i = 0; i < s.length; i++) {
num += (s.charCodeAt(i) - 96).toString();
}
for (let i = 0; i < k; i++) {
let sum = 0;
for (let j = 0; j < num.length; j++) {
sum += parseInt(num[j]);
}
num = sum.toString();
}
return parseInt(num);
};
console.log(getLucky("iiii", 1))
// Min Deletions to Make Frequency of Each Letter Unique
// Min Swaps to Make Palindrome
// Min Steps to Make Piles Equal Height
// Largest K such that both K and -K exist in array
// Max Length of a Concatenated String with Unique Characters
// Unique Integers That Sum Up To 0
// Partition array into N subsets with balanced sum
// Jump Game [Experienced]
// Meeting Rooms II
// Count Visible Nodes in Binary Tree
// Largest Alphabetic Character
// 161928157