(defn repeated-string [s n]
"Complexity: O(n), (= n (count s))
TOC: ~26 min"
(let [string-seq (seq s)
indices-in-single-string (keep-indexed #(if (= %2 \a) %1) string-seq)
num-a-in-single-string (-> (filter #(= % \a) string-seq)
;; looked up counting occurences of \a online
count
)] ;; looked up keep-indexed online. looked up apply max online
(-> num-a-in-single-string
(* (quot n (count string-seq)))
(+ (count (filter #(> (rem n (count string-seq)) %) indices-in-single-string)))
)))
(repeated-string "aba" 10)