Clean Easy BFS traversal in C++ for begineers step by step.
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    void bfs(int i,vector<int>&ans,int n,vector<int>adj[]){\n        queue<int>q;\n        q.push(i);\n        vector<int>vis(n+1,0);\n        vis[i]=1;\n        int level=0;\n        while(!q.empty()){\n            int s=q.size();\n            int c=0;\n            for(int i=0;i<s;i++){\n                int node=q.front();\n                q.pop();\n                for(auto it:adj[node]){\n                    if(!vis[it]){\n                        vis[it]=1;\n                        q.push(it);\n                        c++;\n                    }\n                }\n            }\n            ans[level++]+=c;\n\n        }\n    }\npublic:\n    vector<int> countOfPairs(int n, int x, int y) {\n        \n        vector<int>adj[n+1];\n        for(int i=1;i<n;i++){\n             adj[i].push_back(i+1);\n             adj[i+1].push_back(i);\n        }\n        adj[x].push_back(y);\n        adj[y].push_back(x);\n\n        vector<int>res(n);\n\n        for(int i=1;i<=n;i++){\n            bfs(i,res,n,adj);\n        }\n    \n        return res;\n        \n    }\n};\n```
['Breadth-First Search', 'Graph', 'C++']