Algorithms · Question 30 · Hard

What is the length of the longest strictly increasing subsequence of [3, 10, 2, 1, 20, 4, 6, 7, 5]?

  1. 5
  2. 6
  3. 3
  4. 4
Answer and explanation

Answer: D. 4

Explanation: Subsequences such as 3, 4, 6, 7 or 1, 4, 6, 7 have length 4. No length-5 increasing subsequence exists (checked by the O(n²) DP), so the answer is 4.

Previous: Lomuto partition with the last element as the pivot is applied once to [7, 2…

Practise algorithms

Try a fresh set of algorithms questions with an explanation after every answer, free and without signing up: Algorithms practice. Or sit a full placement mock test.

More algorithms questions

More technical & programming practice

Object-Oriented Programming · DBMS · SQL · Operating Systems · Computer Networks · Software Engineering · Cloud & DevOps · GenAI Basics

LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge