July 23, 2025 - Daily Drill¶
🎯 Daily Goals¶
- Review Anki Deck
- Lumosity training
- Leetcode
- Developing laplace
- Langchain Learning
📝 What I learned:¶
Leetcode Problem¶
Thinking Process¶
Well the question is a bit straightforward, we need to flatten the nested integer lists and add the product of integer value and its depth to a total. Intuitively, we just need to perform a BFS on the nested integers. If the object is a list, we expand it and append it to the queue along with its depth. If it is an integer, we multiply it along with its depth and add to the total sum.
Implementation¶
from collections import deque
class Solution:
def depthSum(self, nestedList: List[NestedInteger]) -> int:
queue = deque([])
for ni in nestedList:
queue.append((ni, 1))
total = 0
while queue:
ni, depth = queue.popleft()
if ni.isInteger():
total += ni.getInteger() * depth
else:
for new_ni in ni.getList():
queue.append((new_ni, depth + 1))
return total
Complexity Analysis¶
Let all there be n integers.
Time Complexity: O(n)
Space Complexity: O(n)
Key Takeaways¶
- Redo it using DFS
AI Engineering¶
Ambient Agent¶
Definition: Ambient agents are agents that listens to an event stream and act on it accrodingly, potentially acting on multiple tasks.
There are two attributes that are important:
- Triggered by event (not necessarily human interaction)
- Parallelism (being able to run multiple tasks simultaneously)
Human-in-the-loop¶
Definition: Huamn-in-the-loop pattern refers to AI system where human interaction is involved to enhance the system accuracy.
Here for ambient agent the most popular human-in-the-loop pattern contains three parts:
- Notify
- Question
- Review
The notify step tells the user what background event is happening which is usually worth attention. No steps are taken by AI at this phase. One good example would be AI trading assistant tells you that there is a new stock that is trending, but it won't buy on your behalf.
The question phase asks user question only when it is unclear to AI how to proceed to solve the event. It might be that AI does not have the tooling, lacks relevant information, or does not have the credential to perform the action. A good example would be that you received an invitation email to a hackathon and the AI agent is trying to reply on behalf of you but it does not know if you want to attend this event or not.
The last step is the review. Usually we don't want AI to take actions that seems "dangerous" like replying to an email, buying, selling stocks. Yet still, we want them to do it for us only after we have reviewed their work just like how a real assistant work.
Advantages of HITL:
- The most natural way how human interact with the AI assistant, like a real assistant
- Lower the stake of AI agents
- Continuous learning and training, personalization with long-term memory