Walmart | IN4 | Round 1 Bangalore

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2023-10-19Added By Anonymous
Source: Link

Walmart


Round1 Interview Questions:-

Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.


Example 1:

Input: nums = [1,2,3,1], k = 3

Output: true


Example 2:

Input: nums = [1,0,1,1], k = 1

Output: true


Example 3:

Input: nums = [1,2,3,1,2,3], k = 2

Output: false


Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.

1.Input: nums = [1,1,1,0,0,0,1,1,1,1,0], k = 2
2.Output: 6


explanation: [1,1,1,0,0,1,1,1,1,1,1]


Input: nums = [0,0,1,1,0,0,1,1,1,0,1,1,0,0,0,1,1,1,1], k = 3


Output: 10


Explanation: [0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1]

Comments