mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
leetcode problem
This commit is contained in:
parent
efec471784
commit
c09ed1008f
@ -27,7 +27,7 @@ def search_range(nums: list[int], target: int) -> list[int]:
|
|||||||
[1, 1]
|
[1, 1]
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def binary_search(nums, target, left):
|
def binary_search(nums:list, target:int, left:int):
|
||||||
low, high = 0, len(nums) - 1
|
low, high = 0, len(nums) - 1
|
||||||
index = -1
|
index = -1
|
||||||
while low <= high:
|
while low <= high:
|
||||||
|
@ -8,7 +8,7 @@ Leetcode reference: https://leetcode.com/problems/lexicographical-numbers/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def lexical_order(n: int) -> list[int]:
|
def lexical_order(num: int) -> list[int]:
|
||||||
"""
|
"""
|
||||||
>>> lexical_order(13)
|
>>> lexical_order(13)
|
||||||
[1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9]
|
[1, 10, 11, 12, 13, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||||
@ -21,7 +21,7 @@ def lexical_order(n: int) -> list[int]:
|
|||||||
of characters according to their position in the alphabet.
|
of characters according to their position in the alphabet.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
numbers = [str(i) for i in range(1, n + 1)]
|
numbers = [str(i) for i in range(1, num + 1)]
|
||||||
numbers.sort()
|
numbers.sort()
|
||||||
res = list(map(int, numbers))
|
res = list(map(int, numbers))
|
||||||
return res
|
return res
|
||||||
|
Loading…
Reference in New Issue
Block a user