Sort by

recency

|

26 Discussions

|

  • + 0 comments

    Here is my solution in java, javascript, python, C, C++, Csharp HackerRank Superman Celebrates Diwali Solution

  • + 0 comments

    Here is superman Celebrates Diwali problem solution - https://programs.programmingoneonone.com/2021/07/hackerrank-superman-celebrates-diwali-problem-solution.html

  • + 0 comments

    I don't understand what input/output logic expected. Every previous task provides function name and parameters. Here we don't have anything

  • + 0 comments

    typical dp problem with some tricky manipulation. Here is my python solution:

    import collections
    
    
    n,h,ii = map(int, input().split())
    dp = [[0]*h for _ in range(n)]
    for i in range(n):
        x = list(map(int, input().split()))
        for j in x[1:]: dp[i][j-1] += 1
    last = collections.deque()
    for j in range(h):
        x = last.popleft() if j >= ii else 0
        for i in range(n):
            dp[i][j] += max(0 if j == 0 else dp[i][j-1], x)
        last.append(max(k[j] for k in dp))
    print(max(k[-1] for k in dp))
    
  • + 0 comments

    import java.io.IOException; import java.io.InputStream;

    public class Solution {

    public static void main(String[] args) throws IOException {
        InputReader reader = new InputReader(System.in);
        int N = reader.readInt();
        int H = reader.readInt();
        int I = reader.readInt();
    

    int[][] people = new int[N][H]; for (int n=0; n

    } int[][] save = new int[N][H]; int[] max = new int[H]; for (int n=0; n

    } for (int h=1; h= I) { value = Math.max(value, max[h-I]);

    } value += people[n][h]; maxPeople = Math.max(maxPeople, value); save[n][h] = value; } max[h] = maxPeople;

    } int answer = 0; for (int n=0; n

    static final class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
    
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
    
    
        private int read() throws IOException {
            if (curChar >= numChars) {
                curChar = 0;
                numChars = stream.read(buf);
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
    
                }
    
        public final int readInt() throws IOException {
            return (int)readLong();
    
                }
    
        public final long readLong() throws IOException {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1) throw new IOException();
    
                }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
    
    
                }
            long res = 0;
            do {
                res *= 10;
                res += c - '0';
    
    
                c = read();
            } while (!isSpaceChar(c));
            return negative ? -res : res;
    
                }
    
        public final int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i=0; i<size; i++) {
                array[i] = readInt();
            }
            return array;
    
                }
    
        public final long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i=0; i<size; i++) {
                array[i] = readLong();
            }
            return array;
        }
    
    
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
    

    }