You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
위 식이 핵심인데, a - b - c 를 죽 이었을 때 a / c 의 답을 얻을 수 있다.
a -> b 의 간선은 a / b 의 값으로, b -> a 의 간선은 1 / (a / b) 로 값을 세팅한 후 쿼리가 오면 경로대로 곱해주면 답이다.
BFS 탐색으로 시작부터 끝까지 돌면서 나오는 값들을 다 곱해주었다. 예외 처리로 없는 값이 들어오는 것만 처리해주면 쉽게 풀린다.
This discussion was converted from issue #62 on September 15, 2026 11:03.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Problem link
https://leetcode.com/problems/evaluate-division/
Problem Summary
방정식과 결과 값이 주어질 때 방정식을 받아서 값을 계산하는 문제.
Solution
체인 형태로 연결되어 있는 것이 그래프가 생각났다.
위 식이 핵심인데, a - b - c 를 죽 이었을 때 a / c 의 답을 얻을 수 있다.
a -> b 의 간선은 a / b 의 값으로, b -> a 의 간선은 1 / (a / b) 로 값을 세팅한 후 쿼리가 오면 경로대로 곱해주면 답이다.
BFS 탐색으로 시작부터 끝까지 돌면서 나오는 값들을 다 곱해주었다. 예외 처리로 없는 값이 들어오는 것만 처리해주면 쉽게 풀린다.
Source Code
All reactions