From d4286d0b42ff5d9fbdc6c13d27057dd11ed194aa Mon Sep 17 00:00:00 2001 From: RISHAV KUMAR Date: Sat, 20 Jan 2018 11:35:43 +0530 Subject: [PATCH] Interview questions --- algorithms/hash.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 algorithms/hash.md diff --git a/algorithms/hash.md b/algorithms/hash.md new file mode 100644 index 00000000..68b9ea79 --- /dev/null +++ b/algorithms/hash.md @@ -0,0 +1,17 @@ +Longest Consecutive Subsequence... + +Given an array of integers, find the length of the longest sub-sequence such that +elements in the subsequence are consecutive integers, +the consecutive numbers can be in any order. + +Examples-- + +Input: arr[] = {1, 9, 3, 10, 4, 20, 2}; +Output: 4 +The subsequence 1, 3, 4, 2 is the longest subsequence +of consecutive elements + +Input: arr[] = {36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42} +Output: 5 +The subsequence 36, 35, 33, 34, 32 is the longest subsequence +of consecutive elements.