Maximum points of intersection n lines
You are given n straight lines. You have to find a maximum number of points of intersection with these n lines.
Input : n = 4 Output : 6 Input : n = 2 Output :1
As we have n number of line, and we have to find the maximum point of intersection using this n line. So this can be done using the combination. This problem can be thought of as a number of ways to select any two lines among n line. As every line intersects with others that are selected.
So, the total number of points = nC2
Below is the implementation of the above approach:
Attention reader! All those who say programming isn’t for kids, just haven’t met the right mentors yet. Join the Demo Class for First Step to Coding Course, specifically designed for students of class 8 to 12.
The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.