Asked inOracle,Mts1

Check if a Number is Binary

Determine if a given string of integers bin represents a valid binary number. Return 'true' if the string represents a valid binary number, otherwise return 'false'. A binary number is strictly composed of the digits 0 and 1.

Input:

The first line contains an integer ‘T’ representing the number of test cases. Each of the next ‘T’ lines contains a single string ‘bin’.

Output:

For each test case, output a boolean: 'true' if the string is a valid binary number and 'false' otherwise. Each result should be printed on a separate line.

Example:

Input:
3
101
123
110110
Output:
true
false
true

Constraints:

  • 1 <= T <= 50
  • 1 <= length(bin) <= 10^4
Note:
No need to print anything; only implement the function to return the desired output.
Be the first one to answer
Add answer anonymously...
Oracle Mts1 Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter