Sort by

recency

|

83 Discussions

|

  • + 0 comments

    knapsack, ez

    O(G * N)

    string indianJob(int G, const vector<int>& A) {
        int M = 0, sum = 0;
        for (int x : A) sum = sum + x;
        vector<vector<bool>> cache(G+1, vector<bool>(A.size()+1));
        for (int j=0; j <= A.size(); j++) cache[0][j] = true;
        for (int i=1; i <= G; i++) {
            for (int j=1; j <= A.size(); j++) {
                (i >= A[j-1]) ? cache[i][j] = cache[i][j-1] or cache[i-A[j-1]][j-1] : cache[i][j] = cache[i][j-1];
                if (cache[i][j]) M = max(M, i);
            }
        }
        return (sum - M <= G) ? "YES" : "NO";
    }
    
  • + 0 comments

    hey good one

  • + 0 comments

    Here is my solution in java, javascript, python, C, C++, csharp HackerRank The Indian Job Problem Solution

  • + 0 comments

    4 line Python, 100%

    Low constraints allow to check all possible sums.

    def _indianJob(g, arr):
        s, sums = sum(arr), [1] + [0] * 10000
        for i in arr:
            sums = sums[0:i] + [sums[x] or sums[x-i] for x in range(i,s+1)]
        return any([i<=g and s-i<=g for i in [i for i in range(s+1) if sums[i]]])
            
    
    def indianJob(g, arr):
        return "YES" if _indianJob(g, arr) else "NO"
    
  • + 0 comments

    Maintaining the grow tent is crucial for the health of your plants. Here are some tips to keep in mind. Monitor the temperature and humidity levels: The ideal temperature for most plants is between 70-85°F (21-29°C) during the day and 60-70°F (15-21°C) at night. The humidity level should range between 40-60%. see this