development

Quicksort in C++

// cat quicksort.cc #include <bits/stdc++.h> #include <algorithm> // std::swap using namespace std; int partition(int arr[], int low, int high); void qsort(int arr[], int start, int end) { int p; if (start < end) { p = partition(arr, start, end); qsort(arr, start, p – 1); qsort(arr, p + 1, end); } } int partition(int arr[], int […]

Read more
development

Codility: Maxed Counters Problem

Problem You are given N counters, initially set to 0, and you have two possible operations on them: > – _increase(X)_ − counter X is increased by 1, > – _max counter_ − all counters are set to the maximum value of any counter. A non-empty array A of M integers is given. This array […]

Read more