Back to Browse

2460. Apply Operations to an Array | leetcode daily challenge | faang | shashcode

1.4K views
Mar 1, 2025
9:54

Problem link: https://leetcode.com/problems/apply-operations-to-an-array/description/?envType=daily-question&envId=2025-03-01 Problem Statement: You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums: If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Otherwise, you skip this operation. After performing all the operations, shift all the 0's to the end of the array. For example, the array [1,0,2,0,0,1] after shifting all its 0's to the end, is [1,2,1,0,0,0]. Return the resulting array. Note that the operations are applied sequentially, not all at once. Solution Link: https://github.com/Tiwarishashwat/InterviewCodes/blob/main/ApplyOperationsToAnArray.java Must Watch: 1. Dijkstra's Algorithm https://youtu.be/jhlo_YQPXR0?si=kLMApjyta4GStfyW 2. Prim's Algorithm https://youtu.be/4EuFmlbcSY8?si=nhnsJBYKHRLvAr7C 3. Krushkal's Algorithm https://youtu.be/dBGYpKLY2bQ?si=fwMWyGSRNG6MkXWH 4. Minimum Swaps for bracket balancing https://youtu.be/U48xDsqb8OE?si=ns5ckPkpxEPNjEXY Custom Comparator: https://youtu.be/quegYlReztM?si=G265RK8IFpP92_4b Lambda Expression: https://youtu.be/3DkmAUdrzKw?si=q9pqrvNPKAXt1g0d Dynamic Programming: https://youtu.be/P3MFBCZCGXs?si=A832THtbhyqPNAf2 Graph Playlist: https://www.youtube.com/playlist?list=PLQ7ZAf76c0ZOGuMjg3qwNgILb_dKWTxyQ Java Plus DSA Placement Course Playlist: https://youtube.com/playlist?list=PLQ7ZAf76c0ZPVdhV1bAjFv0bQc1xHURzE Java Plus DSA Sheet: https://docs.google.com/spreadsheets/d/119u25NO-4ZJ9zwfUKs5eGNo0exCVq3gZEFWvkCDiMqI/edit?usp=sharing Notes: https://github.com/Tiwarishashwat/Java-Plus-DSA-Placement-Course Telegram Link: https://shashwattiwari.page.link/telegramShashwat Ultimate Recursion Series Playlist: https://youtube.com/playlist?list=PLQ7ZAf76c0ZMzC9OHPbo-dUgx6oU3T0jK Instagram Handle: (@shashwat_tiwari_st) https://shashwattiwari.page.link/shashwatInsta Samsung Interview Experience: https://youtu.be/GrvlpBzphSU Company Tags: Facebook | Amazon | Microsoft | Netflix | Google | LinkedIn | Pega Systems | VMware | Adobe | Samsung

Download

1 formats

Video Formats

360pmp413.6 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

2460. Apply Operations to an Array | leetcode daily challenge | faang | shashcode | NatokHD