blob: 623045ce47fc6d5cc8cc9135b9ba9b8655092d02 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
class Pair(object):
def __init__(self, a, b):
self.a = a
self.b = b
def max_chain_length(arr, n):
max = 0
mcl = [1 for i in range(n)]
for i in range(1, n):
for j in range(0, i):
if (arr[i].a > arr[j].b and
mcl[i] < mcl[j] + 1):
mcl[i] = mcl[j] + 1
for i in range(n):
if (max < mcl[i]):
max = mcl[i]
return max
|