Your browser is not supported. Please, update your browser or switch to a different one. Learn more about which browsers are supported.
Task description
Integers K, M and a non-empty array A consisting of N integers, not bigger than M, are given.
The leader of the array is a value that occurs in more than half of the elements of the array, and the segment of the array is a sequence of consecutive elements of the array.
You can modify A by choosing exactly one segment of length K and increasing by 1 every element within that segment.
The goal is to find all of the numbers that may become a leader after performing exactly one array modification as described above.
Write a function:
vector<int> solution(int K, int M, vector<int> &A);
that, given integers K and M and an array A consisting of N integers, returns an array of all numbers that can become a leader, after increasing by 1 every element of exactly one segment of A of length K. The returned array should be sorted in ascending order, and if there is no number that can become a leader, you should return an empty array. Moreover, if there are multiple ways of choosing a segment to turn some number into a leader, then this particular number should appear in an output array only once.
For example, given integers K = 3, M = 5 and the following array A:
A[0] = 2 A[1] = 1 A[2] = 3 A[3] = 1 A[4] = 2 A[5] = 2 A[6] = 3the function should return [2, 3]. If we choose segment A[1], A[2], A[3] then we get the following array A:
A[0] = 2 A[1] = 2 A[2] = 4 A[3] = 2 A[4] = 2 A[5] = 2 A[6] = 3and 2 is the leader of this array. If we choose A[3], A[4], A[5] then A will appear as follows:
A[0] = 2 A[1] = 1 A[2] = 3 A[3] = 2 A[4] = 3 A[5] = 3 A[6] = 3and 3 will be the leader.
And, for example, given integers K = 4, M = 2 and the following array:
A[0] = 1 A[1] = 2 A[2] = 2 A[3] = 1 A[4] = 2the function should return [2, 3], because choosing a segment A[0], A[1], A[2], A[3] and A[1], A[2], A[3], A[4] turns 2 and 3 into the leaders, respectively.
Write an efficient algorithm for the following assumptions:
- N and M are integers within the range [1..100,000];
- K is an integer within the range [1..N];
- each element of array A is an integer within the range [1..M].
Task timeline
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
for(int i = 0; i < A.size(); i++)
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
for(int i = 0; i < A.size(); i++)
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
for(int i = 0; i < copy.size(); i++)
{
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
for(int i = 0; i < copy.size(); i++)
{
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
for(int i = 0; i < copy.size(); i++)
{
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
int nNumSegs = copy.size() - K -1;
for(int i = 0; i < copy.size(); i++)
{
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
int nNumSegs = copy.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
int nNumSegs = copy.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
copy
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
int nNumSegs = copy.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
copy[i]
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
vector<int> copy = A;
int nNumSegs = copy.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
copy[i]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
copy[i]++;
copy[i+1]++;
copy[i+1]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < )
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < A.size();)
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++
{
copy[j]++;
}
c
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++)
{
copy[j]++;
}
for(int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
}
return ret;
}
324122324122341223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++)
{
copy[j]++;
}
for(int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
c
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++)
{
copy[j]++;
}
for(int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
3241223 241223 41223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(int j = i; j < K; j++)
{
copy[j]++;
}
for(int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
3241223 241223 41223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(uint j = i; j < K; j++)
{
copy[j]++;
}
for(int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(uint_32 j = i; j < K; j++)
{
copy[j]++;
}
for(uint_32 j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < nNumSegs; i++) ~~^~~~~~~~~~ func.cpp:20:12: error: 'uint_32' was not declared in this scope for(uint_32 j = i; j < K; j++) ^~~~~~~ func.cpp:20:27: error: 'j' was not declared in this scope for(uint_32 j = i; j < K; j++) ^ func.cpp:25:13: error: 'uint_32' was not declared in this scope for(uint_32 j = i; j < copy.size(); j++) ^~~~~~~ func.cpp:25:28: error: 'j' was not declared in this scope for(uint_32 j = i; j < copy.size(); j++) ^
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(uint_32 j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = i; j < copy.size(); j++)
{
cout << copy[j]++;
}
cout << "\n";
}
return ret;
}
3241223 241223 41223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = i; j < copy.size(); j++)
{
copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = i; j < copy.size(); j++)
{
copy[j]++;
cout << copy[j];
}
cout << "\n";
}
return ret;
}
4352334 352334 52334
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = i; j < copy.size(); j++)
{
copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = i; j < copy.size(); j++)
{
copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
copy[j]++;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[j];
}
cout << "\n";
}
return ret;
}
3241223 2241223 2141223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigneint i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[j];
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[j];
}
cout << "\n";
}
return ret;
}
3241223 2241223 2141223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[j];
}
cout << "\n";
}
return ret;
}
3241223 2241223 2141223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[;
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy;
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:20:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(unsigned int j = i; j < K; j++) ~~^~~ func.cpp:27:16: error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and 'std::vector<int>') cout << copy; ~~~~~^~~~~~~ In file included from /opt/lang/gcc/include/c++/6.2.0/iostream:39:0, from solution.cpp:4: /opt/lang/gcc/include/c++/6.2.0/ostream:108:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>] operator<<(__ostream_type& (*__pf)(__ostream_type&)) ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/ostream:108:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&) {aka std::basic_ostream<char>& (*)(std::basic_ostream<char>&)}' /opt/lang/gcc/include/c++/6.2.0/ostream:117:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ios_type& (*)(std::basic_ostream<_CharT, _Traits>::__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ostream<char>; std::basic_ostream<_CharT, _Traits>::__ios_type = std::basic_ios<char>] operator<<(__ios_type& (*__pf)(__ios_type&)) ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/ostream:117:7: note: no known conversion for argument 1 from 'std::vector<int>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy[j];
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at[j];
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at[j];
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:20:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(unsigned int j = i; j < K; j++) ~~^~~ func.cpp:27:28: error: invalid types '<unresolved overloaded function type>[unsigned int]' for array subscript cout << copy.at[j]; ^
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
3241223 2241223 2141223
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << K << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
3 3241223 2241223 2141223
4
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << K << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << K << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < A. K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << K << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; K; j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << K << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
3 3241223 2242223 2142323
4
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << nnUm << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K -1;
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
3 3241223 2242223 2142323
0
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K;
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - K;
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
4 3241223 2242223 2142323 2132333
1 23322
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - (K+1);
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
3 3241223 2242223 2142323
0
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - (K);
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - (K-1);
cout << nNumSegs << "\n";
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
cout << "\n";
}
return ret;
}
5 3241223 2242223 2142323 2132333 2131334
2 23322 13323
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
for(unsigned int j = 0; j < copy.size(); j++)
{
cout << copy.at(j);
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:12:5: error: 'map' was not declared in this scope map<int,int> occ; ^~~ func.cpp:12:9: error: expected primary-expression before 'int' map<int,int> occ; ^~~
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
smap<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:12:4: error: 'map' is not a member of 'std' std::map<int,int> occ; ^~~ func.cpp:12:13: error: expected primary-expression before 'int' std::map<int,int> occ; ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
for(int i = 0; i < K; )
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]] ++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
vector<int> ret;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > )
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
}
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:10:5: error: 'set' was not declared in this scope set<int> ret; ^~~ func.cpp:10:9: error: expected primary-expression before 'int' set<int> ret; ^~~ func.cpp:33:8: error: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' used without template parameters map::iterator it = occ.begin(); ^~~ func.cpp:34:14: error: 'it' was not declared in this scope while(it != occ.end()) ^~ func.cpp:38:16: error: 'ret' was not declared in this scope ret.insert(it->second); ^~~ func.cpp:45:12: error: 'ret' was not declared in this scope return ret; ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:34:8: error: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' used without template parameters map::iterator it = occ.begin(); ^~~ func.cpp:35:14: error: 'it' was not declared in this scope while(it != occ.end()) ^~ func.cpp:46:12: error: could not convert 'ret' from 'std::set<int>' to 'std::vector<int>' return ret; ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
ret
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> ret;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
ret.insert(it->second);
}
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),ret.begin(), ret.end());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:34:8: error: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' used without template parameters map::iterator it = occ.begin(); ^~~ func.cpp:35:14: error: 'it' was not declared in this scope while(it != occ.end()) ^~ func.cpp:45:20: error: 'ret' was not declared in this scope copy(s.begin(),ret.begin(), ret.end()); ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), ret.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:34:8: error: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' used without template parameters map::iterator it = occ.begin(); ^~~ func.cpp:35:14: error: 'it' was not declared in this scope while(it != occ.end()) ^~ func.cpp:47:12: error: 'ret' was not declared in this scope return ret; ^~~ In file included from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39:0, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h: In instantiation of 'static _OI std::__copy_move<<anonymous>, <anonymous>, <template-parameter-1-3> >::__copy_m(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>; bool <anonymous> = false; bool <anonymous> = false; <template-parameter-1-3> = std::bidirectional_iterator_tag]': /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:386:44: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:422:45: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:455:8: required from '_OI std::copy(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' func.cpp:45:38: required from here /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:294:16: error: assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' *__result = *__first; ~~~~~~~~~~^~~~~~~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:34:8: error: 'template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map' used without template parameters map::iterator it = occ.begin(); ^~~ func.cpp:35:14: error: 'it' was not declared in this scope while(it != occ.end()) ^~ In file included from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39:0, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h: In instantiation of 'static _OI std::__copy_move<<anonymous>, <anonymous>, <template-parameter-1-3> >::__copy_m(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>; bool <anonymous> = false; bool <anonymous> = false; <template-parameter-1-3> = std::bidirectional_iterator_tag]': /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:386:44: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:422:45: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:455:8: required from '_OI std::copy(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' func.cpp:45:38: required from here /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:294:16: error: assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' *__result = *__first; ~~~~~~~~~~^~~~~~~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
In file included from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39:0, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h: In instantiation of 'static _OI std::__copy_move<<anonymous>, <anonymous>, <template-parameter-1-3> >::__copy_m(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>; bool <anonymous> = false; bool <anonymous> = false; <template-parameter-1-3> = std::bidirectional_iterator_tag]': /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:386:44: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:422:45: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:455:8: required from '_OI std::copy(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' func.cpp:45:38: required from here /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:294:16: error: assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' *__result = *__first; ~~~~~~~~~~^~~~~~~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
// copy(s.begin(),s.begin(), s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.begin(), s.end());
return ret;
}
In file included from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39:0, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h: In instantiation of 'static _OI std::__copy_move<<anonymous>, <anonymous>, <template-parameter-1-3> >::__copy_m(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>; bool <anonymous> = false; bool <anonymous> = false; <template-parameter-1-3> = std::bidirectional_iterator_tag]': /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:386:44: required from '_OI std::__copy_move_a(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:422:45: required from '_OI std::__copy_move_a2(_II, _II, _OI) [with bool _IsMove = false; _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:455:8: required from '_OI std::copy(_II, _II, _OI) [with _II = std::_Rb_tree_const_iterator<int>; _OI = std::_Rb_tree_const_iterator<int>]' func.cpp:45:38: required from here /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:294:16: error: assignment of read-only location '__result.std::_Rb_tree_const_iterator<_Tp>::operator*<int>()' *__result = *__first; ~~~~~~~~~~^~~~~~~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.end, s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.end, ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:45:38: error: invalid use of non-static member function 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::end() const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::set<_Key, _Compare, _Alloc>::iterator = std::_Rb_tree_const_iterator<int>]' copy(s.begin(),s.end, ret.begin()); ^ In file included from /opt/lang/gcc/include/c++/6.2.0/set:61:0, from func.cpp:4: /opt/lang/gcc/include/c++/6.2.0/bits/stl_set.h:326:7: note: declared here end() const _GLIBCXX_NOEXCEPT ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[copy[j]] = ;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
inserting inserting inserting inserting inserting inserting
Segmentation Faultstdout:
inserting inserting inserting inserting inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
/occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
cout << "\n"
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
cout << "\n";
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
0 1 2 1 2 3 2 3 4 3 4 5 4 5 6
0 1 2 3 1 2 3 4
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
cout << "\n";
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
cout << "\n";
//occ[j] = copy[j];
}
cout << "\n";
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
0 1 2 1 2 3 2 3 4 3 4 5 4 5 6
0 1 2 3 1 2 3 4
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
cout << "\n";
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K -1); j++)
{
copy[j]++;
cout << j;
//occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
0112233445
012123
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K -1); j++)
{
copy[j]++;
cout << j;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
0112inserting 23inserting 34inserting 45inserting
Segmentation Faultstdout:
012inserting inserting 123inserting inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K -1); j++)
{
copy[j]++;
cout << j;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
0112inserting 23inserting 34inserting 45inserting
Segmentation Faultstdout:
012inserting inserting 123inserting inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K ); j++)
{
copy[j]++;
cout << j;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
012inserting 123inserting 234inserting 345inserting 456inserting inserting
Segmentation Faultstdout:
0123inserting inserting 1234inserting inserting inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
copy[j]++;
cout << j;
occ[j] = copy[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
std::map<int,int> occ;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++
cout << j;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < M; i++)
{
occ[i] = 0;
}
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
std::map<int,int> occ;
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++
cout << j;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++
cout << j;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:28:11: error: 'occ' was not declared in this scope occ[j]++ ^~~ func.cpp:34:36: error: 'occ' was not declared in this scope map<int,int>::iterator it = occ.begin(); ^~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++
cout << j;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:29:11: error: expected ';' before 'cout' cout << j; ^~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++;
cout << j;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++;
cout << occ[j];
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
111221321321321
11112221
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[j]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
inserting inserting inserting inserting inserting inserting
Segmentation Faultstdout:
inserting inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + K); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
copy(s.begin(),s.end(), ret.begin());
return ret;
}
Segmentation Faultstdout:
inserting inserting inserting
Segmentation Faultstdout:
inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
/ copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
inserting inserting inserting
inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = occ.begin();
while(it != occ.end())
{
ret.inser
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = occ.begin();
while(it != occ.end())
{
ret.insert(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:43:38: error: conversion from 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' to non-scalar type 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}' requested set<int>::iterator it = occ.begin(); ~~~~~~~~~^~ func.cpp:44:14: error: no match for 'operator!=' (operand types are 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}' and 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}') while(it != occ.end()) ~~~^~~~~~~~~~~~ In file included from /opt/lang/gcc/include/c++/6.2.0/map:60:0, from func.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:320:7: note: candidate: bool std::_Rb_tree_const_iterator<_Tp>::operator!=(const _Self&) const [with _Tp = int; std::_Rb_tree_const_iterator<_Tp>::_Self = std::_Rb_tree_const_iterator<int>] operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:320:7: note: no known conversion for argument 1 from 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' to 'const _Self& {aka const std::_Rb_tree_const_iterator<int>&}' In file included from /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:64:0, from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: template argument deduction/substitution failed: func.cpp:44:25: note: 'std::set<int>::iterator {aka std::_Rb_tree
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it2 = occ.begin();
while(it != occ.end())
{
ret.insert(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it2 = occ.begin();
while(it2 != occ.end())
{
ret.insert(*it2);
it2++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:43:39: error: conversion from 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' to non-scalar type 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}' requested set<int>::iterator it2 = occ.begin(); ~~~~~~~~~^~ func.cpp:44:15: error: no match for 'operator!=' (operand types are 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}' and 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}') while(it2 != occ.end()) ~~~~^~~~~~~~~~~~ In file included from /opt/lang/gcc/include/c++/6.2.0/map:60:0, from func.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:320:7: note: candidate: bool std::_Rb_tree_const_iterator<_Tp>::operator!=(const _Self&) const [with _Tp = int; std::_Rb_tree_const_iterator<_Tp>::_Self = std::_Rb_tree_const_iterator<int>] operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:320:7: note: no known conversion for argument 1 from 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' to 'const _Self& {aka const std::_Rb_tree_const_iterator<int>&}' In file included from /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:64:0, from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: template argument deduction/substitution failed: func.cpp:44:26: note: 'std::set<int>::iterator {aka std::_Rb_
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
ret.insert(*it2);
it2++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.insert(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:47:23: error: no matching function for call to 'std::vector<int>::insert(const int&)' ret.insert(*it); ^ In file included from /opt/lang/gcc/include/c++/6.2.0/vector:69:0, from solution.cpp:8: /opt/lang/gcc/include/c++/6.2.0/bits/vector.tcc:107:5: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int] vector<_Tp, _Alloc>:: ^~~~~~~~~~~~~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/vector.tcc:107:5: note: candidate expects 2 arguments, 1 provided In file included from /opt/lang/gcc/include/c++/6.2.0/vector:64:0, from solution.cpp:8: /opt/lang/gcc/include/c++/6.2.0/bits/stl_vector.h:1015:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int] insert(const_iterator __position, value_type&& __x) ^~~~~~ /opt/lang/gcc/include/c++/
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.insert(it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:47:22: error: no matching function for call to 'std::vector<int>::insert(std::set<int>::iterator&)' ret.insert(it); ^ In file included from /opt/lang/gcc/include/c++/6.2.0/vector:69:0, from solution.cpp:8: /opt/lang/gcc/include/c++/6.2.0/bits/vector.tcc:107:5: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int] vector<_Tp, _Alloc>:: ^~~~~~~~~~~~~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/vector.tcc:107:5: note: candidate expects 2 arguments, 1 provided In file included from /opt/lang/gcc/include/c++/6.2.0/vector:64:0, from solution.cpp:8: /opt/lang/gcc/include/c++/6.2.0/bits/stl_vector.h:1015:7: note: candidate: std::vector<_Tp, _Alloc>::iterator std::vector<_Tp, _Alloc>::insert(std::vector<_Tp, _Alloc>::const_iterator, std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::iterator = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; typename std::_Vector_base<_Tp, _Alloc>::pointer = int*; std::vector<_Tp, _Alloc>::const_iterator = __gnu_cxx::__normal_iterator<const int*, std::vector<int> >; typename __gnu_cxx::__alloc_traits<typename std::_Vector_base<_Tp, _Alloc>::_Tp_alloc_type>::const_pointer = const int*; std::vector<_Tp, _Alloc>::value_type = int] insert(const_iterator __position, value_type&& __x) ^~~~~~ /opt/lang/gcc/
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->second);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
inserting inserting inserting
inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->firs);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->first);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
inserting inserting inserting
inserting
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->first);
}
it++;
}
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
cout << "inserting\n";
s.insert(it->first);
}
it++;
}
}
co
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
while(it != occ.end())
{
cout occ[]
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
while(it != occ.end())
{
cout << it->first;
it++;
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:45:11: error: 'it' was not declared in this scope while(it != occ.end()) ^~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
cout << it->first;
it++;
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:53:24: error: conflicting declaration 'std::set<int>::iterator it' set<int>::iterator it = s.begin(); ^~ func.cpp:44:28: note: previous declaration as 'std::map<int, int>::iterator it' map<int,int>::iterator it = occ.begin(); ^~ func.cpp:54:14: error: no match for 'operator!=' (operand types are 'std::map<int, int>::iterator {aka std::_Rb_tree_iterator<std::pair<const int, int> >}' and 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}') while(it != s.end()) ~~~^~~~~~~~~~ In file included from /opt/lang/gcc/include/c++/6.2.0/map:60:0, from func.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:241:7: note: candidate: bool std::_Rb_tree_iterator<_Tp>::operator!=(const _Self&) const [with _Tp = std::pair<const int, int>; std::_Rb_tree_iterator<_Tp>::_Self = std::_Rb_tree_iterator<std::pair<const int, int> >] operator!=(const _Self& __x) const _GLIBCXX_NOEXCEPT ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_tree.h:241:7: note: no known conversion for argument 1 from 'std::set<int>::iterator {aka std::_Rb_tree_const_iterator<int>}' to 'const _Self& {aka const std::_Rb_tree_iterator<std::pair<const int, int> >&}' In file included from /opt/lang/gcc/include/c++/6.2.0/bits/stl_algobase.h:64:0, from /opt/lang/gcc/include/c++/6.2.0/bits/char_traits.h:39, from /opt/lang/gcc/include/c++/6.2.0/string:40, from solution.cpp:3: /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: candidate: template<class _T1, class _T2> constexpr bool std::operator!=(const std::pair<_T1, _T2>&, const std::pair<_T1, _T2>&) operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) ^~~~~~~~ /opt/lang/gcc/include/c++/6.2.0/bits/stl_pair.h:376:5: note: template argument deduction/substitution failed: func.cpp:54:23: note: 'std::map<int, int>::iterator
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
map<int,int>::iterator it2 = occ.begin();
while(it != occ.end())
{
cout << it->first;
it++;
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
map<int,int>::iterator it2 = occ.begin();
while(it2 != occ.end())
{
cout << it2->first;
it2++;
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
123
12
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
vector<int> ret;
map<int,int> occ;
unsigned int nNumSegs = A.size() - (K-1);
for(unsigned int i = 0; i < nNumSegs; i++)
{
vector<int> copy = A;
for(unsigned int j = i; j < (i + (K-1)); j++)
{
occ[copy[j]]++;
}
map<int,int>::iterator it = occ.begin();
while(it != occ.end())
{
if(it->second > fHalf)
{
s.insert(it->first);
}
it++;
}
}
map<int,int>::iterator it2 = occ.begin();
while(it2 != occ.end())
{
cout << it2->first;
it2++;
}
set<int>::iterator it = s.begin();
while(it != s.end())
{
ret.push_back(*it);
it++;
}
// copy(s.begin(),s.end(), ret.begin());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
set<int> s;
float fHalf = A.size() / 2;
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
occurrences
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
if(find()
occurrences
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
if(occurrences.find(A[i]) == occurrences.end()_)
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
if(occurrences.find(A[i]) == occurrences.end())
occurrences[A[i]] = 1;
else
occurrences[A[i]]];;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
if(occurrences.find(A[i]) == occurrences.end())
occurrences[A[i]] = 1;
else
occurrences[A[i]]]++;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size())
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> copy = A;
for(int i = 0; i < copy.size())
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> copy = A;
for(int i = 0; i < copy.size() - K)
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> copy = A;
for(int i = 0; i < copy.size() - (K -1))
{
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j (i+))
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < A.size() - (K -1);j++)
{
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < A.size() ;j++)
{
cout << copy
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1))
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < A.size() - (K -1)) ~~^~~~~~~~~~~~~~~~~~~ func.cpp:16:41: error: expected ';' before ')' token for(int i = 0; i < A.size() - (K -1)) ^ func.cpp:25:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < copy.size() ;j++) ~~^~~~~~~~~~~~~ func.cpp:37:12: error: 'ret' was not declared in this scope return ret; ^~~ func.cpp:12:11: warning: unused variable 'fHalf' [-Wunused-variable] float fHalf = A.size() / 2; ^~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < A.size() - (K -1); i++) ~~^~~~~~~~~~~~~~~~~~~ func.cpp:25:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < copy.size() ;j++) ~~^~~~~~~~~~~~~ func.cpp:37:12: error: 'ret' was not declared in this scope return ret; ^~~ func.cpp:12:11: warning: unused variable 'fHalf' [-Wunused-variable] float fHalf = A.size() / 2; ^~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vec
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
3 2 4 1 2 2 3 2 2 4 2 2 2 3 2 1 4 2 3 2 3 2 1 3 2 3 3 3 2 1 3 1 3 3 4
2 3 3 2 2 1 3 3 2 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[i]] = copy[j];
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]] = copy[j];
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]] = copy[j];
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
3 2 4 1 2 2 3 2 2 4 2 2 2 3 2 1 4 2 3 2 3 2 1 3 2 3 3 3 2 1 3 1 3 3 4
2 3 3 2 2 1 3 3 2 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]+
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
3 2 4 1 2 2 3 2 2 4 2 2 2 3 2 1 4 2 3 2 3 2 1 3 2 3 3 3 2 1 3 1 3 3 4
2 3 3 2 2 1 3 3 2 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
it++;
}
}
return ret;
}
3 2 4 1 2 2 3 2 2 4 2 2 2 3 2 1 4 2 3 2 3 2 1 3 2 3 3 3 2 1 3 1 3 3 4
2 3 3 2 2 1 3 3 2 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second;
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
3 2 4 1 2 2 3 2 1 3 1 4 1 2 2 4 2 2 2 3 2 3 3 1 4 2 2 1 4 2 3 2 3 2 4 3 2 4 3 2 1 3 2 3 3 3 2 5 3 4 4 3 2 1 3 1 3 3 4 2 5 3 6 4 4
2 3 3 2 2 2 2 3 2 1 3 3 2 3 2 3 3 5
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
// cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
2 1 3 1 4 1 2 3 3 1 4 2 2 4 3 2 4 3 2 5 3 4 4 3 2 5 3 6 4 4
2 2 3 2 2 3 3 5
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K-1); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
// cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
map<int,int> occurrences;
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
vector<int> copy = A;
for(int j = i; j < (i+K-1); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
// cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
2 1 3 1 2 2 3 1 4 1 2 3 3 1 4 2 2 4 3 2 4 2 2 4 3 4 4 2
2 1 3 2 2 2 3 4
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K-1); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
// cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
2 1 3 1 2 1 4 1 2 1 4 1 2 1 3 1 3 2
2 1 3 2 2 1 3 2
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
// cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
2 1 3 1 4 1 2 2 4 1 2 1 3 1 4 1 2 1 3 2 3 2 4 1
2 2 3 2 2 1 3 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
2 1 3 1 4 1 2 2 4 1 2 1 3 1 4 1 2 1 3 2 3 2 4 1
2 2 3 2 2 1 3 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
cout << copy[j];
occurrences[copy[j]]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
324 2 1 3 1 4 1 242 2 2 4 1 423 2 1 3 1 4 1 233 2 1 3 2 334 3 2 4 1
2332 2 2 3 2 3323 2 1 3 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < occurrences.size(); j++)
{
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
1 1 2 3 3 2 4 1 2 5 3 1 4 1 1 1 2 3 3 2 4 1 1 1 2 2 3 4 1 2 2 1 3 3 4 1
2 3 3 2 1 1 2 1 3 3
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
cout << it->first << " " << it->second << "\n";
;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->second;)
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:16:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < A.size() - (K -1); i++) ~~^~~~~~~~~~~~~~~~~~~ func.cpp:28:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < copy.size(); j++) ~~^~~~~~~~~~~~~ func.cpp:38:41: error: expected ')' before ';' token ret.push_back(it->second;) ^ func.cpp:38:42: error: expected primary-expression before ')' token ret.push_back(it->second;) ^ func.cpp:43:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < copy.size() ;j++) ~~^~~~~~~~~~~~~
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->second)
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->second);
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
{
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->first);
it++;
}
for(int j = 0; j < copy.size() ;j++)
{
// cout << copy[j]<< " ";
}
cout << "\n";
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
}
for(int j = 0; j < copy.size(); j++)
{
occurrences[copy[j]]++;
}
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
ret.push_back(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.i(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
vector<int> ret;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
std::
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret()
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end())
return ret;
}
func.cpp: In function 'std::vector<int> solution(int, int, std::vector<int>&)': func.cpp:15:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int i = 0; i < A.size() - (K -1); i++) ~~^~~~~~~~~~~~~~~~~~~ func.cpp:24:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] for(int j = 0; j < copy.size(); j++) ~~^~~~~~~~~~~~~ func.cpp:40:5: error: expected ',' or ';' before 'return' return ret; ^~~~~~ func.cpp:41:1: warning: no return statement in function returning non-void [-Wreturn-type] } ^
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(unsigneint j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(unsigned int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(unsigned int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(unsigned int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(unsigned int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
// you can use includes, for example:
// #include <algorithm>
#include <map>
#include <set>
// you can write to stdout for debugging purposes, e.g.
// cout << "this is a debug message" << endl;
vector<int> solution(int K, int M, vector<int> &A) {
// write your code in C++14 (g++ 6.2.0)
float fHalf = A.size() / 2;
set<int> s;
for(unsigned int i = 0; i < A.size() - (K -1); i++)
{
map<int,int> occurrences;
vector<int> copy = A;
for(unsigned int j = i; j < (i+K); j++)
copy[j]++;
for(unsigned int j = 0; j < copy.size(); j++)
occurrences[copy[j]]++;
map<int,int>::iterator it = occurrences.begin();
while(it!= occurrences.end())
{
if(it->second > fHalf)
s.insert(it->first);
it++;
}
}
vector<int> ret(s.begin(),s.end());
return ret;
}
The following issues have been detected: timeout errors.
medium tests (N = 10000, M = 100)
running time: 0.316 sec., time limit: 0.100 sec.
medium tests(N >= 20000, M=30000)
running time: 1.808 sec., time limit: 0.100 sec.