Doubt in code of single source path

Sir
one side we are saying that we make a visited map in which there is bool
but we make map<T,int>visited; why
Thanks

Hi @Royal_Yashasvi, In case of bfs traversal , map<T,bool > visited,will also work fine , actually its more space optimized, but using map<T,int> will also produce same output , due to typecasting true will be typecasted to 1 and false to 0. so does’nt matter what you use as output will not be effected . still using bool is recommended for space optimization