Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5646 |

@Quandray | 5233 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 4716 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@marius_valentin_dragoi | 3522 |

@sushant_a | 3459 |

@verma_ji | 3413 |

Complete Leaderboard | |

Handle | Score |

@skj7 | 671 |

@gurshehzadsingh | 418 |

@swastik8750 | 411 |

@nishunishuraj18 | 405 |

@vedantvalsangkar | 390 |

@deepakchowdary | 380 |

@akashverma4 | 369 |

@satyamannsm | 353 |

@rkrupeshkumar345 | 331 |

@2018uec1603 | 331 |

@surajmamgai | 330 |

Complete Leaderboard |

Given an array **arr **of size** N**, the task is to make strictly increasing and strictly decreasing subsequences from the array such that each array element belongs to increasing subsequence or decreasing subsequence, but not both, or can be part of none of the subsequence. Minimize the number of elements that are not part of any of the subsequences and find the count of such elements.

**Example 1:**

Input: N = 12, arr[] = {7, 8, 1, 2, 4, 6, 3, 5, 2, 1, 8, 7}Output:2Explanation: Increasing sequence can be : {1, 2, 4, 5, 8}. Decreasing sequence can be : {7, 6, 3, 2, 1}. So, only 2 (8, 7) elements are left which are not part of either of the subsequences.

**Input: **N = 7, arr[] = {1, 4, 2, 3,
3, 2, 4}
**Output: **0
**Explanation**:
Increasing sequence can be :
{1, 2, 3, 4}.
Decreasing sequence can be :
{4, 3, 2}.

**Your Task: **

You don't need to read input or print anything. Complete the function ** minCount() **which takes

1 ≤ N ≤ 10

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Minimum number of elements

...