Sort by

recency

|

10 Discussions

|

  • + 0 comments
    static int lagDuration(int h1, int m1, int h2, int m2, int k)
    {
        h1=h1+k;
        m1=m1+h1*60;
        m2=m2+h2*60;
        return m1-m2;
    }
    
  • + 0 comments

    Trivial but please fix. The clock is leading not lagging. Had me confused there at the first look.

  • + 0 comments
    static int lagDuration(int h1, int m1, int h2, int m2, int k) {
            // Return an integer denoting the duration of time in minutes by which the clock has been lagging.
            int h = (h1*60) + (k*60)+m1;
            int wh = (h2*60)+m2;
            
            return Math.abs(h-wh);
        }
    
  • + 0 comments

    can you please explain

    private static final Scanner scanner = new Scanner(System.in); public static void main(String[] args) throws IOException { BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH"))); int arrCount = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])"); int[] arr = new int[arrCount]; for (int arrItr = 0; arrItr < arrCount; arrItr++) { int arrItem = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])"); arr[arrItr] = arrItem; } int k = scanner.nextInt(); scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])*"); String res = findNumber(arr, k); bufferedWriter.write(res); bufferedWriter.newLine(); bufferedWriter.close(); scanner.close(); } }

  • + 0 comments

    My solution in plain C

    #include <stdio.h>
    
    int lagDuration(int h1, int m1, int h2, int m2, int k);
    
    int lagDuration(int h1, int m1, int h2, int m2, int k) {
        int lag, t1, t2;
        t1 = (h1 + k) * 60 + m1;
        t2 = h2 * 60 + m2;
        lag = t1 - t2;
        return lag;
    }
    
    int main(void) {
        int n, index, h1, m1, h2, m2, k, lag;
        scanf("%d", &n);
        for (index = 0; index < n; index += 1) {
            scanf("%d %d %d %d", &h1, &m1, &h2, &m2);
            scanf("%d", &k);
            lag = lagDuration(h1, m1, h2, m2, k);
            printf("%d\n", lag);
        }
        return 0;
    }