This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class App { | |
public static void main( String[] args ) { | |
int[] inArray = {1, 3, 3, 5, 7}; | |
int baseNum = 6; | |
System.out.println("Number List: " + Arrays.toString(inArray) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reverses a given List | |
* using Collections.reverse() method | |
* @param list | |
* @author Jon Bonso | |
*/ | |
public static void reverse(List<?> list) { | |
Collections.reverse(list); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check if the two strings are an anagram of each other. | |
* For example: LISTEN is an Anagram of SILENT. | |
* | |
* Two strings are an anagram of each other if the characters | |
* and the numbers of characters that are composing them, | |
* are exactly the same. So for example, SUE and USE are anagrams | |
* because both words have one E, one S and one U, | |
* hence: ESU = ESU. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calculates the next fibonacci sequence. | |
* | |
* To properly implement a Fibonacci sequence, | |
* we need to know the Mathematical formula first, and that is: | |
* | |
* F<sub>n</sub> = F<sub>n-1</sub> + F<sub>n-2</sub> | |
* | |
* The above formula basically reads as this: | |
* The next sequence (Fn) is the sum of the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Import HTTP Module | |
const http = require('http'); | |
const hostname = '127.0.0.1'; | |
const port = 3000; | |
// Create Server | |
const server = http.createServer((request, response) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. Will two objects with the same hashcode always be equal to each other? | |
A. Yes | |
B. No | |
C. Only when using inheritance | |
D. Two objects can never have the same hashcode | |
2. What does it mean to declare a private method as final? | |
A. It can only be called once. | |
B. It is called upon garbage collection | |
C. A subclass cannot override it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1. What's the difference between a DIV and SPAN? | |
- Span is in-line level and div is block level. | |
2. How to include the padding and border in an element's total width and height in CSS? | |
- Use Box Sizing: https://www.w3schools.com/css/css3_box-sizing.asp | |
3. How to create 2 equal DIVs? | |
4. How to change the second <li> of the list to red color? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String nums = "1 2 3 3 3 3 4 5 6 7 8 9 10"; | |
int target = 3; | |
String[] numsArray = nums.split(" "); | |
int firstIndex = 0; | |
int lastIndex = 0; | |
boolean firstIndexDone = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Arrays; | |
public class BinarySearch { | |
/** | |
* Implementation of a Binary Search Returns -1 if no match found | |
* | |
* @param sortedArray | |
* @param target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write a method that finds k-th most common element in a list. For example, kthMostCommon(new in[]{5, 4, 3, 2, 1, 5, 4, 3, 2, 5, 4, 3, 5, 4, 5},2) should return 4. In the array, element 1 occurs once, 2 twice, 3 three times, 4 fours times, and 5 five times, making element 5 the most common element in the list and 4th the second most common element, |