MeetCode
Tree Edges
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Run
Submit
Dark
Problem Statement
Solutions
Submissions
Tree Edges
Easy
Computer Mathematics
Graph Theory Basics
29 views
Explanation
Complexity
Problem Statement
Given number of nodes n in a tree, print number of edges.
Input Format
One integer n.
Output Format
One integer.
Example
Input
5
Output
4
Constraints
n>=1
Input / Output Format
Input Format
One integer n.
Output Format
One integer.
Constraints
n>=1
Examples
Input:
5
Output:
4
Example Solution (Public)
Computer Mathematics
A tree with n nodes has n-1 edges.
Official Solution Code
Wrap
Copy
A tree with n nodes has n-1 edges.
Please
login
to submit solutions.
Editor
C
C++
Computer Mathematics
CSS
DSA
HTML
Java
JavaScript
NodeJS
PHP
Programming Interview
Python
ReactJS
SQL
Test Cases
Output
Submission Result
Input
5
Expected Output
4
Compile Output
Error
Output
Please
login
to submit solutions.