{"id":"5007c26f-68e6-4c63-be51-b7dbe299c0c0","name":"Maximum Non-overlapping Bridges","description":"1. You are given a number n, representing the number of bridges on a river.\r\n2. You are given n pair of numbers, representing the north bank and south bank co-ordinates of each bridge.\r\n3. You are required to print the count of maximum number of non-overlapping bridges.","inputFormat":"A number n\r\n.. n pair of number each on a separate line (and pair separated by space)","outputFormat":"A number representing the count of maximum number of non-overlapping bridges.","constraints":"0 <= n <= 20\r\n0 <= n1n, n1s, n2n, n2s, .. <= 100","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n10 20\r\n2 7\r\n8 15\r\n17 3\r\n21 40\r\n50 4\r\n41 57\r\n60 80\r\n80 90\r\n1 30","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/o1h3aoeSTOU?end=143","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"44f25b8f-9b99-4e1d-a35e-e92082b43088","name":"Maximum Non-overlapping Bridges","slug":"maximum-non-overlapping-bridges","type":1}],"next":{"id":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","type":1,"slug":"longest-increasing-subsequence"},"prev":{"id":"54acc5fb-90df-43cb-95d2-f96b87af5345","name":"Maximum Sum Increasing Subsequence","type":1,"slug":"maximum-sum-increasing-subsequence"}}}

Maximum Non-overlapping Bridges

1. You are given a number n, representing the number of bridges on a river. 2. You are given n pair of numbers, representing the north bank and south bank co-ordinates of each bridge. 3. You are required to print the count of maximum number of non-overlapping bridges.

{"id":"5007c26f-68e6-4c63-be51-b7dbe299c0c0","name":"Maximum Non-overlapping Bridges","description":"1. You are given a number n, representing the number of bridges on a river.\r\n2. You are given n pair of numbers, representing the north bank and south bank co-ordinates of each bridge.\r\n3. You are required to print the count of maximum number of non-overlapping bridges.","inputFormat":"A number n\r\n.. n pair of number each on a separate line (and pair separated by space)","outputFormat":"A number representing the count of maximum number of non-overlapping bridges.","constraints":"0 <= n <= 20\r\n0 <= n1n, n1s, n2n, n2s, .. <= 100","sampleCode":{"cpp":{"code":""},"java":{"code":"import java.io.*;\r\nimport java.util.*;\r\n\r\npublic class Main {\r\n\r\n public static void main(String[] args) throws Exception {\r\n // write your code here\r\n }\r\n\r\n}"},"node":{"code":""},"ruby":{"code":""},"python":{"code":""}},"points":10,"difficulty":"easy","sampleInput":"10\r\n10 20\r\n2 7\r\n8 15\r\n17 3\r\n21 40\r\n50 4\r\n41 57\r\n60 80\r\n80 90\r\n1 30","sampleOutput":"7","questionVideo":"https://www.youtube.com/embed/o1h3aoeSTOU?end=143","hints":[],"associated":[],"solutionSeen":false,"tags":[],"meta":{"path":[{"id":0,"name":"home"},{"id":"0c54b191-7b99-4f2c-acb3-e7f2ec748b2a","name":"Data Structures and Algorithms","slug":"data-structures-and-algorithms","type":0},{"id":"5539a6e8-c8bf-4f04-805c-e43e9d20e72a","name":"Dynamic Programming For Intermediate","slug":"dynamic-programming-for-intermediate-408","type":0},{"id":"44f25b8f-9b99-4e1d-a35e-e92082b43088","name":"Maximum Non-overlapping Bridges","slug":"maximum-non-overlapping-bridges","type":1}],"next":{"id":"497198c6-c788-44aa-b37f-f6ae8369aa08","name":"Longest Increasing Subsequence","type":1,"slug":"longest-increasing-subsequence"},"prev":{"id":"54acc5fb-90df-43cb-95d2-f96b87af5345","name":"Maximum Sum Increasing Subsequence","type":1,"slug":"maximum-sum-increasing-subsequence"}}}
plane

Editor


Loading...

Maximum Non-overlapping Bridges

easy

1. You are given a number n, representing the number of bridges on a river. 2. You are given n pair of numbers, representing the north bank and south bank co-ordinates of each bridge. 3. You are required to print the count of maximum number of non-overlapping bridges.

Constraints

0 <= n <= 20 0 <= n1n, n1s, n2n, n2s, .. <= 100

Format

Input

A number n .. n pair of number each on a separate line (and pair separated by space)

Output

A number representing the count of maximum number of non-overlapping bridges.

Example

Sample Input

10 10 20 2 7 8 15 17 3 21 40 50 4 41 57 60 80 80 90 1 30

Sample Output

7

Question Video

Discussions

Show Discussion

Related Resources

related resources

Turning Off Zen Mode