{"id":22513972,"url":"https://github.com/emahtab/binary-tree-right-side-view","last_synced_at":"2026-01-06T17:36:40.628Z","repository":{"id":79525303,"uuid":"237651025","full_name":"eMahtab/binary-tree-right-side-view","owner":"eMahtab","description":"Binary Tree Right Side View","archived":false,"fork":false,"pushed_at":"2020-02-01T17:41:22.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T03:26:16.263Z","etag":null,"topics":["bfs","binary-tree","leetcode","problem-solving"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eMahtab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-01T17:28:37.000Z","updated_at":"2020-02-01T17:41:24.000Z","dependencies_parsed_at":"2023-05-10T17:00:56.625Z","dependency_job_id":null,"html_url":"https://github.com/eMahtab/binary-tree-right-side-view","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fbinary-tree-right-side-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fbinary-tree-right-side-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fbinary-tree-right-side-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eMahtab%2Fbinary-tree-right-side-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eMahtab","download_url":"https://codeload.github.com/eMahtab/binary-tree-right-side-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245952406,"owners_count":20699479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bfs","binary-tree","leetcode","problem-solving"],"created_at":"2024-12-07T03:15:18.663Z","updated_at":"2026-01-06T17:36:40.564Z","avatar_url":"https://github.com/eMahtab.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Binary Tree Right Side View\n## https://leetcode.com/problems/binary-tree-right-side-view\n\nGiven a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.\n\n```\nExample:\nGiven the below tree, right side view of the tree will be : [1, 3, 4, 6]\nExplanation:\n\n   1            \u003c---\n /   \\\n2     3         \u003c---\n \\     \\\n  5     4       \u003c---\n / \n6               \u003c---\n```\n\n## Implementation :\n\n```java\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     int val;\n *     TreeNode left;\n *     TreeNode right;\n *     TreeNode(int x) { val = x; }\n * }\n */\nclass Solution {\n    public List\u003cInteger\u003e rightSideView(TreeNode root) {\n        List\u003cInteger\u003e list = new ArrayList\u003c\u003e();\n        if(root == null)\n            return list;\n        Queue\u003cTreeNode\u003e queue = new LinkedList\u003c\u003e();\n        queue.offer(root);\n        while(!queue.isEmpty()){\n            int size = queue.size();\n            for(int i = 0; i \u003c size; i++){\n                TreeNode current = queue.poll();\n                if(i == size - 1)\n                    list.add(current.val);\n                if(current.left != null)\n                    queue.offer(current.left);\n                if(current.right != null)\n                    queue.offer(current.right);\n            }\n        }\n       return list; \n    }\n}\n```\n\n```\nRuntime Complexity = O(n), where n is the total number of nodes in the binary tree\nSpace Complexity   = O(n), where n is the total number of nodes in the binary tree\n```\n\n# References :\nhttps://www.youtube.com/watch?v=jCqIr_tBLKs\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fbinary-tree-right-side-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femahtab%2Fbinary-tree-right-side-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femahtab%2Fbinary-tree-right-side-view/lists"}