HAPPY DECEMBER ⛄ || BEATS 100% 💯|| BEGINEER FRIENDLY ❤ || BRUTEFORCE APPROACH ✌
\n\n# Intuition And Approach :\nHere we came up again with ne problem and solution for that.\nThis december are mostly easy questions but some might are little 
![leetcode 100% beats.png](https://assets.leetcode.com/users/images/9af7967d-cce6-4be3-a62a-339bb89a8a19_1702606705.4202905.png)\n\n# Intuition And Approach :\nHere we came up again with ne problem and solution for that.\nThis december are mostly easy questions but some might are little bit tricky with edge cases. overall keep doing codes and i might not able to post further solution due to my exams from next week. \n\nso, lets hop back to our todays problem, that says to find the final destination we reached if we keep following from the 1st index . and it is also said that there is not loop. so here approach is very much simple here :\n\nsteps :\n\n1. i will see the edge cases first that is if there only `1 route` given  `i.e` `size` of array is `1`, then i will return the 2nd element .\n\n2. i am using while loop where i will check when `flag` is` true`.\n\n3. so when `flag` will `false?` when the route from the 2nd index from the position we are in , will `not be found` , we will make `flag = false.`\n\n4. you can see in code i am using `for` loop from `j=0 to j<n` . so there i m finding the next detination route. if found it will change mt iterator to that position and and make flag true. otherwise flag will remain false. and will go outside loop.\n\n5. and in outiside `while loop` i will return the latest updated iterator `it`. that gives me the position of last destination index found. \n\nHope u find this helpful. anydoubts u can put in comment i will reach to u .\nHappy December \uD83C\uDF81\u26C4.. and `merry cristmas` in Advance \u2744\u2603\uD83C\uDF67.\n\n# Code\n```\nclass Solution {\npublic:\n    string destCity(vector<vector<string>>& paths) {\n        string ans="";\n        int n=paths.size();\n        if(n==1) return paths[0][1];\n        int i=0;\n        bool flag=true;\n        int it=0;\n        while(flag==true){\n            \n            for(int j=0;j<n;j++){\n                flag=false;\n                if(paths[j][0]==paths[i][1]){\n                    i=j;\n                    j=n;\n                    flag=true;\n                }\n            }\n              \n            if(paths[it][1]==paths[i][0]){\n                   it=i;\n               }\n        } \n        return paths[it][1];\n    }\n};\n```
['String', 'C++']