package com.fishercoder.solutions;

import java.util.ArrayList;
import java.util.List;

/**
 * 1213. Intersection of Three Sorted Arrays
 *
 * Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order,
 * return a sorted array of only the integers that appeared in all three arrays.
 *
 * Example 1:
 * Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8]
 * Output: [1,5]
 * Explanation: Only 1 and 5 appeared in the three arrays.
 *
 * Constraints:
 *
 * 1 <= arr1.length, arr2.length, arr3.length <= 1000
 * 1 <= arr1[i], arr2[i], arr3[i] <= 2000
 * */
public class _1213 {
    public static class Solution1 {
        /**credit: https://leetcode.com/problems/intersection-of-three-sorted-arrays/discuss/397603/Simple-Java-solution-beats-100*/
        public List<Integer> arraysIntersection(int[] arr1, int[] arr2, int[] arr3) {
            List<Integer> result = new ArrayList();
            int i = 0;
            int j = 0;
            int k = 0;
            while (i < arr1.length && j < arr2.length && k < arr3.length) {
                if (arr1[i] == arr2[j] && arr1[i] == arr3[k]) {
                    result.add(arr1[i]);
                    i++;
                    j++;
                    k++;
                } else if (arr1[i] < arr2[j]) {
                    i++;
                } else if (arr2[j] < arr3[k]) {
                    j++;
                } else {
                    k++;
                }
            }
            return result;
        }
    }
}

@@ -85,514 +85,8 @@
 t;%0A%0A
-/**%0A * 1213. Intersection of Three Sorted Arrays%0A *%0A * Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order,%0A * return a sorted array of only the integers that appeared in all three arrays.%0A *%0A * Example 1:%0A * Input: arr1 = %5B1,2,3,4,5%5D, arr2 = %5B1,2,5,7,9%5D, arr3 = %5B1,3,4,5,8%5D%0A * Output: %5B1,5%5D%0A * Explanation: Only 1 and 5 appeared in the three arrays.%0A *%0A * Constraints:%0A *%0A * 1 %3C= arr1.length, arr2.length, arr3.length %3C= 1000%0A * 1 %3C= arr1%5Bi%5D, arr2%5Bi%5D, arr3%5Bi%5D %3C= 2000%0A * */%0A
 publ
@@ -149,16 +149,28 @@
      /**
+%0A         * 
 credit: 
@@ -280,16 +280,26 @@
 eats-100
+%0A         
 */%0A     

refactor 1213