cuctaccuctac
Đàn iem Duy Mạnh
Để lại một bãi
có gì hay ko tmlmới mua leetcode premium luyện công đón gió bigtech 2025
bài này K tương đương với ith à? vd N = 5 thì 1,2,4,3,5 là một trường hợp à hay K bất kì nếu thế thì 1,2,... là một trường hợp à?Bài dễ: Bãi xe có N chỗ đỗ xe cạnh nhau. Tính xác xuất để xe thứ K và K+1 đỗ cạnh nhau ( 0 < K < N -1 )
N = 5 thì có các trường hợp:bài này K tương đương với ith à? vd N = 5 thì 1,2,4,3,5 là một trường hợp à hay K bất kì nếu thế thì 1,2,... là một trường hợp à?
xét tiếp K+2 đita xét K, và K + 1 là một khối khi đó ta có 1 khối và N-2 chỗ còn lại => để sắp xếp K và K+1 ta có (N-2 + 1)! = (N-1)! . Mà mỗi cách sắp xếp có thể thoán đổ vd K, K+1 và K+1, K => có 2*(N-1)! cách. với N thì ta có N! cách sắp xếp => 2*(N-1)!/N! =2*(N-1)!/N*(N-1)! = 2/N
=> P(K, K+1) = 2/N
Thì cũng có khác gì mấy đâu, tự làm đixét tiếp K+2 đi
class Solution:
def backtracking(self, candidates: List[int], index, target, sum, result, combination):
if sum == target:
result.append(combination.copy())
return
if sum > target:
return
for i in range(index, len(candidates)):
if i > index and candidates[i] == candidates[i - 1]:
continue
combination.append(candidates[i])
sum += candidates[i]
self.backtracking(candidates, i+1, target, sum, result, combination)
sum -= candidates[i]
combination.pop()
def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]:
result = []
combination = []
candidates.sort()
if len(candidates) == 0:
return result
self.backtracking(candidates, 0, target, 0, result, combination)
return result
mấy bài này chưa đủ vào bigtech đâuSang năm có bigtech nào về VN nữa ko nhỉ
Năm nay có MS và NVIDIA rồi
# Python program to construct tree using
# inorder and postorder traversals
class Node:
def __init__(self, x):
self.data = x
self.left = None
self.right = None
# Function to find index of value in arr[start...end]
# The function assumes that value is present in in[]
def search(arr, start, end, value):
for i in range(start, end + 1):
if arr[i] == value:
return i
return -1
# Recursive function to construct binary tree of size n
# from Inorder traversal in[] and Postorder traversal
# post[]. Initial values of inStrt and inEnd should
# be 0 and n - 1.
def build_util(inorder, postorder, in_start, in_end, post_index):
if in_start > in_end:
return None
# Pick current node from Postorder traversal using
# postIndex and decrement postIndex
node = Node(postorder[post_index[0]])
post_index[0] -= 1
# If this node has no children then return
if in_start == in_end:
return node
# Else find the index of this node in Inorder traversal
in_index = search(inorder, in_start, in_end, node.data)
# Using index in Inorder traversal, construct left and
# right subtrees
node.right = build_util(inorder, postorder, in_index + 1, in_end, post_index)
node.left = build_util(inorder, postorder, in_start, in_index - 1, post_index)
return node
# This function mainly initializes index of root
# and calls buildUtil()
def buildTree(inorder, postorder):
n = len(inorder)
post_index = [n - 1]
return build_util(inorder, postorder, 0, n - 1, post_index)
# Print the preorder of a binary tree
def print_preorder(node):
if node is None:
return
print(node.data, end=" ")
print_preorder(node.left)
print_preorder(node.right)
if __name__ == "__main__":
inorder = [4, 8, 2, 5, 1, 6, 3, 7]
postorder = [8, 4, 5, 2, 6, 7, 3, 1]
root = buildTree(inorder, postorder)
print_preorder(root)
cặc hình như eigenvalues t làm trong cal3 hay linear algebra r, đ phải đúng không, kh quá khó.
ChatGPT hả màyPython:# Python program to construct tree using # inorder and postorder traversals class Node: def __init__(self, x): self.data = x self.left = None self.right = None # Function to find index of value in arr[start...end] # The function assumes that value is present in in[] def search(arr, start, end, value): for i in range(start, end + 1): if arr[i] == value: return i return -1 # Recursive function to construct binary tree of size n # from Inorder traversal in[] and Postorder traversal # post[]. Initial values of inStrt and inEnd should # be 0 and n - 1. def build_util(inorder, postorder, in_start, in_end, post_index): if in_start > in_end: return None # Pick current node from Postorder traversal using # postIndex and decrement postIndex node = Node(postorder[post_index[0]]) post_index[0] -= 1 # If this node has no children then return if in_start == in_end: return node # Else find the index of this node in Inorder traversal in_index = search(inorder, in_start, in_end, node.data) # Using index in Inorder traversal, construct left and # right subtrees node.right = build_util(inorder, postorder, in_index + 1, in_end, post_index) node.left = build_util(inorder, postorder, in_start, in_index - 1, post_index) return node # This function mainly initializes index of root # and calls buildUtil() def buildTree(inorder, postorder): n = len(inorder) post_index = [n - 1] return build_util(inorder, postorder, 0, n - 1, post_index) # Print the preorder of a binary tree def print_preorder(node): if node is None: return print(node.data, end=" ") print_preorder(node.left) print_preorder(node.right) if __name__ == "__main__": inorder = [4, 8, 2, 5, 1, 6, 3, 7] postorder = [8, 4, 5, 2, 6, 7, 3, 1] root = buildTree(inorder, postorder) print_preorder(root)
Vẫn chưa hiêủ lắm, bài này thì liên quan gì tới ML nhỉHi các bác,
Em đang có 1 bài tập về machine learning.
có 1 file dữ liệu đường kính của sản phẩm. Em cần tìm ra độ dài của khoảng em vẽ màu đỏ.
Mỗi 1 dòng dữ liệu tương đương 0.1mm.
Khi đo bất kì 1 sản phẩm, máy sẽ đo được khoảng cách kia.
Nhờ các bác tư vấn ạ.
Data thì em có thể thu thập được nhiều.
Nhưng phương pháp em chưa biết làm thế nào.
![]()
minaminoJ
taokhongcoten19xx
đại khái là khi đo sản phẩm. phần mềm sẽ tự động nhận biết được vị trí trong vùng màu đỏ.Vẫn chưa hiêủ lắm, bài này thì liên quan gì tới ML nhỉ