Sort by

recency

|

1003 Discussions

|

  • + 0 comments

    My python solution using sort and bisect:

    def biggerIsGreater(w):
        w = [c for c in w]
        vortex = len(w)-2
        while vortex >= 0 and w[vortex] >= w[vortex+1]:
            vortex -= 1
        
        if vortex >= 0:
            w = w[:vortex+1] + sorted(w[vortex+1:])
            idx = bisect.bisect(w, w[vortex], vortex + 1, len(w))
            w[vortex], w[idx] = w[idx], w[vortex]
            return ''.join(w)
            
        return 'no answer'
    
  • + 0 comments

    I think a lot of the solutions described here are over-complicating things. I wrote a quick solution and explanation here: https://willievaldez.github.io/2026-02-20-NextLexPerm/ And yes, I consider using next_permutation cheating :)

  • + 0 comments

    Here is updated solution in python, java, c++, c and javascript programming - https://programmingoneonone.com/hackerrank-bigger-is-greater-problem-solution.html

  • + 0 comments

    c++ solution, disliking the fact that I spent a bit too long thinking about how to do this, no cause the problem explenation sucks.

    string biggerIsGreater(string w) {
        int n = w.length();
        int i = n - 2;
    
        while (i >= 0 && w[i] >= w[i + 1]) {
            i--;
        }
    
        if (i < 0) return "no answer"; 
    
        int j = n - 1;
        while (w[j] <= w[i]) {
            j--;
        }
    
        swap(w[i], w[j]);
    
        reverse(w.begin() + i + 1, w.end());
    
        return w;
    }
    
  • + 2 comments

    Composite Door Locks deliver strength, style, and advanced security, making them an ideal choice for modern homes. Built to withstand forced entry, they combine multi-point locking systems with durable materials, ensuring long-lasting protection. Easy to operate and designed to fit seamlessly with composite doors, they enhance both safety and appearance. Investing in secure locking solutions reflects the idea that Bigger is Greater, giving homeowners confidence in superior protection and peace of mind.