Author: akshay
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively. Merge nums1 and nums2 into a single array sorted in non-decreasing order. The final sorted array should not be returned by the function, but instead be stored inside the array nums1. To accommodate this, nums1 has a length of m + n, where the first m elements denote the elements that should be merged, and the last n elements are set to 0 and should be ignored. nums2 has a length…
Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note: You must do this in-place without making a copy of the array. Examples Example 1: Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] Example 2: Input: nums = [0] Output: [0] Constraints: 1 <= nums.length <= 104 -231 <= nums[i] <= 231 – 1 Optimal Approach – Two Pointers Initialize a pointer x = 0. Loop through the array: If the current element is not 0, assign it to nums[x] and increment x. After the loop, from index x…
Given a binary array nums, return the maximum number of consecutive 1’s in the array. Examples Example 1: Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3. Example 2: Input: nums = [1,0,1,1,0,1] Output: 2 Constraints: 1 ≤ nums.length ≤ 105 nums[i] is either 0 or 1. Optimal Approach – Single Pass Initialize two variables: currentCount → to count current streak of 1s maxCount → to keep track of the maximum streak seen so far Traverse the array: If nums[i] == 1,…
Problem Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Example 1: Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not appear in nums. Example 2: Input: nums = [0,1] Output: 2 Explanation: n = 2 since there are 2 numbers, so all numbers are in the range [0,2]. 2 is the missing number in the range…
Problem Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Examples Input: nums = [2, 2, 1] → Output: 1 Input: nums = [4, 1, 2, 1, 2] → Output: 4 Input: nums = [1] → Output: 1 Constraints 1 ≤ nums.length ≤ 3 × 104 -3 × 104 ≤ nums[i] ≤ 3 × 104 Each element appears twice except one that appears only once. Approach 1: Brute Force (Hash Map) Create an empty hash…
Approach (Brute Force – Hash Map) Create an empty hash map to store counts of each element. Loop through the array, update the count for each element. Loop through the array again to find the element with count 1. Return that element. Dry Run Input: [4, 1, 2, 1, 2] Step 1: Counting frequency hash = {} Insert 4 → hash[4] = 1 Insert 1 → hash[1] = 1 Insert 2 → hash[2] = 1 Update 1 → hash[1] = 2 Update 2 → hash[2] = 2 Step 2: Find the element with count 1 4 → hash[4] = 1…
CHANGE is the only constant in front-end development. With so many frameworks and tools available, the community has set a benchmark for the end-user experience as well as the efficiency of products. I certainly feel that React JS is a go-to framework. But is React JS the best choice? Is it easier to learn? These are the common queries from students starting with React JS. In this article, I have tried to break down a few benefits and advantages of why you should choose React JS over any other framework. Here are 7 reasons why you should choose React JS…
There were 4-5 roundRound-1: Online test + phone screeningRound 2: Online Machine Coding RoundRound-3: Tech round (DSA + web dev(google doc or code-sandbox))Round 4: Tech round-2 – 2 or Hiring Manager RoundRound-5: HRRound -1: 15 min: – passedPhone screening roundIntroduce yourselfComplexity based quesbasic react-jsOnline Assessment – 60 min:- passed2 ques( easy,medium level)Round-2: Machine coding round : 120min :: PassedNote:- UI should be responsible.Implement a Flipkart search bar to show data based on API (By searching product name or product ID data should be shown on UI)Round:3 : 90 min : bad luck1. Recursion+stack based ques(leet code medium level): not able…
There were 4 Rounds of Interview.ROUND 1: Machine Coding | 60 minutes- I was asked to build the UI for an e-commerce website like Amazon.- A dummy API was provided which gives sample data- Was only allowed to use Vanilla JS for building thisROUND 2: DS/Algo Round | 60 minutesTwo questions were asked directly from leetcode,- Longest Palindromic Substring : https://leetcode.com/problems/longest-palindromic-substring/description/- Reverse Integer : https://leetcode.com/problems/reverse-integer/description/ROUND 3 : JavaScript Round | 60 minutesInterviewer asked core concepts of Javascript like Closures, prototype, Promises, Event loopROUND 4: UI System Design round | 60 minutesI was asked to come up with design & architecture…
Walmart interview experienceRound 1 :a) Egg dropping problemb) search pattern (KMP)DBMS questions1) ER diagram2) all normal forms3) queries like second highest Salary and nth highest Salary .4) top down query execution .5) triggers and cursors in pl SQLOS questions1) Deadlock2) paging3) semaphores and some linux commandsRound 2 + HR Deep questions on project .Questions on React js , vue js . Why do we prefer one over other . Asked me to explain the whole back-end part of the project with a small part written . Resume based questions too .HR roundYour strengthYour weaknessWhy walmartSome situation based questions
Contact Us
Subscribe to Stay Updated
Stay ahead in the world of tech with our exclusive newsletter! Subscribe now for regular updates on the latest trends, valuable coding resources, and tips to boost your frontend development skills.
