03 2024 档案
摘要:20. 有效的括号 class Solution: def isValid(self, s: str) -> bool: stk = [] upper = ["(", "{", "["] lower = [")", "}", "]"] dictionary = {")":"(", "}":"{",
阅读全文
摘要:What's AWS S3 database for unstructured data, we can put a static website (doesn't need that much back-end) on S3 Why use S3 high scalability horizont
阅读全文
摘要:232.用栈实现队列 class MyQueue: def __init__(self): """ in主要负责push,out主要负责pop """ self.stack_in = [] self.stack_out = [] def push(self, x: int) -> None: """
阅读全文
摘要:KMP算法 解决字符串匹配问题 例子: 文本串aabaabaaf 模式串aabaaf 问:模式串是否在文本串中出现过? 1.暴力解法,ptr指向文本串index 0,遍历一遍发现不匹配,ptr再移向index 1,遍历……依次重复,直到ptr指向3 2.KMP算法,ptr指向文本串index 0,遍
阅读全文
摘要:** 344.反转字符串** class Solution: def reverseString(self, s: List[str]) -> None: left = 0 right = len(s)-1 while left < right: temp = s[left] s[left] = s
阅读全文
摘要:454.四数相加II class Solution: def fourSumCount(self, nums1: List[int], nums2: List[int], nums3: List[int], nums4: List[int]) -> int: table = dict() for i
阅读全文
摘要:242.有效的字母异位词 思路:26位的array,每个分别对应a, b, c..., z,如果遇到一个字母就++,如果两个array一样则为anagram hint: to initiate an array with n elements carrying value 0: arr=[] arr
阅读全文
04天【代码随想录算法训练营34期】 第二章 链表part02 (● 24. 两两交换链表中的节点 ● 19.删除链表的倒数第N个节点 ● 面试题 02.07. 链表相交 ● 142.环形链表II )
摘要:24. 两两交换链表中的节点 # Definition for singly-linked list. class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next clas
阅读全文
摘要:203.移除链表元素 竟然可以做个假head,学到了 class ListNode(object): def __init__(self, val=0, next=None): self.val = val self.next = next class Solution(object): def r
阅读全文
摘要:Model optimizations to improve application performance Distillation: uses a larger model, the teacher model, to train a smaller model, the student mod
阅读全文
摘要:977.有序数组的平方 暴力解法,熟悉python的array.sort()用法 可以再温习一下不同sort的算法写法以及complexity class Solution(object): def sortedSquares(self, nums): for i in range(len(nums
阅读全文
摘要:704. 二分查找 先选是[low, high]还是[low, high)还是(low, high] 下面选择[] "while (low <= high)"还是"while (low < high)" 因为[1,1]合法,所以是<=(什么是不合法呢,比如说[2,1]) "high = mid -
阅读全文
摘要:Helpful? Honest? Harmless? Make sure AI response in those 3 ways. If not, we need RLHF is reduce the toxicity of the LLM. Reinforcement learning: is a
阅读全文
摘要:With PEFT, we only train on small portion of parameters! What's using memory while training model? Trainable weights Optimizer states Gradients Forwar
阅读全文
摘要:GenAI Project Lifecycle: After picking pre-trained models, we can fine-tune! In-context learning (ICL): zero / one / few shot inference. Including a f
阅读全文