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
intn = nums.length; //Creates a variable named n that is the length of nums
14
-
int[] ans = newint[2 * n]; //Creates a new array that is double the size of n.
14
+
intn = nums.length; //Creates a variable named n that is the length of nums
15
+
int[] ans = newint[2 * n]; //Creates a new array that is double the size of n.
15
16
16
-
17
-
for (inti = 0; i < n; ++i) {
18
-
ans[i] = nums[i]; //Gets the first half of the int array
19
-
ans[i + n] = nums[i]; //Gets the second half of the int array
20
-
}
21
-
returnans;
17
+
for (inti = 0; i < n; ++i) {
18
+
ans[i] = nums[i]; // Gets the first half of the int array
19
+
ans[i + n] = nums[i]; // Gets the second half of the int array
22
20
}
21
+
returnans;
22
+
}
23
23
24
-
25
-
publicstaticvoidmain(String[] args) {
26
-
27
-
//Creates an instance of the solution class
28
-
//We need this because getConcatenation() is a method that is non-static meaning we need and object of Solution to use it.
29
-
//This would be unneeded if getConcatenation() was static
30
-
24
+
publicstaticvoidmain(String[] args) {
31
25
32
-
int[] nums = {1, 2, 3, 4}; //Array of nums based on Test input
33
-
int[] result = getConcatenation(nums); //calls the getConcatenation method giving it the array of nums.
26
+
// Creates an instance of the solution class
27
+
// We need this because getConcatenation() is a method that is non-static meaning we need and
28
+
// object of Solution to use it.
29
+
// This would be unneeded if getConcatenation() was static
34
30
31
+
int[] nums = {1, 2, 3, 4}; // Array of nums based on Test input
32
+
int[] result =
33
+
getConcatenation(nums); // calls the getConcatenation method giving it the array of nums.
35
34
36
-
//Prints result out.
35
+
// Prints result out.
37
36
38
-
//You need to loop out the result because we want to display the contents of an array which means we need to call each instance in it. This is easily done by using the for else loop to run until it is returned false.
39
-
for (intnum: result) {
40
-
System.out.print(num + " ");
41
-
}
37
+
// You need to loop out the result because we want to display the contents of an array which
38
+
// means we need to call each instance in it. This is easily done by using the for else loop to
39
+
// run until it is returned false.
40
+
for (intnum : result) {
41
+
System.out.print(num + " ");
42
42
}
43
-
}
44
43
44
+
String[] words = {
45
+
"leet", "code", "hello", "world"
46
+
}; // Creates an Array named words that contains a series of strings.
45
47
48
+
charx = 'e'; // Calls for a specific char
49
+
System.out.println(findWordsContaining(words, x)); // Prints out findWordsContaining method
0 commit comments