diff options
Diffstat (limited to 'microposts/ia-lawsuit.md~')
-rw-r--r-- | microposts/ia-lawsuit.md~ | 17 |
1 files changed, 0 insertions, 17 deletions
diff --git a/microposts/ia-lawsuit.md~ b/microposts/ia-lawsuit.md~ deleted file mode 100644 index e3e0f9c..0000000 --- a/microposts/ia-lawsuit.md~ +++ /dev/null @@ -1,17 +0,0 @@ ---- -date: 2018-06-04 ---- - -The [Boyer-Moore algorithm for finding the majority of a sequence of elements](https://en.wikipedia.org/wiki/Boyer–Moore_majority_vote_algorithm) falls in the category of "very clever algorithms". - - int majorityElement(vector<int>& xs) { - int count = 0; - int maj = xs[0]; - for (auto x : xs) { - if (x == maj) count++; - else if (count == 0) maj = x; - else count--; - } - return maj; - } - |