Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d5db4c5

Browse files
minor code addition
1 parent 275f12c commit d5db4c5

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/main/java/com/fishercoder/solutions/_99999RandomQuestions.java

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,40 @@ public static void main(String... args) {
2323
// int[] nums = new int[]{-1, -2, 1,2,3,-1, -2};
2424
// List<int[]> result = subarraySum_v2(nums);
2525

26-
System.out.println(rollingString("abc", new String[]{"0 0 L", "2 2 L", "0 2 R"}));
26+
// System.out.println(rollingString("abc", new String[]{"0 0 L", "2 2 L", "0 2 R"}));
27+
//
28+
// GetMovies getMovies = new GetMovies();
29+
// System.out.println(getMovies.getMovieTitles("spiderman"));
30+
//
31+
// System.out.println(counting("00110"));
2732

28-
GetMovies getMovies = new GetMovies();
29-
System.out.println(getMovies.getMovieTitles("spiderman"));
33+
int total = 0;
34+
for (int n = 0; n < 50; n++) {
35+
if (method(n)) {
36+
total++;
37+
System.out.print(n + ", " + method(n) + "\n");
38+
}
39+
}
40+
System.out.println("total = " + total);
3041

31-
System.out.println(counting("00110"));
42+
}
3243

44+
/**This below small code snippet checks whether a given number is a prime number or not*/
45+
static boolean method(int n) {
46+
if (n < 2) {
47+
return false;
48+
}
49+
for (int i = 2; i < n; i++) {
50+
if (n % i == 0) {
51+
// System.out.print("n = " + n + ", " + "i = " + i + "\t");
52+
return false;
53+
}
54+
}
55+
return true;
3356
}
3457

58+
59+
3560
/**
3661
* 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:
3762
* 1. one left parenthesis must have a corresponding right parenthesis

0 commit comments

Comments
 (0)