Refactored all solutions
This commit is contained in:
@@ -4,18 +4,16 @@
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
/* O(n) runtime. O(1) space. Uses XOR. Keep in mind:
|
||||
1) x ^ x = 0
|
||||
2) x ^ 0 = x
|
||||
3) XOR is commutative and associative
|
||||
*/
|
||||
// O(n) runtime. O(1) space. Uses XOR. Keep in mind:
|
||||
// 1) x ^ x = 0
|
||||
// 2) x ^ 0 = x
|
||||
// 3) XOR is commutative and associative
|
||||
public class Solution {
|
||||
|
||||
public static void main(String[] args) {
|
||||
/* Read input */
|
||||
public static void main(String [] args) {
|
||||
/* Save input */
|
||||
Scanner scan = new Scanner(System.in);
|
||||
int n = scan.nextInt();
|
||||
int array[] = new int[n];
|
||||
int [] array = new int[n];
|
||||
for(int i = 0; i < n; i++){
|
||||
array[i] = scan.nextInt();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user