Ad

Used lambda in python

Code
Diff
  • output_array = lambda inp: [min(inp),max(inp)]
    
    • interface HighLow {
    • static int[] findLargestAndSmallest(int[] nums) {
    • // Change min and max below to be the highest and lowest values
    • // in the nums array provided to the function
    • int min = 0;
    • int max = 100;
    • return new int[]{min, max};
    • }
    • }
    • output_array = lambda inp: [min(inp),max(inp)]
Code
Diff
  • is_leap = lambda n:(n%400==0 or (n%4==0 and n%100!=0))
    • def is_leap_year(year: str) -> bool:
    • """Returns True if year is a Leap Year else False."""
    • case1: bool = year % 4 == 0
    • case2: bool = year % 100 == 0
    • case3: bool = year % 400 == 0
    • return case1 and not case2 or case3
    • is_leap = lambda n:(n%400==0 or (n%4==0 and n%100!=0))
Code
Diff
  • def days(month, day):
        months=[28 if x==2 else 31 if ((x<8 and x%2!=0) or (x>7 and x%2==0)) else 30 for x in range(1,13)]
        return sum(months[0:month-1])+day
    
    • int days(int month, int day) {
    • int i;
    • int count = 0;
    • int v[12]={31,28,31,30,31,30,31,31,30,31,30,31};
    • for(i=0;i<month-1;i++) {
    • count+=v[i];
    • }
    • count = count + day;
    • return count;
    • }
    • def days(month, day):
    • months=[28 if x==2 else 31 if ((x<8 and x%2!=0) or (x>7 and x%2==0)) else 30 for x in range(1,13)]
    • return sum(months[0:month-1])+day