Find First Negative Number in Every subarray of Size k using Sliding Window Algorithm in c#

Arkaprava Sinha
Mar 17, 2021

Problem : Find First negative number in every subarray of size k

Explanantion:

Lets say we have an array like this { 12, -1, -7, 8, -15, 30, 16, 18 }

Sub Arrays of size k(k=3) will be below,

{12,-1,-7} {-1,-7,8} {-7,8,-15} {8,-15,30} {-15,30,16} {30,16,18}

First Negative of each sub arrays will be -1,-1,-7,-15,-15,0(as there are no negative numbers)

Code:

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Arkaprava Sinha
Arkaprava Sinha

Written by Arkaprava Sinha

Senior Software Engineer@Walmart , Cloud, IoT and DevOps Enthusiast

No responses yet

Write a response