Facebook Onsite Interview Problem

Anonymous User
626
Jul 12, 2024

You are playing a game with ( n ) rooms and ( m ) tunnels. Starting with a score of 0, each tunnel you traverse alters your score by a value ( x ), which can be either positive or negative. You are allowed to pass through a tunnel multiple times. Your goal is to find the maximum score possible while traveling from room 1 to room ( n ).

Input1:
4 5
1 2 3
2 4 -1
1 3 -2
3 4 7
1 4 4
Outpu1:
5

Input2:
4 5
1 2 1
2 3 1
3 2 1
2 4 1
1 4 1000000000
Output2:
-1

same problem existed on Internet: https://cses.fi/problemset/task/1673

Comments (6)