Day 6 LeetCode
👨‍💻

Day 6 LeetCode

Tags
Data Structures
Python
Java
Computer Science
Published
Jan 24, 2021

Day 6 Task:

→ 1436. Destination City:
 

Solutions:

Please review all the solutions and try implementing on your own if you haven’t gotten it.
 
class Solution:
    def destCity(self, paths: List[List[str]]) -> str:
        curr = []
        nex = []
        for i in range(len(paths)):
            curr.append(paths[i][0])
            nex.append(paths[i][1])
        c = paths[0][0]
        while(nex[curr.index(c)] in curr):
            c = nex[curr.index(c)]
        return nex[curr.index(c)]