We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Data Structures
  3. Stacks
  4. Largest Rectangle
  5. Discussions

Largest Rectangle

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • vedantmahajan121
    6 months ago+ 0 comments

    //My C Language Code

    long largestRectangle(int h_count, int* h) {

    long max=LONG_MIN;
    int count=0;
    int mul;
    for(int i=0;i<h_count;i++){
        for(int k=i;k>=0;k--){
            if(h[i]<=h[k]){
                count++;
            }
            else 
               break;
        }
    
        for(int j=i+1;j<h_count;j++){
            if(h[i]<=h[j]){
                count++;
            }
            else 
                break;
    
        }
        mul=h[i]*count;
        count=0;
        if(max < mul)
            max=mul;
    
    }
    return max;
    

    }

    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy