No video

1509. Minimum Difference Between Largest and Smallest Value in Three Moves | 03 July 2024 | Java

  Рет қаралды 6

My Learning Hub

My Learning Hub

Күн бұрын

LeetCode Problem of the day
02 July 2024
Problem No [1509] : Minimum Difference Between Largest and Smallest Value in Three Moves using Java
Level : Medium
Topic : Array | Greedy | Sorting
------------------------------------------------
You may also explore my another playlists :
👉Java Tutorial :
• Java Tutorial | Java P...
👉 Geeks-for-Geeks Problem :
• Geeks-for-Geeks Problems
👉 Coding ninjas Easy coding problem :
• Coding Ninjas | MCQ Da...
----------------------------------------------------------------
⏩ Stay connected with me on social media for more updates and behind-the-scenes content !
You can find me on 🔍 :
📱Instagram Profile :
/ _ganesh_p09
🌐 LinkedIn Profile :
/ ganesh-prasad09
-----------------------------------------------------
✅ Description about the problem as follows :
You are given an integer array nums.
In one move, you can choose one element of nums and change it to any value.
Return the minimum difference between the largest and smallest value of nums after performing at most three moves.
Example 1:
Input: nums = [5,3,2,4]
Output: 0
Explanation: We can make at most 3 moves.
In the first move, change 2 to 3. nums becomes [5,3,3,4].
In the second move, change 4 to 3. nums becomes [5,3,3,3].
In the third move, change 5 to 3. nums becomes [3,3,3,3].
After performing 3 moves, the difference between the minimum and maximum is 3 - 3 = 0.
Example 2:
Input: nums = [1,5,0,10,14]
Output: 1
Explanation: We can make at most 3 moves.
In the first move, change 5 to 0. nums becomes [1,0,0,10,14].
In the second move, change 10 to 0. nums becomes [1,0,0,0,14].
In the third move, change 14 to 1. nums becomes [1,0,0,0,1].
After performing 3 moves, the difference between the minimum and maximum is 1 - 0 = 1.
It can be shown that there is no way to make the difference 0 in 3 moves.
Example 3:
Input: nums = [3,100,20]
Output: 0
Explanation: We can make at most 3 moves.
In the first move, change 100 to 7. nums becomes [3,7,20].
In the second move, change 20 to 7. nums becomes [3,7,7].
In the third move, change 3 to 7. nums becomes [7,7,7].
After performing 3 moves, the difference between the minimum and maximum is 7 - 7 = 0.
------------------------------------
🔔 If you enjoyed the content, please subscribe to the channel for more updates! 📺
👍 If you found this video helpful, don't forget to give it a thumbs up and share it with your friends! 📤
🙏 Thank you for watching the video! 😊
------------------------------------------------
📚 Check out other problems! 🔍:
🧩1. Partitions with Given Difference | Java | GeekforGeeks | Practice Problem
• GFG-POTD | Partitions ...
🧩2. K-Palindrom | Java | GeeksforGeeks | Practice Problems
• GFG-POTD | K-Palindrom...
🧩3. [ Part-02 ] Maximum Score Words Formed by Letters - Leetcode
• 1255. [Part-01] Maximu...
🧩4. Mobile Numeric Keypad :
• GFG-POTD | 📱Mobile num...
🧩5. Summed Matrix :
• GFG-POTD | Summed Matr...
🧩6. Print Bracket Numbers :
• GFG-POTD | Print Brack...
🧩 7. Toeplitz matrix :
• GFG-POTD | Toeplitz ma...
🧩 8. 350. Intersection of Two Arrays II :
• 350. Intersection of T...
---------------------------------------
#leetcodeproblemoftheday
#leetcodeproblems
#leetcodeproblemsolution
#leetcode
#1509minimumdifferencebetweenlargestandsmallestvalueinthreemoves
#1509minimumdifferencebetweenlargestandsmallestvalueinthreemovesusingjava
#1509minimumdifferencebetweenlargestandsmallestvalueinthreemovesjavasolution
#1509minimumdifferencebetweenlargestandsmallestvalueinthreemovespotd

Пікірлер
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Chapitosiki
Рет қаралды 28 МЛН
КАКУЮ ДВЕРЬ ВЫБРАТЬ? 😂 #Shorts
00:45
НУБАСТЕР
Рет қаралды 3,2 МЛН
wow so cute 🥰
00:20
dednahype
Рет қаралды 14 МЛН
Database Sharding and Partitioning
23:53
Arpit Bhayani
Рет қаралды 78 М.
Hash Table - Data Structures & Algorithms Tutorials In Python #5
17:52
Yaml Tutorial | Learn YAML in 18 mins
18:05
TechWorld with Nana
Рет қаралды 625 М.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Chapitosiki
Рет қаралды 28 МЛН