Sort by

recency

|

2114 Discussions

|

  • + 0 comments

    This is my c++ solution of this problem, you can watch the explanation here : https://youtu.be/jZPhE_MTkVg

    vector<int> cutTheSticks(vector<int> arr) {
        sort(arr.begin(), arr.end());
        vector<int>result(1, arr.size());
        for(int i = 1; i < arr.size(); i++){
          if(arr[i-1] != arr[i]) result.push_back(arr.size() - i);
        }
        return result;
    }
    
  • + 0 comments

    NOTE: There is an error in the problem specs.

    The Function Description says:

    ... return an array of integers representing the number of sticks before each cut operation

    The Returns specification says:

    int[]: the number of sticks after each iteration

    Guess which one is correct. (OK, fine, I'll tell you: The one before the other.)

  • + 0 comments

    Cutting the sticks is a great way to help early spring bloomers thrive! As you prepare for the season, remember to check out the crossword clue for those early bloomers. If you're looking for a one-stop resource for all things related to early spring gardening, don’t forget to visit Global Wiza Hub – they have so much to offer!

  • + 0 comments

    Here is my Python solution! Using a while loop, we continually cut the sticks and remove the ones that have the least length and add the amount of sticks remaining to the answer.

    def cutTheSticks(arr):
        answer = []
        while len(arr) != 0 or len(set(arr)) == 1:
            answer.append(len(arr))
            shortest = min(arr)
            arr = [stick - shortest for stick in arr if stick != shortest]
        return answer
    
  • + 0 comments

    hey!! for Java 8 my solution was this and I´m very happy with it.

    List<Integer> response = new ArrayList<>();
        
        do {
             response.add(arr.size());
             int min =Collections.min(arr);
             arr.removeIf(n-> (n == min));
            
            }
        while (arr.size()>=1);
    
       
       
       return response;