You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**This below small code snippet checks whether a given number is a prime number or not*/
45
+
staticbooleanmethod(intn) {
46
+
if (n < 2) {
47
+
returnfalse;
48
+
}
49
+
for (inti = 2; i < n; i++) {
50
+
if (n % i == 0) {
51
+
// System.out.print("n = " + n + ", " + "i = " + i + "\t");
52
+
returnfalse;
53
+
}
54
+
}
55
+
returntrue;
33
56
}
34
57
58
+
59
+
35
60
/**
36
61
* Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules:
37
62
* 1. one left parenthesis must have a corresponding right parenthesis
0 commit comments