<commit_before>/**
 * https://leetcode.com/problems/compare-version-numbers/
 * 
 * 
 */ 
class Solution {
    func compareVersion(_ version1: String, _ version2: String) -> Int {
        let v1 = version1.components(separatedBy: ".").map({Int($0)!})
        let v2 = version2.components(separatedBy: ".").map({Int($0)!})
        let n = max(v1.count, v2.count)
        for i in 0..<n {
            var a = 0
            var b = 0
            if i < v1.count { a = v1[i] }
            if i < v2.count { b = v2[i] }
            if a < b {
                return -1
            } else if a > b {
                return 1
            }
        }
        return 0
    }
}<commit_msg>Add compare-version-numbers.swift<commit_after>/**
 * https://leetcode.com/problems/compare-version-numbers/
 * 
 * 
 */ 
class Solution {
    func compareVersion(_ version1: String, _ version2: String) -> Int {
        let v1 = version1.components(separatedBy: ".").map({Int($0)!})
        let v2 = version2.components(separatedBy: ".").map({Int($0)!})
        let n = max(v1.count, v2.count)
        for i in 0..<n {
            var a = 0
            var b = 0
            if i < v1.count { a = v1[i] }
            if i < v2.count { b = v2[i] }
            if a < b {
                return -1
            } else if a > b {
                return 1
            }
        }
        return 0
    }
}
/**
 * https://leetcode.com/problems/compare-version-numbers/
 * 
 * 
 */ 
// Date: Wed Sep  9 08:06:14 PDT 2020
class Solution {
    /// - Complexity:
    ///     - Time Complexity: O(max(n, m))
    ///     - Space Complexity: O(max(n, m))
    func compareVersion(_ version1: String, _ version2: String) -> Int {
        // - Time Complexity: O(n)
        // - Space Complexity: O(n)
        var v1 = version1.split(separator: ".").map { Int($0)! }
        // - Time Complexity: O(m)
        // - Space Complexity: O(m)
        var v2 = version2.split(separator: ".").map { Int($0)! }
        let n = max(v1.count, v2.count)
        // - Space Complexity: O(max(n, m))
        if v1.count < n {
            v1 += Array(repeating: 0, count: n - v1.count)
        } else {
            v2 += Array(repeating: 0, count: n - v2.count)
        }
        var index = 0
        // - Time Complexity: O(max(n, m))
        while index < v1.count {
            if v1[index] != v2[index] {
                if v1[index] < v2[index] { return -1 }
                return 1
            }
            index += 1
        }
        return 0
    }
}
{'fraction_non_alphanumeric': 0.15304902351534475, 'fraction_numerical': 0.031088082901554404, 'mean_word_length': 1.3904761904761904, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 8, 'https://': 3, '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': '5306110', 'n_tokens_mistral': 896, 'n_tokens_neox': 831, 'n_words': 209}