Αποτελέσματα Αναζήτησης
2 Σεπ 2024 · 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. Explanation: The subsequence 1, 3, 4, 2 is the longest subsequence of consecutive elements.
Polyakov's record for longest cumulative time in space of 678 days over two missions stood until surpassed in 1999 by cosmonaut Sergei Avdeyev with a total of 747 days in space during three different missions.
4 Φεβ 2024 · Russian cosmonaut Oleg Kononenko has broken the world record for the most cumulative time spent in space, Russia's space agency Roscosmos reported Sunday.
6 Φεβ 2024 · Russian cosmonaut Oleg Kononeko breaks record for longest time spent in space — and he still has 6 months to go. News. By Harry Baker. published 6 February 2024. Oleg Kononeko has broken...
Longest Consecutive Sequence - Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O (n) time.
class Solution {public: int longestConsecutive (vector < int >& nums) {int ans = 0; unordered_set < int > seen {nums. begin (), nums. end ()}; for (int num: nums) {// `num` is the start of a sequence. if (seen. contains (num-1)) continue; int length = 1; while (seen. contains (++ num)) ++ length; ans = max (ans, length);} return ans;}};
Explanation: There are two longest consecutive sequences of length 6: [-4, -3, -2, -1, 0, 1] and [-2, -1, 0, 1, 2, 3]. So, we return 6 as an output. Example 3. Input: X[] = [0, 3, 7, 2, 5, 8, 4, 6, 0, 2, 1], Output: 9. Explanation: Here 2 and 3 are repeated, but all the unique integers are part of the longest consecutive sequence i.e. 0, 1, 2 ...