DSA- L1- Check if a key is present in every segment of size k in an array

using System;public class GFG{
static public void Main (){
//Code

int[] arr = {5, 8, 7, 12, 14, 3, 9};
int findItem = 8;
int chunk = 2;

int counter = 0;
bool found = false;
for(int i=0; i<arr.Length;i++){
if(arr[i] == findItem ){
found = true;
}
counter++;
if(counter == chunk && found == false )
{
break;
}else{
counter = 0;
found = true;
}
}
Console.WriteLine(found);

}
}

--

--

--

Software engineer | loves working in a startup like environment

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

My journey with C++20 (with tutorials)

Interactively exploring Reddit posts using basic Scala in your browser

Introduction To Cloud Computing

Analyzing your Friends’ iMessage Wordle Stats Using Python

Launching Airchat, an alternative to Drift bots!

Dissipativity of the H∞ system

Kubernetes on AzureStackHub with AKS-Engine and external AD/DNS integration

【SCRY.INFO】Monthly Project Report in February 2019

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kapil Patel

Kapil Patel

Software engineer | loves working in a startup like environment

More from Medium

Are you still didn’t start using Version Control for Data?

Coding Standards and Best Practices to Follow

What Are SOLID Principles?

S.O.L.I.D: The First 5 Principles of Object-Oriented Design