• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
October 21, 2023 |1.7K Views
PROBLEM OF THE DAY: 20/10/2023 | Form a number divisible by 3 using array digits
Description
Discussion

Welcome to the daily solving of our PROBLEM OF THE DAY with Karan Mashru. We will discuss the entire problem step-by-step and work towards developing an optimized solution. This will not only help you brush up on your concepts of Arrays but will also help you build up problem-solving skills.

In this problem, we are given, an array arr of integers of length N. You can construct an integer from two integers by treating the integers as strings, and then concatenating them. For example, 19 and 4 can be used to construct 194 and 419.

The task is to find whether it’s possible to construct an integer using all the digits of these numbers such that it would be divisible by 3.
If it is possible then print 1 and if not print 0.

Example :

Input: N = 3
arr = {40, 50, 90}
Output: 1
Explanation: One such number is 405090.

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems-preview/form-a-number-divisible-by-3-using-array-digits0717/1

Solution Function Link: https://ide.geeksforgeeks.org/online-cpp-compiler/7fa8d058-7356-4fc2-8abe-ff3eb6ae2b74