Stella
Stella

Stella

OpenClaw, Hermes, Poke를 쓰며 느낀 단점들

내가 만약 워크스페이스 에이전트를 만든다면 어떻게 만들까?

메모리

  • 육하원칙에 맞게 기억해야하는데, 이걸 잘 못 함
    • 맥락을 종종 헷갈려함
  • 메모리 툴을 명시적으로 불러야 함
    • 이는 Hermes에서 많이 완화된 부분

Slack

  • 답장을 매번 하려 함. 쓰레드에 달리는 모든 글에 답을 함.
    • 매번 답할 필요는 없음. 필요할 때만 하면 됨.
  • 언급하지 않은 메시지는 읽지 않음.
    • 모든 워크스페이스의 변화를 계속 보고 있어야 함, 그리고 기억해야 함
Backlinks (2)
  • 260419
  • 260411
260413
260413

260413

Ramp의 AX (회사를 AI로 물들이는 법)

Backlinks (0)

No backlinks found.

Debian Setup
Debian Setup

Debian Setup

sudo apt update && sudo apt install git && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && echo >> ~/.bashrc && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" && sudo apt-get install build-essential && brew install gcc btop
Backlinks (1)
  • 260415
Definition for a binary tree node.
Definition for a binary tree node.

Definition for a binary tree node.

Solved at: 220925. Took 17m 09s

Question

Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.

According to thedefinition of LCA on Wikipedia: "The lowest common ancestor is defined between two nodespandqas the lowest node inTthat has bothpandqas descendants (where we allowa node to be a descendant of itself)."

Solution

python
# Definition for a binary tree node.# class TreeNode:#     def __init__(self, x):#         self.val = x#         self.left = None#         self.right = None
class Solution:    def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
        found_p = False        found_q = False
        queue = [root]
        ancestor = {}
        while((not found_p or not found_q) and queue):            current = queue.pop()            if not current:                continue            left = current.left            right = current.right            if left:                ancestor[left] = current                if p.val == left.val:                    found_p = True                if q.val == left.val:                    found_q = True            if right:                ancestor[right] = current                if p.val == right.val:                    found_p = True                if q.val == right.val:                    found_q = True            queue.append(left)            queue.append(right)
        current = p        p_path = [current]
        while current != root:            current = ancestor[current]            p_path.append(current)
        current = q        q_path = [current]
        while current != root:            current = ancestor[current]            q_path.append(current)
        lca = root
        for i in p_path:            print(i.val, "<-", end=" ")        print()        for i in q_path:            print(i.val, "<-", end=" ")
        for i in range(-1, -1 * min(len(q_path), len(p_path)) - 1, -1):            if q_path[i] == p_path[i]:                lca = p_path[i]            elif q_path[i] != p_path[i]:                break
        return lca

I misunderstood LCA as being the minimum in value.

Results

Runtime

  • 89 ms, faster than 86.27% of Python3 online submissions for the Lowest Common Ancestor of a Binary Search Tree.

Memory Usage

  • 18.9 MB, less than 23.33% of Python3 online submissions for the Lowest Common Ancestor of a Binary Search Tree.

Improvements

I ignored that this is a Binary Search Tree, not just Binary Tree. Therefore one can binary search to reduce the search scope.

Complexity Analysis

For this, It will be O(N)O(N)O(N) where NNN is the count of the nodes. Space complexity will be O(N)O(N)O(N) for constructing lists and dictionaries.

If we use the above improvement, space complexity will reduce to O(1)O(1)O(1). However, time complexity will not change.

Backlinks (2)
  • 220925
  • Coding Tests
Index
cho.sh
I prefer CLIBB9A08260619260619컴퓨트로늄37A88F컴퓨트로늄0CF03F컴퓨트로늄2C60FB260618260618260418260418260528260528AutoBuilder63849A260419260419Setup9AC296StellaD226F7260415260415Debian SetupD2F701260414260414anaclumos/configs/AGENTS.mdED86A3Ramp의 AX (회사를 AI로 물들이는 법)840774260413260413How to get your company AI pilled46544C260411260411260409260409260407260407260406260406Separating Claude Code Personal Sub and Claude Code Company Sub33A53C
sudo apt update && sudo apt install git && /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" && echo >> ~/.bashrc && echo 'eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)"' >> ~/.bashrc && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv bash)" && sudo apt-get install build-essential && brew install gcc btop
Warning
This post is more than a year old. Information may be outdated.
# Definition for a binary tree node.# class TreeNode:#     def __init__(self, x):#         self.val = x#         self.left = None#         self.right = None
class Solution:    def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
        found_p = False        found_q = False
        queue = [root]
        ancestor = {}
        while((not found_p or not found_q) and queue):            current = queue.pop()            if not current:                continue            left = current.left            right = current.right            if left:                ancestor[left] = current                if p.val == left.val:                    found_p = True                if q.val == left.val:                    found_q = True            if right:                ancestor[right] = current                if p.val == right.val:                    found_p = True                if q.val == right.val:                    found_q = True            queue.append(left)            queue.append(right)
        current = p        p_path = [current]
        while current != root:            current = ancestor[current]            p_path.append(current)
        current = q        q_path = [current]
        while current != root:            current = ancestor[current]            q_path.append(current)
        lca = root
        for i in p_path:            print(i.val, "<-", end=" ")        print()        for i in q_path:            print(i.val, "<-", end=" ")
        for i in range(-1, -1 * min(len(q_path), len(p_path)) - 1, -1):            if q_path[i] == p_path[i]:                lca = p_path[i]            elif q_path[i] != p_path[i]:                break
        return lca