DEV Community

Cover image for Problem Solving for Developers - JavaScript [Arrays, Searching].
Dreamy Developer
Dreamy Developer

Posted on • Edited on

3 1

Problem Solving for Developers - JavaScript [Arrays, Searching].

Hey everyone,
I'm Dreamy and today we're gonna solve a problem in JavaScript.

And today's type of Problem is - Arrays and Searching.

/**
 * Given two sorted arrays array1 and array2 of size m and n respectively.
 * Find the median of the two sorted arrays.
 *
 * @Example 1:
 * Input:
 * m = 3, n = 4
 * array1 = [1, 9, 15]
 * array2 = [2, 4, 5, 23]
 *
 * Output: 5
 *
 * @Example 2:
 * Input:
 * m = 2, n = 4
 * array1 = [41, 78]
 * array2 = [3, 4, 7, 8]
 *
 * Output: 7.5
 *
 * Expected Time Complexity: O(min(log n, log m)).
 * Expected Auxiliary Space: O((n+m)/2).
 */
Enter fullscreen mode Exit fullscreen mode

Have a bit of a coding yourself and see what kind of solution you can come up with and comment your solution here.
You can write your solution in any language and in your way, But don't forget to comment your best solution here.

If you get stuck or you want to see the solution,
II'l show you how would i solve it.

We will Highlight top answers || comments in Future videos.

highlighted Comments showing 40% responded

Check the tutorial for Solution

SurveyJS custom survey software

Build Your Own Forms without Manual Coding

SurveyJS UI libraries let you build a JSON-based form management system that integrates with any backend, giving you full control over your data with no user limits. Includes support for custom question types, skip logic, an integrated CSS editor, PDF export, real-time analytics, and more.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

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. ❤️