LeetCode: 606-Construct String from Binary Tree Solution
Problem
Given the root
of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.
Given the root
of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.
You are given a string num
, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num
, or an empty string ""
if no odd integer exists.
In early 2023, The pytorch 2.0 version added a new function that is torch.compile()
, It cloud be accelerate the speed of model training or inference. By using precision training with compiling, it always make my training time reduce to half.
Today I tried to load the model weights file after torch.compile()
, and then I found the weights is stored by OrderedDict data structure. This data structure is an ordered sequence, in other word its content needs to follow the order.
yield
is a keyword in Python, utilized much like return
, the use of yield
transforms a function into a Generator.
FastAPI is a modern, high-performance Python web framework. It is based on Python 3.7+ and utilizes Python type hints.
Read More »[Python] Notes on Backend Development Using the FastAPI FrameworkRecently, I trace many codes about LLaMA LoRA training (almost two months ago…), and when I reading the codes, I found if they want to configure the prompt for LLMs, if they need to change the prompt content by different training, the format_map()
function is the best choice.
As project development plans become increasingly concerned with execution speed and memory usage, it is clearly necessary for us to understand how much memory the variables and objects use in the program.
Read More »[Python] How To Compute The Memory Usage of Variables And ObjectsYou are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list.
You may assume the two numbers do not contain any leading zero, except the number 0 itself.
Read More »LeetCode: 2-Add Two Numbers Solution