マガジンのカバー画像

LeetCodeまとめ

6
自分の回答を説明してます。
運営しているクリエイター

#LeetCode

LeetCode : 763. Partition Labels(11/29:update)

1回目function partitionLabels(s: string): number[] { let list: Map<string, { start: number, last: number }> = new Map<string, { start: number, last: number }>(); const len: number = s.length; f

もっとみる

LeetCode : Market Analysis I

1回目# Write your MySQL query statement belowselect u.user_id as buyer_id,u.join_date as join_date,count(o.buyer_id) as orders_in_2019from Users as uleft join Orders as o on o.buyer_id = u.user_id

もっとみる

LeetCode : Length of Last Word

1回目function lengthOfLastWord(s: string): number { const x: string[] = s.split(" "); const y: string[] = x.filter(z => z !== ""); return y[y.length - 1].length;};

マイベスト。66ms。

Input: s = " fl

もっとみる

LeetCode : Final Value of Variable After Performing Operations

1回目function finalValueAfterOperations(operations: string[]): number { let x: number = 0; operations.forEach((op: string) => { if (op === "X++" || op === "++X") { x += 1;

もっとみる

LeetCode : Build Array from Permutation

1回目function buildArray(nums: number[]): number[] { let result: number[] = []; for (let i: number = 0; i < nums.length; i++) { result[i] = nums[nums[i]]; } return result;};

問題文をそのままコードにし

もっとみる

LeetCode : Tow Sum

1回目function twoSum(nums: number[], target: number): number[] { let ret: number[] = []; nums.forEach((x: number, i: number) => { nums.forEach((y: number, j: number) => { if (j =

もっとみる