<commit_before>﻿using System.Collections.Generic;

namespace Algorithms.RobertSedgewick.Analysis
{
    public static class TwoSum
    {
        public static int Quick(List<int> source)
        {
            int result = 0;
            source.Sort();
            for (int i = 0; i < source.Count; i++)
            {
                int searchValue = -source[i];
                if (source.BinarySearch(searchValue) > i)
                {
                    result++;
                }
            }
            return result;
        }

        public static int Slow(List<int> source)
        {
            int result = 0;
            for (int i = 0; i < source.Count; i++)
            {
                for (int j = i + 1; j < source.Count; j++)
                {
                    if (source[i] + source[j] == 0)
                    {
                        result++;
                    }
                }
            }
            return result;
        }
    }
}
<commit_msg>* TwoSum.cs improved Quick. Current order of growth is MLogN where M - count of negative values<commit_after>﻿using System.Collections.Generic;

namespace Algorithms.RobertSedgewick.Analysis
{
    public static class TwoSum
    {
        public static int Quick(List<int> source)
        {
            int result = 0;
            source.Sort();
            for (int i = 0; i < source.Count; i++)
            {
                if (source[i] > 0)
                {
                    return result;
                }
                int searchValue = -source[i];
                if (source.BinarySearch(searchValue) > i)
                {
                    result++;
                }
            }
            return result;
        }

        public static int Slow(List<int> source)
        {
            int result = 0;
            for (int i = 0; i < source.Count; i++)
            {
                for (int j = i + 1; j < source.Count; j++)
                {
                    if (source[i] + source[j] == 0)
                    {
                        result++;
                    }
                }
            }
            return result;
        }
    }
}

{'fraction_non_alphanumeric': 0.09722222222222222, 'fraction_numerical': 0.0060185185185185185, 'mean_word_length': 0.9225978647686833, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6340391', 'n_tokens_mistral': 586, 'n_tokens_neox': 538, 'n_words': 146}