Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 | class Solution { public: vector<int> shuffle(vector<int>& nums, int n) { vector<int> result; for(int i=0; i<n;i++){ result.push_back(nums.at(i)); result.push_back(nums.at(i+n)); } return result; } }; |
Resolvemos desafios de programação de diversas plataformas, tais como URI (BEECROWD), UVA e SPOJ. Sejam-bem vindos! Aqui você vai encontrar a solução para os seus problemas! Soluções para o Beecrowd! Chave PIX para doações: 6d8bc7a8-5d74-493a-ab7a-3515baf35956 - Welcome to Codificando Online! We solve programming challenges in many platforms like URI (BEECROWD), UVA and SPOJ. Here you'll find the solutions to various exercises! Beecrowd solutions. Donations: Ask for our PayPal
Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 | class Solution { public: vector<int> shuffle(vector<int>& nums, int n) { vector<int> result; for(int i=0; i<n;i++){ result.push_back(nums.at(i)); result.push_back(nums.at(i+n)); } return result; } }; |
Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class Solution { public: vector<bool> kidsWithCandies(vector<int>& candies, int extraCandies) { int max = 0; vector<bool> result; for(int i = 0; i < candies.size(); i++){ if(candies.at(i)>max){ max = candies.at(i); } } for(int i = 0; i < candies.size(); i++){ if(candies.at(i) + extraCandies >= max){ result.push_back(true); } else{ result.push_back(false); } } return result; } }; |
Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 12 | class Solution { public: vector<int> runningSum(vector<int>& nums) { vector<int> result; int sum = 0; for(int i=0;i<nums.size();i++){ sum += nums.at(i); result.push_back(sum); } return result; } }; |
Linguagem: C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | class Solution { public: bool canPlaceFlowers(vector<int>& flowerbed, int n) { int planted = 0; if(flowerbed.size() == 1 and flowerbed.at(0)==0){ return true; } if(flowerbed.size() > 1 and flowerbed.at(0) == 0 and flowerbed.at(1) == 0){ planted++; flowerbed[0] = 1; } for(int i =1;i<flowerbed.size()-1;i++){ if(flowerbed.at(i-1) == 0 and flowerbed.at(i) == 0 and flowerbed.at(i+1) == 0){ planted++; flowerbed[i] = 1; } } if(flowerbed.size() > 1 and flowerbed.at(flowerbed.size()-2) == 0 and flowerbed.at(flowerbed.size()-1) == 0){ planted++; } if(planted >= n){ return true; } else{ return false; } } }; |
Buenas! Estou aqui mais uma vez para resolver um problema de Matemática! Agora tenho resolvido alguns dessa categoria, pra que vocês possam ...