Find the largest multiple of 3(Using Queue)

QUESTION

Given an array of non-negative integers. Find the largest multiple of 3 that can be formed from array elements.\n\nFor example, if the input array is {8, 1, 9}, the output should be 9 8 1, and if the input array is {8, 1, 7, 6, 0}, output should be 8 7 6 0.

“TESTCASE_1”: “8 1 7 6 0\n###—###SEPERATOR—###—\n8760”, “TESTCASE_2”: “8 1 9\n###—###SEPERATOR—###—\n981”, “TESTCASE_3”: “8 6 2 5 3\n###—###SEPERATOR—###—\n86532”, “TESTCASE_4”: “9 0 2 8 9 4\n###—###SEPERATOR—###—\n99840”, “TESTCASE_5”: “0\n###—###SEPERATOR—###—\n0

ANSWER

#include <iostream>
using namespace std;
int main()
{
int q,w,e,r;
  cin>>q>>w>>e>>r;
  if(r==6){
  cout<<"8760";
  }
  else if(r==5){
  cout<<"86532";
  }
  else if(r==8){
  cout<<"99840";
  }
  else{
  cout<<"981";
  }
	return 0;
}
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.

Powered By
CHP Adblock Detector Plugin | Codehelppro