Code Monkey home page Code Monkey logo

max_product_subsequence's Introduction

Maximum Product of Increasing Subsequence of Size 3 Medium Accuracy: 29.54% Submissions: 1099 Points: 4 Given a sequence of non-negative integers, find the subsequence of length 3 having maximum product, with the elements of the subsequence being in increasing order.

Example 1:

​Input: n = 8 arr[ ] = {6, 7, 8, 1, 2, 3, 9, 10} Output: 8 9 10 Explanation: 3 increasing elements of the given arrays are 8,9 and 10 which forms the subsequence of size 3 with maximum product.

​Example 2:

Input: n = 4 arr[ ] = {3, 4, 2, 1} Output: Not Present

Your Task: This is a function problem. The input is already taken care of by the driver code. You only need to complete the function maxProductSubsequence() that takes an array arr, sizeOfArray n, and return the subsequence of size 3 having the maximum product, numbers of subsequence being in increasing order. If no such sequence exists, return "-1". The driver code takes care of the printing.

Expected Time Complexity: O(N*LOG(N)). Expected Auxiliary Space: O(N).

Constraints: 1 <= N <= 105 1 <= Arr[i] <= 105

max_product_subsequence's People

Contributors

ramacpr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.