<commit_before><commit_msg>Added solution for leetCode - Valid Palindrome II<commit_after>//
//  validPalindromeII.swift
//
//  Practice solution - <NAME> - 2017
//
//  Check the problem (and run the code) on leetCode @ https://leetcode.com/problems/valid-palindrome-ii/
//  Note: make sure that you select "Swift" from the top-left language menu of the code editor when testing this code
//

class Solution {
  func validPalindrome(_ input: String) -> Bool {
    let s = [Character](input)
    if s.count < 2 { return true }
    var l = 0, r = s.count - 1
    while l < r {
      if s[l] != s[r] {
        return validate(s, l+1, r) || validate(s, l, r-1)
      }
      r -= 1
      l += 1
    }
    return true
  }

  func validate(_ s: [Character], _ left: Int, _ right: Int) -> Bool {
    var l = left, r = right
    while l < r {
      if s[l] != s[r] { return false }
      l += 1
      r -= 1
    }
    return true
  }
}
{'fraction_non_alphanumeric': 0.1348435814455232, 'fraction_numerical': 0.014023732470334413, 'mean_word_length': 2.1140939597315436, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 6, 'https://': 1, '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': '7198898', 'n_tokens_mistral': 337, 'n_tokens_neox': 320, 'n_words': 110}