Sort by

recency

|

42 Discussions

|

  • + 0 comments

    if jim is out of jokes just to entertain his customers, tell jim that maybe he can sing or dance just to entertain his customer .. the real problem is how to entertain the customer .

  • + 1 comment

    100000

    12 31

    12 31

    12 31

    12 31

    12 31

    12 31 and so on for this test case how is the answer 499950000???

    12 31

    12 31

  • + 0 comments

    Yet another one-liner:

    from collections import Counter
    def solve(dates):
        return sum(math.comb(n,2) for _, n in Counter(int(str(day), base=month) for month, day in dates if all(month > int(digit) for digit in str(day))).most_common())
    
  • + 0 comments

    Java8 codes

    import java.util.HashMap;
    import java.util.Map;
    import java.util.Scanner;
    
    public class Solution {
    	public static void main(String[] args) {
    		Scanner sc = new Scanner(System.in);
    
    		Map<Integer, Integer> number2count = new HashMap<Integer, Integer>();
    		int N = sc.nextInt();
    		for (int i = 0; i < N; i++) {
    			int month = sc.nextInt();
    			int date = sc.nextInt();
    
    			if (isValid(month, date)) {
    				int number = convertToNumber(month, date);
    
    				if (!number2count.containsKey(number)) {
    					number2count.put(number, 0);
    				}
    				number2count.put(number, number2count.get(number) + 1);
    			}
    		}
    
    		long result = 0;
    		for (int count : number2count.values()) {
    			if (count > 1) {
    				result += (long) count * (count - 1) / 2;
    			}
    		}
    		System.out.println(result);
    
    		sc.close();
    	}
    
    	static boolean isValid(int month, int date) {
    		return month != 1 && String.valueOf(date).chars().allMatch(digit -> digit - '0' < month);
    	}
    
    	static int convertToNumber(int month, int date) {
    		int number = 0;
    		for (char digit : String.valueOf(date).toCharArray()) {
    			number = number * month + (digit - '0');
    		}
    		return number;
    	}
    }
    
  • + 0 comments

    This is horribly worded. The question specifies that "Two jokes (x1, y1) and (x2, y2) differ if they don't contain the same events."

    This seems to imply that if (12, 31) was in the list three times, then two of them could count as a joke, but no more times than that. But, as it turns out, all three possible pairs of those identical events should count as three separate jokes. This is not clear at all from the statement, as the jokes ((12, 31), (12, 31)) and ((12, 31), (12, 31)) contain the same events.