<commit_before>//: Playground - noun: a place where people can play

import UIKit

/*:
 
 Write a function that checks if a string is a palindrome.
 
 
    "nan" is a palindrome, "a" is apalindrome, "nat" is not a palindrome
 
 
 
 Input    output
 
 nat	   false
 
 nan       true
 
 oacocao   true
 
 ""        true
 
 Brainstorming solutions
 
 Hash table: O(n) - time
             O(n) - space
 

 Two variables to traverse the array from start to end and from end to start.<commit_msg>Added a more efficient solution for camel case string word counter<commit_after>//: Playground - noun: a place where people can play

import UIKit

/*:
 Write a function that counts the number of words in a camelCase string.
 
    input:    							output:
 
	albertoVegaGonzalez                     3
	one										1
    twoWords								2
    ""										0
    nil										0
 
 
 Check each character for uppercase

 O(N) - time
 O(1) - space


 */

let camelCaseString = "twoWords"
let stringCharacters = String(camelCaseString).characters.map{ String($0) }

func countCamelCaseWords(string: String?) -> Int {
    if string == "" || string == nil {
        return 0
    }
    
    var counter = 1
    let charArray = string?.unicodeScalars.map {$0}
    let upperCase = NSCharacterSet.uppercaseLetters

    guard let characters = charArray else {
        return 0
    }
    
    for character in characters {
        
        if upperCase.contains(character) {
            counter += 1
        }
    }
    return counter
}

print(countCamelCaseWords(string: "albertoVega"))

/*:
 
 Write a function that checks if a string is a palindrome.
 
 
    "nan" is a palindrome, "a" is apalindrome, "nat" is not a palindrome
 
 
 
 Input    output
 
 nat	   false
 
 nan       true
 
 oacocao   true
 
 ""        true
 
 Brainstorming solutions
 
 Hash table: O(n) - time
             O(n) - space
 

 Two variables to traverse the array from start to end and from end to start.
{'fraction_non_alphanumeric': 0.0693523712391637, 'fraction_numerical': 0.006119326874043855, 'mean_word_length': 2.046583850931677, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '3082612', 'n_tokens_mistral': 678, 'n_tokens_neox': 566, 'n_words': 220}