This file contains hidden or 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
| public class ArraySort { | |
| public static void main(String[] args) { | |
| int[] array = {1, 3, 1, 2, 5, 2, 1, 3}; | |
| sort(array); | |
| for (int i : array) { | |
| System.out.print(i + " "); | |
| } |
This file contains hidden or 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.HashMap; | |
| import java.util.Map; | |
| public class MatchingChars { | |
| public static void main(String[] args) { | |
| String firstStr = "abca"; | |
| String secondStr = "deaf"; | |
| String rslt = matchingChar(firstStr, secondStr); |
This file contains hidden or 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
| public class Numbers { | |
| public static void main(String[] args) { | |
| for (int i = 1; i <= 100 ; i++) { | |
| if(i % 3 == 0){ | |
| System.out.println("git"); | |
| }else if(i % 5 == 0){ | |
| System.out.println("hub"); | |
| }else { | |
| System.out.println(i); |
This file contains hidden or 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
| Below are the Big O performance of common functions of different Java Collections. | |
| List | Add | Remove | Get | Contains | Next | Data Structure | |
| ---------------------|------|--------|------|----------|------|--------------- | |
| ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
| LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
| CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array |