Open in app

Sign in

Write

Sign in

jojo lee
jojo lee

1 Follower

Home

About

Jul 26, 2021

[Leetcode]8 : String to Integer (atoi)

Link : https://leetcode.com/problems/string-to-integer-atoi/ Problem : Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++'s atoi function). The algorithm for myAtoi(string s) is as follows: 1. Read in and ignore any leading whitespace. 2. Check if the next character (if not already at the end…

Leetcode Solution

2 min read

[Leetcode]8 :  String to Integer (atoi)
[Leetcode]8 :  String to Integer (atoi)
Leetcode Solution

2 min read


Jul 23, 2021

[Leetcode]937 : Reorder Data in Log Files

Link : https://leetcode.com/problems/reorder-data-in-log-files/ Problem : You are given an array of logs. Each log is a space-delimited string of words, where the first word is the identifier. There are two types of logs: Letter-logs: All words (except the identifier) consist of lowercase English letters. Digit-logs: All words (except the identifier)…

Leetcode Solution

1 min read

[Leetcode]937 : Reorder Data in Log Files
[Leetcode]937 : Reorder Data in Log Files
Leetcode Solution

1 min read


Jul 22, 2021

[Leetcode]287 : Find the Duplicate Number

Link : https://leetcode.com/problems/find-the-duplicate-number/ Problem : Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive. There is only one repeated number in nums, return this repeated number. You must solve the problem without modifying the array nums and uses…

Leetcode Solution

1 min read

[Leetcode]287 : Find the Duplicate Number
[Leetcode]287 : Find the Duplicate Number
Leetcode Solution

1 min read


Jul 20, 2021

[Leetcode]128: Longest Consecutive Sequence

Link : https://leetcode.com/problems/longest-consecutive-sequence/ Problem : Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. Thoughts : 1. 先把 nums 放進去 set中,排除重複的數字。 2. 跑 nums迴圈,假設 nums-1 數字有在 set 中,那 nums 就不能當開頭。 3. 如果 nums-1沒有在 set 中,那就可以當開頭,計算值為1,如果 nums+1有在…

Leetcode Solution

1 min read

[Leetcode]128: Longest Consecutive Sequence
[Leetcode]128: Longest Consecutive Sequence
Leetcode Solution

1 min read


Jul 20, 2021

[Leetcode]334: Increasing Triplet Subsequence

Link : https://leetcode.com/problems/increasing-triplet-subsequence/ Problem: Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k]. If no such indices exists, return false. Thoughts: 1. 直接跑array內的值(nums[i] < nums[j] < nums[k])做比較,i<j<k這個照迴圈跑就可以達成。 2. first, second先設為 infinity,然後比較小的值取代掉…

Leetcode Solution

1 min read

[Leetcode]334: Increasing Triplet Subsequence
[Leetcode]334: Increasing Triplet Subsequence
Leetcode Solution

1 min read


Jul 19, 2021

[Leetcode]11: Container With Most Water

Link :https://leetcode.com/problems/container-with-most-water/ Problem : Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the…

Leetcode Medium

1 min read

[Leetcode]11: Container With Most Water
[Leetcode]11: Container With Most Water
Leetcode Medium

1 min read


Jul 15, 2021

[Leetcode]55. Jump Game

Link : https://leetcode.com/problems/jump-game/ Problem : Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. 有一個array nums,起始位置在 first index,每一次前進的值為nums[i],試問是否在array結束前來到最後最後一個數上。 …

Leetcode

1 min read

[Leetcode]55. Jump Game
[Leetcode]55. Jump Game
Leetcode

1 min read


Jul 14, 2021

[Leetcode]690: Employee Importance

Link : https://leetcode.com/problems/employee-importance/ Problem : You have a data structure of employee information, which includes the employee’s unique id, their importance value, and their direct subordinates’ id. You are given an array of employees employees where: employees[i].id is the ID of the ith employee. employees[i].importance is the importance value of…

Leetcode Solution

2 min read

[Leetcode]690: Employee Importance
[Leetcode]690: Employee Importance
Leetcode Solution

2 min read


Jul 14, 2021

[Leetcode]119 : Pascal’s Triangle II

Link : https://leetcode.com/problems/pascals-triangle-ii/ Problem : Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal’s trian …

Leetcode Solution

2 min read

[Leetcode]119 : Pascal’s Triangle II
[Leetcode]119 : Pascal’s Triangle II
Leetcode Solution

2 min read


Jul 13, 2021

[Leetcode]118 : Pascal’s Triangle

Link : https://leetcode.com/problems/pascals-triangle/ Problem : Given an integer numRows, return the first numRows of Pascal's triangle.

Leetcode Easy

1 min read

[Leetcode]118 : Pascal’s Triangle
[Leetcode]118 : Pascal’s Triangle
Leetcode Easy

1 min read

jojo lee

jojo lee

1 Follower

Help

Status

About

Careers

Blog

Privacy

Terms

Text to speech

Teams