---
title: "Discussion on \"Lets Code Everyday - Day 22\" | Hashnode"
description: "Discussion on \"Lets Code Everyday - Day 22\". Question - 22:\nFirst Missing Positive\nGiven an unsorted integer array nums, return the smallest missing positive integer.\nExample 1:\nInput: nums = [1,2,0]\nOutput: 3\nExplanation: The numbers in the range [1,2] are all in the array.\n\nExample 2:\nInput: ..."
url: "https://hashnode.com/posts/lets-code-everyday-day-22-1/6445838b4d667ab374052bdf"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Lets Code Everyday - Day 22](https://vinayrangaraju.hashnode.dev/lets-code-everyday-day-22-1?utm_source=hashnode&utm_medium=feed)

Question - 22: First Missing Positive Given an unsorted integer array nums, return the smallest missing positive integer. Example 1: Input: nums = \[1,2,0\] Output: 3 Explanation: The numbers in the range \[1,2\] are all in the array. Example 2: Input: ...

Apr 23, 2023 · 5 min read · vinayrangaraju.hashnode.dev  
Read the article

-   [#programming](https://hashnode.com/tag/programming)
-   [#programming-blogs](https://hashnode.com/tag/programming-blogs)

## Written by

[Vinay Rangaraju](https://hashnode.com/@vinayrangaraju)

@vinayrangaraju

  
[View profile](https://hashnode.com/@vinayrangaraju)

Learn--->Share--->Learn

## Responses 1

Markdown supported · ⌘↵ to post

[Kumarasamy Mani](https://hashnode.com/@kumarasamy)

[Apr 25, 2023](https://hashnode.com/posts/lets-code-everyday-day-22-1/6445838b4d667ab374052bdf/comment/6447c12773f3c95ec8ed5f94)

What happens if we use Divide and Conquer after sorting? Will that be efficient, sort it and try to remove all the -Ve elements by dividing the array and checking the last element, if it's null ignore it and continue till you get +ve element in left array's last element, then use index and figure out won't it reduce the time?

[Vinay Rangaraju](https://hashnode.com/@vinayrangaraju)

[Apr 25, 2023](https://hashnode.com/posts/lets-code-everyday-day-22-1/6445838b4d667ab374052bdf/comment/6447c12773f3c95ec8ed5f94#reply-6447cbdce947fa5fa90b16cf)

Thanks for commenting 😁 & giving another possibility to solve the problem.

If I understood correctly ,The approach you described involves dividing the array and checking the last element of the left subarray to determine if there are positive numbers in that subarray. If the last element is positive, the algorithm recursively searches that subarray. Otherwise, it searches the right subarray.

I don't think there will be variation in time complexity since sorting involves in the suggested approach also.

But will definitely try the approach mentioned via code and get back.

Actually the first approach taken is to solve the problem mainly. Then after I have focused on decreasing complexity in terms of time and space. Unfortunately ended up in bringing difference in only time complexity in second approach i.e., O(n) which is better than first approach with time complexity i.e., O(nlogn)
