A responsive image service has a set of pre-rendered images with widths images. Each waiting screen has a minimum width it needs, in screens. A screen is served if it gets an image at least as wide as it needs. Each image can be sent to only one screen, and each screen gets at most one image.
Write screensServed(screens, images) that returns the largest number of screens that can be served.
Input: screens = [320,768,1024], images = [400,300] Output: 1
Only the 320 screen can be served (with the 400 image). The 300 image is too small for everyone.
Input: screens = [320,640], images = [640,1280,320] Output: 2
Both screens get a wide enough image.
0 <= screens.length, images.length <= 300001 <= screens[i], images[j] <= 10^4Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #571 Serve Image Variants to Screens. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.