Geeksforgeeks

Error

×

Leaderboard

Showing:

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

@Ibrahim Nash | 6420 |

@blackshadows | 6380 |

@mb1973 | 5704 |

@Quandray | 5245 |

@akhayrutdinov | 5111 |

@saiujwal13083 | 5046 |

@sanjay05 | 3762 |

@kirtidee18 | 3673 |

@mantu_singh | 3530 |

@marius_valentin_dragoi | 3523 |

@sushant_a | 3459 |

Complete Leaderboard | |

Handle | Score |

@cfwong8 | 1160 |

@gurshehzadsingh | 847 |

@nithinreddy3210 | 735 |

@mohanreddy8847 | 702 |

@AkashLahoty | 606 |

@jha8768 | 583 |

@workit | 582 |

@balwanyadav34 | 582 |

@pritsahkar2000 | 580 |

@divyagupta221100 | 557 |

@dipeshtiwari47 | 541 |

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?

YesLoading...

Minimum number of elements

...