8000 update at 2019-03-29 · bonfy/leetcode@849cd54 · GitHub
[go: up one dir, main page]

Skip to content

Commit 849cd54

Browse files
committed
update at 2019-03-29
1 parent aa38a5a commit 849cd54

File tree

7 files changed

+74
-44
lines changed

7 files changed

+74
-44
lines changed

README.md

Lines changed: 36 additions & 16 deletions
Large diffs are not rendered by default.

solutions/003-longest-substring-without-repeating-characters/longest-substring-without-repeating-characters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#
3434
#
3535
#
36-
#
3736

3837

3938
class Solution(object):

solutions/066-plus-one/plus-one.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
# Output: [4,3,2,2]
2323
# Explanation: The array represents the integer 4321.
2424
#
25-
#
2625

2726

2827
class Solution(object):

solutions/227-basic-calculator-ii/basic-calculator-ii.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# You may assume that the given expression is always valid.
3232
# Do not use the eval built-in library function.
3333
#
34+
#
3435

3536

3637
class Solution(object):

solutions/335-self-crossing/self-crossing.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,43 @@
55
#
66
# Write a one-pass algorithm with O(1) extra space to determine, if your path crosses itself, or not.
77
#
8-
# Example 1:
8+
#  
99
#
10+
# Example 1:
1011
#
11-
# Input: [2,1,1,2]
1212
#
13-
# ?????
14-
# ? ?
15-
# ???????>
16-
# ?
13+
# ┌───┐
14+
# │   │
15+
# └───┼──>
16+
#     │
1717
#
18-
# Input: true
19-
# Explanation: self crossing
18+
# Input: [2,1,1,2]
19+
# Output: true
2020
#
2121
#
2222
# Example 2:
2323
#
2424
#
25-
# Input: [1,2,3,4]
26-
#
27-
# ????????
28-
# ? ?
29-
# ?
30-
# ?
31-
# ?????????????>
25+
# ┌──────┐
26+
# │      │
27+
# │
28+
# │
29+
# └────────────>
3230
#
31+
# Input: [1,2,3,4]
3332
# Output: false
34-
# Explanation: not self crossing
3533
#
3634
#
3735
# Example 3:
3836
#
3937
#
40-
# Input: [1,1,1,1]
41-
#
42-
# ?????
43-
# ? ?
44-
# ?????>
38+
# ┌───┐
39+
# │   │
40+
# └───┼>
4541
#
42+
# Input: [1,1,1,1]
4643
# Output: true
47-
# Explanation: self crossing
44+
#
4845
#
4946

5047

solutions/454-4sum-ii/4sum-ii.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#
88
# Example:
99
#
10+
#
1011
# Input:
1112
# A = [ 1, 2]
1213
# B = [-2,-1]
@@ -22,6 +23,8 @@
2223
# 2. (1, 1, 0, 0) -> A[1] + B[1] + C[0] + D[0] = 2 + (-1) + (-1) + 0 = 0
2324
#
2425
#
26+
#  
27+
#
2528

2629

2730
class Solution(object):

solutions/458-poor-pigs/poor-pigs.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
# -*- coding:utf-8 -*-
22

33

4-
# There are 1000 buckets, one and only one of them contains poison, the rest are filled with water. They all look the same. If a pig drinks that poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket contains the poison within one hour.
4+
# There are 1000 buckets, one and only one of them is poisonous, while the rest are filled with water. They all look identical. If a pig drinks the poison it will die within 15 minutes. What is the minimum amount of pigs you need to figure out which bucket is poisonous within one hour?
55
#
6-
# Answer this question, and write an algorithm for the follow-up general case.
6+
# Answer this question, and write an algorithm for the general case.
77
#
8-
# Follow-up:
8+
#  
99
#
10-
# If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the "poison" bucket within p minutes? There is exact one bucket with poison.
10+
# General case:
11+
#
12+
# If there are n buckets and a pig drinking poison will die within m minutes, how many pigs (x) you need to figure out the poisonous bucket within p minutes? There is exactly one bucket with poison.
13+
#
14+
#  
15+
#
16+
# Note:
17+
#
18+
#
19+
# A pig can be allowed to drink simultaneously on as many buckets as one would like, and the feeding takes no time.
20+
# After a pig has instantly finished drinking buckets, there has to be a cool down time of m minutes. During this time, only observation is allowed and no feedings at all.
21+
# Any given bucket can be sampled an infinite number of times (by an unlimited number of pigs).
1122
#
1223

1324

0 commit comments

Comments
 (0)
0