Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • F first-contributions
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 322
    • Merge requests 322
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • First Contributions
  • first-contributions
  • Merge requests
  • !58452

Create CheckCousinsINBinaryTree

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/Shubh-k04/patch-1 into main Oct 15, 2022
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Created by: Shubh-k04

Check cousins: Given the binary Tree and two nodes say ‘p’ and ‘q’. Determine whether the two nodes are cousins of each other or not. Two nodes are said to be cousins of each other if they are at same level of the Binary Tree and have different parents. Do it in O(n). Input format : Line 1 : Nodes in level order form (separated by space). If any node does not have left or right child, take -1 in its place Line 2 : integer value of p Line 3 : Integer value of q Output format : true or false Constraints : 1 <= N <= 10^5 Sample Input : 5 6 10 2 3 4 -1 -1 -1 -1 9 -1 -1 -1 -1 2 4 Sample Output : true

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/Shubh-k04/patch-1