Skip to content

230. Kth Smallest Element in a BST - #117

Open
kazuki-official wants to merge 1 commit into
mainfrom
230-kth-smallest-element-in-a-bst
Open

230. Kth Smallest Element in a BST#117
kazuki-official wants to merge 1 commit into
mainfrom
230-kth-smallest-element-in-a-bst

Conversation

@kazuki-official

Copy link
Copy Markdown
Owner

Comment thread memo.md
node_infos.pop();
TreeNode* node = node_information._node;
State state = node_information._state;
if (state == State::Unvisited) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

個人的には、 enum の値に応じて処理を切り替えるコードを書く際は、 switch 文を使用するようにしています。理由は、カバーしていない列挙子があった場合に、早めに発見できるようにするためです。

switch (state) {
case State::Unvisited:
    ...
case State::Visited:
    ...
default:
    // ここでエラーログを出力したり、失敗を意味する値を return したり、例外を送出したりする。
}

趣味の範囲かもしれません。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants