Permuting Two Arrays

  • + 0 comments

    in c#

    public static string twoArrays(int k, List<int> A, List<int> B)
    {
        var minValueInA = A.Order().FirstOrDefault();
        var minValueInACount = A.Count(x => x == minValueInA);
    
        var requiredNum = k - minValueInA;
    
        var numCountInB = B.Count(x => x >= requiredNum);
        if (minValueInACount > numCountInB) {
            return "NO";
        }
        return "YES";
    }