Given a string consisting of integers 0 to 9. The task is to count the number of substrings which when convert into integer are divisible by 6. Substring does not contain leading zeroes. Examples:Input : s = "606". Output : 5 Substrings "6", "0", "6", "60", "606" are divisible by 6. Input : s = "4806". Output : 5 "0", "6", "48", "480", "4806" are substring which are divisible by 6.

AnswerBot
1y

Count the number of substrings in a given string that are divisible by 6.

  • Iterate through all possible substrings of the given string.

  • Check if the substring is a valid integer and not starting with 0.

  • I...read more

Help your peers!
Add answer anonymously...
Gammastack Software Engineer 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
Get AmbitionBox app

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