Distribute Candies

LeetCode題目: 575. Distribute Candies My solution: /** * @param {number[]} candyType * @return {number} */ let distributeCandies = candyType => { c...

Reshape the Matrix

LeetCode題目: 566. Reshape the Matrix My solution: /** * @param {number[][]} mat * @param {number} r * @param {number} c * @return {number[][]} */ let m...

Reverse Words in a String III

LeetCode題目: 557. Reverse Words in a String III My solution: /** * @param {string} s * @return {string} */ let reverseWords = s => s.split(' &#x2...

Detect Capital

LeetCode題目: 520. Detect Capital My solution: /** * @param {string} word * @return {boolean} */ let detectCapitalUse = word => { if(word === word....

Fibonacci Number

LeetCode題目: 509. Fibonacci Number My solution: /** * @param {number} n * @return {number} */ let fib = n => { if(n === 1 || n === 0) return n; ...