<commit_before>//
//  LeetCode026.swift
//  SwiftAlgorithm
//
//  Created by Phoenix on 2017/10/26.
//  Copyright © 2017年 Phoenix. All rights reserved.
//

import Foundation

extension LeetCode {
    
    // LeetCode 026 https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/
    public static func removeDuplicates(_ nums: inout [Int]) -> Int {
        if nums.isEmpty {
            return 0
        }
        
        var j = 1
        for (i, element) in nums.enumerated() {
            if i == nums.count - 1 { break }
            if element != nums[i + 1] {
                j = j + 1
            }
        }
        return j
    }
}<commit_msg>update leetcode 26<commit_after>//
//  LeetCode026.swift
//  SwiftAlgorithm
//
//  Created by Phoenix on 2017/10/26.
//  Copyright © 2017年 Phoenix. All rights reserved.
//

import Foundation

extension LeetCode {
    
    // LeetCode 026 https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/
    public static func removeDuplicates(_ nums: inout [Int]) -> Int {
        if nums.isEmpty {
            return 0
        }
        
        var j = 0
        for element in nums {
            if j == nums.count - 1 {
                break
            }
            if element != nums[j + 1] {
                j = j + 1
            }
            else {
                nums.remove(at: j + 1)
            }
        }
        return j + 1
    }
}
{'fraction_non_alphanumeric': 0.10716771050800278, 'fraction_numerical': 0.03479471120389701, 'mean_word_length': 1.3690280065897857, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '4324594', 'n_tokens_mistral': 494, 'n_tokens_neox': 440, 'n_words': 118}