You are viewing a single comment's thread. Return to all comments →
unable to submit ,as one test case failed.
`import java.io.; import java.util.; interface PerformOperation { boolean check(int a); } class MyMath { public static boolean checker(PerformOperation p, int num) { return p.check(num); }
// Write your code here public PerformOperation isOdd() { return (int num) -> num % 2 ==1; } public PerformOperation isPrime (){ return (int num) -> { if(num < 2){ return false; } for(int i = 2; i*i <= num; i++) { if(num % i == 0){ return false; } } return true; }; } public PerformOperation isPalindrome(){ return (int num) -> { //343 int revNum = 0; while(num > 0){ num = num / 10; //34 3 int reminder = num % 10; // 3 4 revNum = num * 10 + reminder; } if(revNum == num){ return true; }else return false; }; }
} public c
Seems like cookies are disabled on this browser, please enable them to open this website
Java Lambda Expressions
You are viewing a single comment's thread. Return to all comments →
unable to submit ,as one test case failed.
`import java.io.; import java.util.; interface PerformOperation { boolean check(int a); } class MyMath { public static boolean checker(PerformOperation p, int num) { return p.check(num); }
// Write your code here public PerformOperation isOdd() { return (int num) -> num % 2 ==1; } public PerformOperation isPrime (){ return (int num) -> { if(num < 2){ return false; } for(int i = 2; i*i <= num; i++) { if(num % i == 0){ return false; } } return true; };
} public PerformOperation isPalindrome(){ return (int num) -> { //343 int revNum = 0; while(num > 0){ num = num / 10; //34 3 int reminder = num % 10; // 3 4 revNum = num * 10 + reminder; } if(revNum == num){ return true; }else return false; }; }
} public c