JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat  | Threaded  | Tree Previous Thread  |  Next Thread Forums TopCoder Cookbook Algorithm Competitions - Rewriting Phase How to find maximum element on left hand side of an element which is smaller than the element in an array?
 How to find maximum element on left hand side of an element which is smaller than the element in an array? | Reply Suppose I have an array of integers like this:{ 3, 1, 6, 8, 2, 0, 1 }I need to find the maximum element on the left hand side of each element which is smaller than the element, or print -1 if that maximum element doesn't exist. So, solution for this problem will be:{ -1, -1, 3, 6, 1, -1, 0 }I can solve this in O(n^2) using two loops. Inner loop will find maximum element which is smaller than the given element. But is there any better approach to solve this?
 Subject Author Date How to find maximum element on left hand side of an element which is smaller than the element in an array? d@rk_sh@dow Oct 27, 2014 at 1:59 PM EDT Re: How to find maximum element on left hand side of an element which is smaller than the element in an array? vampcoder Jan 21, 2016 at 2:37 AM EST
 Forums TopCoder Cookbook Algorithm Competitions - Rewriting Phase How to find maximum element on left hand side of an element which is smaller than the element in an array? Previous Thread  |  Next Thread