summaryrefslogtreecommitdiff
path: root/progs/a262.py
diff options
context:
space:
mode:
Diffstat (limited to 'progs/a262.py')
-rw-r--r--progs/a262.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/progs/a262.py b/progs/a262.py
new file mode 100644
index 0000000..dd4220b
--- /dev/null
+++ b/progs/a262.py
@@ -0,0 +1,16 @@
+def find_longest_conseq_subseq(arr, n):
+ ans = 0
+ count = 0
+ arr.sort()
+ v = []
+ v.append(arr[0])
+ for i in range(1, n):
+ if (arr[i] != arr[i - 1]):
+ v.append(arr[i])
+ for i in range(len(v)):
+ if (i > 0 and v[i] == v[i - 1] + 1):
+ count += 1
+ else:
+ count = 1
+ ans = max(ans, count)
+ return ans \ No newline at end of file