DEV Community

Cover image for Problem Solving for Developers - Javascript
Dreamy Developer
Dreamy Developer

Posted on

4 3

Problem Solving for Developers - Javascript

Hey, Everyone! 👋
I'm Dreamy! 🧔 Today's problem [easy]
Have a bit of coding yourself and see what kind of solution you came up with, and comment down your best solution. 🙏

/**
 * Given an array of size N consisting of only 0's and 1's.
 * The array is sorted in such a manner that all the 1's are placed first
 * and then they are followed by all the 0's.
 * Find the count of all the 0's.
 * Example 1:
 * Input:
 * N = 12
 * array = [1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0]
 * Output: 3
 * Explanation: There are 3 0's in the given array.
 * Example 2:
 * Input:
 * N = 5
 * array = [0, 0, 0, 0, 0]
 * Output: 5
 * Explanation: There are 5 0's in the array.
 */
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

SurveyJS custom survey software

JavaScript Form Builder UI Component

Generate dynamic JSON-driven forms directly in your JavaScript app (Angular, React, Vue.js, jQuery) with a fully customizable drag-and-drop form builder. Easily integrate with any backend system and retain full ownership over your data, with no user or form submission limits.

Learn more

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️