question_slug
stringlengths
3
77
title
stringlengths
1
183
slug
stringlengths
12
45
summary
stringlengths
1
160
author
stringlengths
2
30
certification
stringclasses
2 values
created_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
updated_at
stringdate
2013-10-25 17:32:12
2025-04-12 09:38:24
hit_count
int64
0
10.6M
has_video
bool
2 classes
content
stringlengths
4
576k
upvotes
int64
0
11.5k
downvotes
int64
0
358
tags
stringlengths
2
193
comments
int64
0
2.56k
minimum-score-by-changing-two-elements
[Python] ✅🔥 2-line Solution w/ Explanation!
python-2-line-solution-w-explanation-by-8mz2y
Please upvote/favourite/comment if you like this solution!\n\n# Approach\n Describe your approach to solving the problem. \nThis question reduces to minimizing
j-douglas
NORMAL
2023-02-18T16:11:48.681658+00:00
2023-02-18T17:59:01.361014+00:00
404
false
## **Please upvote/favourite/comment if you like this solution!**\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nThis question reduces to minimizing the range of `nums` by changing 2 elements in `nums`. We can minimize the range by doing one of 3 options:\n1. Increase the smallest two numbers. ...
8
0
['Math', 'Sorting', 'Python', 'Python3']
1
minimum-score-by-changing-two-elements
Simple java solution
simple-java-solution-by-siddhant_1602-y85i
\n# Complexity\n- Time complexity: O(n log n)\n\n- Space complexity: O(1)\n\n# Code\n\nclass Solution {\n public int minimizeSum(int[] nums) {\n Array
Siddhant_1602
NORMAL
2023-02-18T16:03:05.374610+00:00
2023-02-18T16:24:11.279792+00:00
442
false
\n# Complexity\n- Time complexity: $$O(n log n)$$\n\n- Space complexity: $$O(1)$$\n\n# Code\n```\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n int a=nums[nums.length-1]-nums[0];\n int b=nums[nums.length-1]-nums[2];\n int c=nums[nums.length-3]-nums[0];\n ...
8
0
['Sorting', 'Java']
0
minimum-score-by-changing-two-elements
Sorting || Two liner || Easy & Understandable C++ Code
sorting-two-liner-easy-understandable-c-h1x4b
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
vidit987
NORMAL
2023-02-18T16:13:08.404137+00:00
2023-02-18T16:18:02.523776+00:00
272
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e....
7
0
['C++']
0
minimum-score-by-changing-two-elements
O(N) TC - O(1) SC || 100% Beats || Most Efficient Approach || C++ Solution
on-tc-o1-sc-100-beats-most-efficient-app-pnm5
Intuition\nThere Is No Need Of Sorting Here , By the Observation Of Some Random Test Cases i got know that, we just need to keep track first 3 minimum elements
brucewayne_5
NORMAL
2023-05-31T08:20:57.002158+00:00
2023-05-31T08:20:57.002202+00:00
254
false
# Intuition\nThere Is No Need Of Sorting Here , By the Observation Of Some Random Test Cases i got know that, we just need to keep track first 3 minimum elements and first 3 maximum elements . then apply the appropriate conditions to get the answer.\n# Approach\n**1 Condition**\nConsider the array : [1,4,5,6,7,8]\nNow ...
6
0
['Greedy', 'C++']
0
minimum-score-by-changing-two-elements
Video Solution - [With Sorting, Easy to Understand] - C++
video-solution-with-sorting-easy-to-unde-u7lz
Video Solution\nhttps://youtu.be/B3iSW6gKXXk\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n = nums.size();\n
aryan_0077
NORMAL
2023-02-18T17:45:28.735517+00:00
2023-02-18T17:45:28.735550+00:00
228
false
# Video Solution\nhttps://youtu.be/B3iSW6gKXXk\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n = nums.size();\n \n sort(nums.begin(), nums.end());\n \n int ans = min( min( nums[n-1] - nums[2] , nums[n-3] - nums[0] ) , nums[n-2] - nums[1]);\...
6
0
['C++']
1
minimum-score-by-changing-two-elements
Easy Peasy C++ code | O(n logn) time complexity | O(1) Space Complexity
easy-peasy-c-code-on-logn-time-complexit-qab6
Complexity\n- Time complexity:\nO(n logn) for sorting the vector\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector
karankc23
NORMAL
2023-02-18T18:26:13.503138+00:00
2023-02-18T18:26:13.503175+00:00
838
false
# Complexity\n- Time complexity:\nO(n logn) for sorting the vector\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& a) {\n int n = a.size();\n if(n==3){\n return 0;\n }\n sort(a.begin(),a.end());\n int one = a[n-1] - a...
5
0
['C++']
2
minimum-score-by-changing-two-elements
[C++] 2 Liner Code
c-2-liner-code-by-pathak_ankit-6h1j
Self-explanatory\nOnly three windows are possible to minimze\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) \n {\n \n
Pathak_Ankit
NORMAL
2023-02-18T16:11:39.547318+00:00
2023-02-18T16:13:28.085939+00:00
745
false
Self-explanatory\nOnly three windows are possible to minimze\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) \n {\n \n int n=nums.size();\n sort(nums.begin(),nums.end());\n return min({nums[n-3]-nums[0],nums[n-2]-nums[1],nums[n-1]-nums[2]});\n \n ...
5
0
['C++']
0
minimum-score-by-changing-two-elements
Simple c++ Easiest solution with 3 cases
simple-c-easiest-solution-with-3-cases-b-9f09
Intuition\nSort the vector to focus mainly on minimum and maximum values.\nFind the cases where we can minimize the score\nMinimum diff can always be made 0 by
sanjaygouroju
NORMAL
2023-02-18T16:01:37.393085+00:00
2023-02-24T17:33:59.423200+00:00
405
false
# Intuition\nSort the vector to focus mainly on minimum and maximum values.\nFind the cases where we can minimize the score\nMinimum diff can always be made 0 by making two elements equal.\nTo minimize the maximum diff there can be\nthree cases possible:\n1. First and last element can be made equal to its adjacent valu...
5
0
['C++']
1
minimum-score-by-changing-two-elements
Simplest Java solution with Time and Space complexity explaination
simplest-java-solution-with-time-and-spa-apfb
Approach\n Describe your approach to solving the problem. \nThe code first checks if the length of the input array is 3, and if so, returns 0. This is because,
BleedBlue38
NORMAL
2023-02-18T18:55:56.078443+00:00
2023-02-18T18:55:56.078478+00:00
838
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nThe code first checks if the **length of the input array is 3**, and if so, **returns 0.** This is because, in this case, *all elements in the array can be made equal by replacing any two elements with the third element, and hence, the sum of differen...
4
0
['Java']
0
minimum-score-by-changing-two-elements
Python
python-by-abdulazizms-4zqc
\n# Code\n\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n nums.sort()\n return min(nums[-2] - nums[1],\n
abdulazizms
NORMAL
2023-02-18T16:19:59.312041+00:00
2023-02-18T16:19:59.312082+00:00
400
false
\n# Code\n```\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n nums.sort()\n return min(nums[-2] - nums[1],\n nums[-1] - nums[2],\n nums[-3] - nums[0])\n \n```
4
0
['Python3']
2
minimum-score-by-changing-two-elements
Java | 2-3 Lines | Sorting
java-2-3-lines-sorting-by-aaveshk-f5a2
Observations\nIf two numbers are equal, low is 0. We\'ll use this to remove low from consideration \nThere are three possibilities to minimize score:\n1. Set le
aaveshk
NORMAL
2023-02-18T16:01:05.651670+00:00
2023-02-18T16:15:12.762231+00:00
664
false
**Observations**\nIf two numbers are equal, low is 0. We\'ll use this to remove `low` from consideration \nThere are three possibilities to minimize score:\n1. Set least two elements as third least\n2. Set greatest two elements as third greatest\n3. Set least to second least and greatest to second greatest\n\n```\nclas...
4
1
['Java']
1
minimum-score-by-changing-two-elements
USING SORT || C++ || EASY TO UNDERSTAND
using-sort-c-easy-to-understand-by-ganes-g9s2
Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& v) {\n sor
ganeshkumawat8740
NORMAL
2023-05-19T11:53:28.754618+00:00
2023-05-19T11:53:28.754667+00:00
498
false
# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& v) {\n sort(v.begin(),v.end());\n return min({v[v.size()-3]-v[0],v[v.size()-2]-v[1],v[v.size()-1]-v[2]});\n }\n};\n```
3
0
['Array', 'Greedy', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
JavaScript solution
javascript-solution-by-svolkovichs-rx9i
Intuition\nThe answer will be in one of 3 cases. We set Max and second Max elements to third Max. We set Min and second Min elements to third Min element. We se
svolkovichs
NORMAL
2023-02-19T23:17:17.309739+00:00
2023-02-19T23:17:17.309769+00:00
86
false
# Intuition\nThe answer will be in one of 3 cases. We set Max and second Max elements to third Max. We set Min and second Min elements to third Min element. We set Max to second Max and Min to second Min.\n\n# Approach\nTo simplify the code we sort the array. The answer will be the following Math.min(nums[end-2]-nums[0...
3
0
['JavaScript']
1
minimum-score-by-changing-two-elements
✅C++ | ✅Intuitive Approach
c-intuitive-approach-by-yash2arma-oosn
Intuition\nTo get minimum score either we need to make smallest element as larget or largest element as smallest in the array.\n\n# Approach\nWe have three case
Yash2arma
NORMAL
2023-02-19T15:18:10.118023+00:00
2023-02-19T15:41:01.851146+00:00
266
false
# Intuition\nTo get minimum score either we need to make smallest element as larget or largest element as smallest in the array.\n\n# Approach\nWe have three cases by which we can get minimum score\n## Case-1:\nWe can make first two elements as maximum element.\n**Example-**\n[1,4,7,8,5]\n[1,4,5,7,8] (sorted)\n[8,8,5,7...
3
0
['Array', 'Math', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
ONE LINE CODE || C++
one-line-code-c-by-yash___sharma-t115
\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n return min({nums[nums.size()-1]-nums[2],n
yash___sharma_
NORMAL
2023-02-19T04:39:54.566394+00:00
2023-02-19T04:39:54.566434+00:00
79
false
```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n return min({nums[nums.size()-1]-nums[2],nums[nums.size()-3]-nums[0],nums[nums.size()-2]-nums[1]});\n }\n};\n```
3
0
['Math', 'Greedy', 'C', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
Easiest C++ Solution (5 line code) - Very Easy
easiest-c-solution-5-line-code-very-easy-20wx
Intuition\nThere can only be 3 cases, either \n- Change the first 2 elements\n- We change the last 2 elements\n- We change the 1st and the last element\n\n# App
mihir_sahai
NORMAL
2023-02-18T18:01:46.799709+00:00
2023-03-05T08:48:45.416051+00:00
47
false
# Intuition\nThere can only be 3 cases, either \n- Change the first 2 elements\n- We change the last 2 elements\n- We change the 1st and the last element\n\n# Approach\nWe sort the given array, then we can calculate all the 3 cases just by considering the difference between the mentioned values.\nAlso, we don\'t need a...
3
0
['C++']
0
minimum-score-by-changing-two-elements
C++ || Easy
c-easy-by-shrikanta8-wjyh
\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n\n sort(nums.begin(), nums.end());\n int n= nums.size();\n
Shrikanta8
NORMAL
2023-02-18T16:01:24.900279+00:00
2023-02-18T16:04:56.205385+00:00
62
false
\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n\n sort(nums.begin(), nums.end());\n int n= nums.size();\n \n int val = min (abs(nums[0] - nums[n-3]) , min( abs(nums[n-2]-nums[1]), abs(nums[2] - nums[n-1] ) ) );\n return val;\n }\n};\n```
3
0
['C++']
0
minimum-score-by-changing-two-elements
Beginner friendly
beginner-friendly-by-ng6-3n3k
\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n i
ng6
NORMAL
2023-05-02T17:10:22.079906+00:00
2023-05-02T17:10:22.079952+00:00
31
false
\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n int case1=nums[n-3]-nums[0];//change two of largest to the third largest\n int case2=nums[n-1]-nums[2];//change two of smallest to the third smallest\n...
2
0
['Sorting', 'C++']
0
minimum-score-by-changing-two-elements
✅ 2 Lines of Code || Explaination💯
2-lines-of-code-explaination-by-razpatel-512c
First we will sort the list so we can easily access minimum and maximum values.\n\nThere are total 3 ways in which we can get answer.\n1. By changing First two
RazPatel
NORMAL
2023-02-21T04:40:10.484005+00:00
2023-02-21T06:31:25.203720+00:00
104
false
First we will sort the list so we can easily access minimum and maximum values.\n\nThere are total 3 ways in which we can get answer.\n1. By changing First two values - In this case we will chage first two values to make difference zero. Now lowest value we have is nums[2] and largest is nums[-1].\n2. By changing Last ...
2
0
['Python3']
0
minimum-score-by-changing-two-elements
Python short and clean. Beats 100%. 2 solutions. Sorting and Heap.
python-short-and-clean-beats-100-2-solut-slti
Approach 1: Sort\n1. Sort nums to s_nums for random access to maxes and mins.\n\n2. If there were 0 changes allowed:\n There\'s nothing to do.\n The best
darshan-as
NORMAL
2023-02-19T11:08:26.857614+00:00
2023-02-19T11:09:05.194978+00:00
267
false
# Approach 1: Sort\n1. Sort `nums` to `s_nums` for random access to maxes and mins.\n\n2. If there were `0` changes allowed:\n There\'s nothing to do.\n The best we can do is: `s_nums[n - 1] - s_nums[0]`.\n \n Note: Abbriviating `s_num[a] - s_num[b]` as `|a, b|` from henceforth.\n Hence the above becomes...
2
0
['Math', 'Sorting', 'Heap (Priority Queue)', 'Python', 'Python3']
0
minimum-score-by-changing-two-elements
Greedy Kotlin Lambda O(N log N)
greedy-kotlin-lambda-on-log-n-by-kotlinc-91jn
Consider the sorted scenario, where the index of the nums is\n0 1 2 3 4 .... n-3, n-2, n-1\nWe need to find the min value of\n nums[n-1] vs nums[2]\n nums[n-2]
kotlinc
NORMAL
2023-02-18T20:44:01.682321+00:00
2023-08-27T18:34:28.921871+00:00
30
false
Consider the sorted scenario, where the index of the nums is\n```0 1 2 3 4 .... n-3, n-2, n-1```\nWe need to find the min value of\n* `nums[n-1]` vs `nums[2]`\n* `nums[n-2]` vs `nums[1]`\n* `nums[n-3]` vs `nums[0]`\nThe commonality is `n-1-2 = n-3`, `n-2-1 = n-3` and `n-3-0 = n-3`. So we write the following lambda to f...
2
0
['Kotlin']
0
minimum-score-by-changing-two-elements
Java solution with detailed explanation
java-solution-with-detailed-explanation-c9ae5
Intuition\nSince we can change the value of atmost 2 elements, we are left with three choices, I will explain why these three choices only.\n\nWe know the max s
kunal-j
NORMAL
2023-02-18T16:22:42.233153+00:00
2023-02-18T16:22:42.233185+00:00
68
false
# Intuition\nSince we can change the value of atmost 2 elements, we are left with three choices, I will explain why these three choices only.\n\nWe know the max score we can achieve is by subtracting the min element from the max element.\nNow we are given a condition that we can change atmost two values, and so we can ...
2
0
['Java']
0
minimum-score-by-changing-two-elements
C++ 2 line Easy Code.
c-2-line-easy-code-by-sagargupta1610-62ok
Complexity\n- Time complexity: O(n*log(n))\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \
Sagargupta1610
NORMAL
2023-02-18T16:18:35.224636+00:00
2023-02-18T16:18:35.224678+00:00
35
false
# Complexity\n- Time complexity: $$O(n*log(n))$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n ...
2
0
['C++']
0
minimum-score-by-changing-two-elements
[Java] Best choice from three cases
java-best-choice-from-three-cases-by-0x4-w4us
Intuition\n Describe your first thoughts on how to solve this problem. \nJust sort the array and use greedy method.\n\n# Approach\n Describe your approach to so
0x4c0de
NORMAL
2023-02-18T16:00:30.744852+00:00
2023-02-18T16:12:29.908562+00:00
364
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nJust sort the array and use greedy method.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**We can alwasy make lower score to 0 by keeping same number, so we can focus on high score.**\n\nTo get minimum high score...
2
0
['Greedy', 'Java']
0
minimum-score-by-changing-two-elements
5 Lines Code || DP || Easy C++ || Beats 100% ✅✅
5-lines-code-dp-easy-c-beats-100-by-deep-q0iu
\n# Approach\n Describe your approach to solving the problem. \nWe have to choose two numbers from minimum or maximum but which two elements will we choose.....
Deepak_5910
NORMAL
2023-08-06T16:19:09.846096+00:00
2023-08-06T16:19:09.846116+00:00
76
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\nWe have to **choose two numbers** from **minimum or maximum** but which two elements will we **choose**.........\uD83E\uDD14\uD83E\uDD14\uD83E\uDD14\uD83E\uDD14\nHere I used **dp concept** to select two elements so as to **minimize the score sum**.\...
1
0
['Array', 'Dynamic Programming', 'Greedy', 'C++']
0
minimum-score-by-changing-two-elements
[Golang] Simple solution
golang-simple-solution-by-user0440h-sqfe
Complexity\n- Time complexity: O(N Log N)\n- Space complexity: O(1)\n\n# Code\n\nfunc minimizeSum(nums []int) int {\n sort.Ints(nums)\n n := len(nums)\n // S
user0440H
NORMAL
2023-07-02T00:19:04.373438+00:00
2023-07-02T00:19:04.373457+00:00
12
false
# Complexity\n- Time complexity: O(N Log N)\n- Space complexity: O(1)\n\n# Code\n```\nfunc minimizeSum(nums []int) int {\n sort.Ints(nums)\n n := len(nums)\n // Since we can only make at most 2 modifications\n // We either change the first two elements, last two elements\n // or the first and last element.\n res ...
1
0
['Sorting', 'Go']
0
minimum-score-by-changing-two-elements
JAVA very easy solution
java-very-easy-solution-by-21arka2002-ygc2
Approach\nSort the array in ascending order\nThree Cases can occur-\n1. Remove first two elements\n2. Remove last two elements\n3. Remove first and the last ele
21Arka2002
NORMAL
2023-04-03T04:52:51.378084+00:00
2023-04-03T04:52:51.378115+00:00
75
false
### Approach\nSort the array in ascending order\nThree Cases can occur-\n1. Remove first two elements\n2. Remove last two elements\n3. Remove first and the last element\n\n\n\n# Code\n```\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n int d1=(nums[nums.length-1]-nums[2]...
1
0
['Array', 'Greedy', 'Sorting', 'Java']
0
minimum-score-by-changing-two-elements
Sorting approach | Java solution | Clean Code
sorting-approach-java-solution-clean-cod-02bc
Intuition\nIf we make two elements equal then value of low will be 0. Hence we can utilize both the two operations in minimizing the value of high\n\n# Approach
vrutik2809
NORMAL
2023-02-21T18:22:39.863450+00:00
2023-02-21T18:22:39.863493+00:00
32
false
# Intuition\nIf we make two elements equal then value of `low` will be `0`. Hence we can utilize both the two operations in minimizing the value of `high`\n\n# Approach\n- Sort the array in acending order\n- We can minimize the value of `high` using any of the following three operations:\n 1. If we make `nums[0] = n...
1
0
['Sorting', 'Java']
0
minimum-score-by-changing-two-elements
Sort + Greedy | C++
sort-greedy-c-by-tusharbhart-quuy
\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n int n = nums.size();\n return min
TusharBhart
NORMAL
2023-02-20T16:29:30.496096+00:00
2023-02-20T16:29:30.496248+00:00
39
false
```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n int n = nums.size();\n return min({nums[n - 3] - nums[0], nums[n - 1] - nums[2], nums[n - 2] - nums[1]});\n }\n};\n```
1
0
['Greedy', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
C++ || Easy approach
c-easy-approach-by-mrigank_2003-ps2w
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:O(nlogn)\n\n- Space complexity:O(n)\n\n# Code\n\nclass Solution {\npublic:\n int min
mrigank_2003
NORMAL
2023-02-20T09:08:36.432907+00:00
2023-02-20T09:08:36.432955+00:00
41
false
Here is my c++ code for this problem.\n\n# Complexity\n- Time complexity:$$O(nlogn)$$\n\n- Space complexity:$$O(n)$$\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(), nums.end());\n // if(nums.size()==3){return 0;}\n // vector<int>v=nums;\n ...
1
0
['C++']
0
minimum-score-by-changing-two-elements
Explanation and C++ Solution
explanation-and-c-solution-by-shubham_mi-mkb9
Intuition\n Describe your first thoughts on how to solve this problem. \nIf we make two numbers equal, we can make the low score equal to 0. So only thing left
Shubham_Mi
NORMAL
2023-02-19T07:15:33.841704+00:00
2023-02-19T07:15:33.841760+00:00
164
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf we make two numbers equal, we can make the __low__ score equal to `0`. So only thing left is to find minimum __high__ score.\nThe __high__ score will depend on the minimum and the maximum value in the array. So, we should either decrea...
1
0
['Math', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
C++ || Easy Explanation with comments ||
c-easy-explanation-with-comments-by-khwa-jqw8
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nTo Minimine our Ans We need to do two things :\n1. Maximize the maximum d
Khwaja_Abdul_Samad
NORMAL
2023-02-18T18:40:37.558510+00:00
2023-02-18T18:40:37.558555+00:00
74
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nTo Minimine our Ans We need to do two things :\n1. Maximize the maximum difference of two numbers. \n2. Minimize the minimum difference of two numbers.\n\nNow to minimize the difference of two number we can always minimze it...
1
0
['Sorting', 'C++']
0
minimum-score-by-changing-two-elements
C++||Most Easy Solution with Explanation
cmost-easy-solution-with-explanation-by-ggik3
\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n //increase th
Arko-816
NORMAL
2023-02-18T18:15:51.339792+00:00
2023-02-18T18:15:51.339843+00:00
35
false
```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n=nums.size();\n sort(nums.begin(),nums.end());\n //increase the smallest two numbers\n int a=nums[n-1]-nums[2];\n //decrease the two largest nos\n int b=nums[n-3]-nums[0];\n //increase the sm...
1
0
[]
0
minimum-score-by-changing-two-elements
Python Solution || 2 lines || Easy to understand
python-solution-2-lines-easy-to-understa-er78
\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n n,_ = len(nums),nums.sort()\n return min([nums[n-1]-nums[0],nums[n-3]-nums
mohitsatija
NORMAL
2023-02-18T18:03:41.756337+00:00
2023-02-18T18:03:41.756368+00:00
50
false
```\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n n,_ = len(nums),nums.sort()\n return min([nums[n-1]-nums[0],nums[n-3]-nums[0],nums[n-1]-nums[2],nums[n-2]-nums[1]])\n```
1
0
['Array', 'Math', 'Greedy', 'Sorting', 'Python', 'Python3']
0
minimum-score-by-changing-two-elements
Java sorting detailed solution
java-sorting-detailed-solution-by-callme-nhm5
class Solution {\n public int minimizeSum(int[] nums) {\n int n=nums.length;\n Arrays.sort(nums);\n //Remove first and last elem\n
callmecomder
NORMAL
2023-02-18T17:50:28.125201+00:00
2023-02-18T17:50:28.125242+00:00
22
false
# class Solution {\n public int minimizeSum(int[] nums) {\n int n=nums.length;\n Arrays.sort(nums);\n //Remove first and last elem\n int a=nums[n-2]-nums[1];\n //Remove first two elements\n int b=nums[n-1]-nums[2];\n //Remove last two elements\n int c=nums[n-3]...
1
0
['Sorting', 'Java']
0
minimum-score-by-changing-two-elements
only 2 line answer easy to understand both line explain good
only-2-line-answer-easy-to-understand-bo-9p3d
Approach\n Describe your approach to solving the problem. \nwe have 3 case for 2 element remove\n1. 2 minimum\n2. 2 maximum\n3. 1 minimum and 1 maximum\n\nfor a
mandliyarajendra11
NORMAL
2023-02-18T17:46:47.426726+00:00
2023-02-18T17:51:05.190681+00:00
60
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nwe have 3 case for 2 element remove\n1. 2 minimum\n2. 2 maximum\n3. 1 minimum and 1 maximum\n\nfor all cases low always 0 \nand high is (as a que maximum-minimum) after remove \n2 element \n\n1. ```nums[nums.size()-1]-nums[2]```\n2. ```nums[nums.size(...
1
0
['C++']
0
minimum-score-by-changing-two-elements
C++ simple 4 line Solution
c-simple-4-line-solution-by-technoreck-l1ii
Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n if(nums.size()==3){\n return 0;\n }\n int n = nums
technoreck
NORMAL
2023-02-18T16:52:14.679938+00:00
2023-02-18T16:52:14.679972+00:00
46
false
# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n if(nums.size()==3){\n return 0;\n }\n int n = nums.size();\n sort(nums.begin(),nums.end());\n int ans1 = nums[n-3] - nums[0];\n int ans2 = nums[n-2] - nums[1];\n int ans3 = nums...
1
0
['C++']
0
minimum-score-by-changing-two-elements
100% ACCEPTANCE..VERY EASY APPROACH ...REDUCING THE MAXIMUM DIFFERENCE IN INTERVAL
100-acceptancevery-easy-approach-reducin-i94p
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
PagalavanPagal66
NORMAL
2023-02-18T16:36:46.097079+00:00
2023-02-18T16:36:46.097115+00:00
36
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(1)\n<!-- Add your space complexity here, e.g....
1
0
['Greedy', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
Easy Java Solution
easy-java-solution-by-1asthakhushi1-enf2
\n# Code\n\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n int ref=nums[2];\n int high=nums[nums.length-
1asthakhushi1
NORMAL
2023-02-18T16:04:52.170090+00:00
2024-02-27T06:26:00.610854+00:00
146
false
\n# Code\n```\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n int ref=nums[2];\n int high=nums[nums.length-1]-ref;\n int ref2=nums[nums.length-3];\n int high2=ref2-nums[0];\n \n int high3=nums[nums.length-2]-nums[1];\n return Mat...
1
0
['Array', 'Math', 'Java']
0
minimum-score-by-changing-two-elements
Easy Approach || C++✅
easy-approach-c-by-101rror-fjwb
Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums)\n {\n int n = nums.size();\n \n sort(nums.begin(), nums.end())
101rror
NORMAL
2023-02-18T16:04:07.238431+00:00
2023-02-18T16:04:07.238493+00:00
26
false
# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums)\n {\n int n = nums.size();\n \n sort(nums.begin(), nums.end());\n \n int ans = min({nums[n - 1] - nums[0], nums[n - 1] - nums[2], nums[n - 3] - nums[0], nums[n - 2] - nums[1]});\n \n return...
1
0
['Sorting', 'C++']
0
minimum-score-by-changing-two-elements
Think about corner elements after sorting
think-about-corner-elements-after-sortin-nc3e
\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& a) {\n sort(a.begin(),a.end());\n return min({\n a.back() - a[
__Abcd__
NORMAL
2023-02-18T16:02:16.100832+00:00
2023-02-18T16:02:16.100866+00:00
55
false
\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& a) {\n sort(a.begin(),a.end());\n return min({\n a.back() - a[2],\n a[size(a)-2] - a[1],\n a[size(a)-3] - a[0]\n });\n }\n};\n```
1
0
['C++']
0
minimum-score-by-changing-two-elements
3 liner | Easy C++ code 🔥🔥🔥
3-liner-easy-c-code-by-iritikkumar7-l8gp
Just check three cases\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end
iritikkumar7
NORMAL
2023-02-18T16:01:54.301011+00:00
2023-02-18T16:02:29.673023+00:00
117
false
Just check three cases\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n return min({nums[n-1]-nums[2], nums[n-3]-nums[0], nums[n-2]-nums[1]});\n }\n};\n```
1
0
['C']
1
minimum-score-by-changing-two-elements
C++ || 3 Choices Sort
c-3-choices-sort-by-up1512001-ytuk
\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n if(nums.size()<=3) return 0;\n \n vector<int> first,middle;\n
up1512001
NORMAL
2023-02-18T16:01:30.596515+00:00
2023-02-18T16:01:30.596566+00:00
165
false
```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n if(nums.size()<=3) return 0;\n \n vector<int> first,middle;\n sort(nums.begin(),nums.end());\n first = nums;\n middle = nums;\n \n nums[0] = nums[2];\n nums[1] = nums[2];\n in...
1
0
['C', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
Three Cases to Calculation
three-cases-to-calculation-by-linda2024-wcbv
IntuitionApproachComplexity Time complexity: Space complexity: Code
linda2024
NORMAL
2025-04-09T17:34:19.940082+00:00
2025-04-09T17:34:19.940082+00:00
1
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['C#']
0
minimum-score-by-changing-two-elements
Easy to understand, straightforward with explanation
easy-to-understand-straightforward-with-fon53
IntuitionAfter reading the question it was clear that ordering of elements doesn't matter and we are dealing max/min diff so sorting seemed an option, also sinc
shubham1697
NORMAL
2025-02-25T05:49:09.836452+00:00
2025-02-25T05:49:09.836452+00:00
5
false
# Intuition After reading the question it was clear that ordering of elements doesn't matter and we are dealing max/min diff so sorting seemed an option, also since we are allowed to change at most two elements so low score will always be zero as difference of equal elements is zero so we need to minimize max score onl...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Simple Intuitive Approach
simple-intuitive-approach-by-jihyuk3885-ovss
IntuitionSince low scores always become 0 after changing, it is important to make the high score small.ApproachSince the high score is the gap between the large
jihyuk3885
NORMAL
2025-02-03T11:34:01.749683+00:00
2025-02-03T11:34:01.749683+00:00
5
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Since low scores always become 0 after changing, it is important to make the high score small. # Approach <!-- Describe your approach to solving the problem. --> Since the high score is the gap between the largest and smallest values, to r...
0
0
['C++']
0
minimum-score-by-changing-two-elements
CPP | Sorting + Greedy
cpp-sorting-greedy-by-kena7-m2be
Code
kenA7
NORMAL
2025-02-03T04:29:27.012959+00:00
2025-02-03T04:29:27.012959+00:00
2
false
# Code ```cpp [] class Solution { public: int minimizeSum(vector<int>& nums) { sort(nums.begin(),nums.end()); int n=nums.size(); int res=nums[n-1]-nums[2]; res=min(res, nums[n-3]-nums[0]); res=min(res,nums[n-2]-nums[1]); return res; } }; ```
0
0
['C++']
0
minimum-score-by-changing-two-elements
python
python-by-vishwanath20023-e65t
Code
vishwanath20023
NORMAL
2025-01-27T07:46:33.361995+00:00
2025-01-27T07:46:33.361995+00:00
3
false
# Code ```python3 [] class Solution: def minimizeSum(self, nums: List[int]) -> int: nums.sort() return min((nums[-1]-nums[2]),(nums[-3]-nums[0]),(nums[-2]-nums[1])) ```
0
0
['Python3']
0
minimum-score-by-changing-two-elements
2567. Minimum Score by Changing Two Elements
2567-minimum-score-by-changing-two-eleme-o3ra
IntuitionApproachComplexity Time complexity: Space complexity: Code
G8xd0QPqTy
NORMAL
2025-01-19T03:24:29.234788+00:00
2025-01-19T03:24:29.234788+00:00
4
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Math | Simple solution with 100% beaten
math-simple-solution-with-100-beaten-by-jjif5
IntuitionTo minimize the score after modifying two elements, we must consider the difference between the largest and smallest values, as well as their "neighbor
Takaaki_Morofushi
NORMAL
2025-01-14T11:05:05.056195+00:00
2025-01-14T11:05:05.056195+00:00
6
false
# Intuition To minimize the score after modifying two elements, we must consider the difference between the largest and smallest values, as well as their "neighbors." The strategy involves identifying possible modifications to the smallest and largest values. By removing two elements, we can minimize the score by eithe...
0
0
['C++']
0
minimum-score-by-changing-two-elements
Chop chopper
chop-chopper-by-tonitannoury01-vpwq
IntuitionApproachComplexity Time complexity: O(nlog(n)) Space complexity: O(1) Code
tonitannoury01
NORMAL
2025-01-11T17:51:36.728460+00:00
2025-01-11T17:51:36.728460+00:00
6
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: O(nlog(n)) - Space complexity: O(1) # Code ```javascript [] /** * @param {number[]} nums * @return {number} */ var minimizeSum = funct...
0
0
['JavaScript']
0
minimum-score-by-changing-two-elements
C++ Greedy solution
c-greedy-solution-by-oleksam-xdjp
Please, upvote if you like it. Thanks :-)ApproachUse a greedy approach.Complexity Time complexity: O(n log(n)) Space complexity: O(1) Code
oleksam
NORMAL
2025-01-09T11:54:24.880256+00:00
2025-01-09T11:55:14.672011+00:00
4
false
Please, upvote if you like it. Thanks :-) # Approach Use a greedy approach. # Complexity - Time complexity: O(n log(n)) - Space complexity: O(1) # Code ```cpp [] int minimizeSum(vector<int>& nums) { int n = nums.size(); sort(begin(nums), end(nums)); return min( { nums[n - 2] - nums[1], ...
0
0
['Array', 'Greedy', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
// Changing the minimum or maximum values will only minimize the score is the key to solving it
changing-the-minimum-or-maximum-values-w-kym6
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
2manas1
NORMAL
2024-11-24T14:19:57.002044+00:00
2024-11-24T14:19:57.002075+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Math', 'Java']
0
minimum-score-by-changing-two-elements
Uhh... find k first min elements and k first max elements
uhh-find-k-first-min-elements-and-k-firs-j1vw
Intuition\n Describe your first thoughts on how to solve this problem. \nAnother tricky problem when reading requirement, but turns into a simple problem if you
minhtud04
NORMAL
2024-11-20T19:09:23.308869+00:00
2024-11-20T19:09:23.308901+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAnother tricky problem when reading requirement, but turns into a simple problem if you translate + rephrase it properly :)\n\nHere I need to find min-range and max-range after change k numbers. Notice that I could change to any number ->...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
100 % faster
100-faster-by-rohitgupta_2254-hdgw
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach \nSort the Array: \nSorting helps easily find the smallest and largest ele
rohitgupta_2254
NORMAL
2024-11-15T08:20:00.745318+00:00
2024-11-15T08:20:00.745355+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach \nSort the Array: \nSorting helps easily find the smallest and largest elements, and it allows us to calculate the smallest differences between consecutive elements.\n\nPossible Changes:\nAfter sorting, consider adjusting the...
0
0
['Java']
0
minimum-score-by-changing-two-elements
Minimum Score by Changing Two Elements
minimum-score-by-changing-two-elements-b-haj6
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Naeem_ABD
NORMAL
2024-11-13T05:50:03.206824+00:00
2024-11-13T05:50:03.206848+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
python - O(n)/O(1) - No Sorting/No heap
python-ono1-no-sortingno-heap-by-randomq-ly9a
Intuition\n\nThere are only 3 possibilities:\n- change the two smallest values: score becomes largest minus third smallest\n- change the two largest values: sco
randomQuant
NORMAL
2024-11-07T15:23:09.946631+00:00
2024-11-07T15:23:09.946667+00:00
0
false
# Intuition\n\nThere are only 3 possibilities:\n- change the two smallest values: score becomes largest minus third smallest\n- change the two largest values: score becomes third largest minus smallest\n- change the largest and smallest values: score becomes second largest minus second smallest\n\nWhen we change a vari...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Simple Java Solution
simple-java-solution-by-sakshikishore-l72r
Code\njava []\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n if(nums.length==3)\n {\n return
sakshikishore
NORMAL
2024-10-23T13:12:27.717306+00:00
2024-10-23T13:12:27.717337+00:00
0
false
# Code\n```java []\nclass Solution {\n public int minimizeSum(int[] nums) {\n Arrays.sort(nums);\n if(nums.length==3)\n {\n return 0;\n }\n int min=nums[nums.length-1]-nums[2];\n if(nums[nums.length-2]-nums[1]<min)\n {\n min=nums[nums.length-2]-n...
0
0
['Java']
0
minimum-score-by-changing-two-elements
O(n) heapq Solution | 235ms | Beats 99%
on-heapq-solution-235ms-beats-99-by-padt-va0y
Complexity\n- Time complexity: O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(1)\n Add your space complexity here, e.g. O(n) \n\n# Co
padth
NORMAL
2024-10-02T01:25:21.343339+00:00
2024-10-02T01:25:21.343364+00:00
3
false
# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n low = heapq.nsmallest(3, nums)\n...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
for loop python code
for-loop-python-code-by-rakshitha0912-83uq
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
rakshitha0912
NORMAL
2024-09-17T07:22:12.835674+00:00
2024-09-17T07:22:12.835707+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
c++
c-by-indian_2000error404-0xkn
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
INDIAN_2000ERROR404
NORMAL
2024-09-10T22:20:35.380817+00:00
2024-09-10T22:20:35.380835+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
c++ easy solution
c-easy-solution-by-baku12-3eiy
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
baku12
NORMAL
2024-09-10T10:36:34.001282+00:00
2024-09-10T10:36:34.001313+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
O(n) time, O(1) space, no sorting required
on-time-o1-space-no-sorting-required-by-ha1o8
Approach\nNo need to sort the array instead do the following:\n\nFind 1st 3 minimum values (low1<=low2<=low3) and 1st 3 maximum values (high1>=high2>=high3)\n\n
kakshayiitk
NORMAL
2024-09-02T14:24:24.774384+00:00
2024-09-02T14:24:24.774429+00:00
4
false
# Approach\nNo need to sort the array instead do the following:\n\nFind 1st 3 minimum values (low1<=low2<=low3) and 1st 3 maximum values (high1>=high2>=high3)\n\nAnswer is minimum difference between the pairs (high1,low3), (high2,low2), (high3,low1)\n# Complexity\n- Time complexity:\nO(n) - finding min and max values o...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
scala twoliner
scala-twoliner-by-vititov-laxz
scala []\nobject Solution {\n def minimizeSum(nums: Array[Int]): Int =\n lazy val sorted = nums.sorted\n Iterator(\n sorted(sorted.length-1) - sorte
vititov
NORMAL
2024-09-01T12:39:47.419001+00:00
2024-09-01T12:39:47.419035+00:00
0
false
```scala []\nobject Solution {\n def minimizeSum(nums: Array[Int]): Int =\n lazy val sorted = nums.sorted\n Iterator(\n sorted(sorted.length-1) - sorted(2),\n sorted(sorted.length-2) - sorted(1),\n sorted(sorted.length-3) - sorted(0)\n ).min\n}\n```
0
0
['Greedy', 'Sorting', 'Scala']
0
minimum-score-by-changing-two-elements
Greedy Solution
greedy-solution-by-ni_har15-5wdq
\n\n# Approach\nhum greedy approach laga raha hai jaha pe 3 conditions possible hai .\n1. Starting ke 2 elements equal kar do \n2. Last ke 2 elements equal ka
ni_har15
NORMAL
2024-08-22T17:59:37.149829+00:00
2024-08-22T17:59:37.149864+00:00
4
false
\n\n# Approach\nhum greedy approach laga raha hai jaha pe 3 conditions possible hai .\n1. Starting ke 2 elements equal kar do \n2. Last ke 2 elements equal kar do \n3. First aur last ke 2 elements equal kar do\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(n)\n<!-- Add y...
0
0
['Java']
0
minimum-score-by-changing-two-elements
Python - beats 99%, true O(n) runtime, no sorting
python-beats-99-true-on-runtime-no-sorti-d641
Intuition\nSorting is an O(n log n) operation, we can do this in O(n) without sorting\n\n# Approach\nIf we have 3 elements, select 1 element, the other 2 can be
j13622
NORMAL
2024-08-16T03:07:48.555415+00:00
2024-08-16T03:07:48.555435+00:00
1
false
# Intuition\nSorting is an O(n log n) operation, we can do this in O(n) without sorting\n\n# Approach\nIf we have 3 elements, select 1 element, the other 2 can be made into that element, guaranteeing a 0 solution.\n\nIf we have 4 elements, by switching 2 we guarantee that the array contains only 2 unique elements, we c...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Simple and Easy JAVA Solution , Basic maths
simple-and-easy-java-solution-basic-math-9ejh
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Triyaambak
NORMAL
2024-07-14T15:37:04.378835+00:00
2024-07-14T15:37:04.378864+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Array', 'Java']
0
minimum-score-by-changing-two-elements
Two lines is enough
two-lines-is-enough-by-fustigate-3aft
Intuition\nSince we can change two elements to any arbitrary value, we can always change them to be the same value such as the low score is always zero. \n\nNow
Fustigate
NORMAL
2024-07-04T14:21:10.557680+00:00
2024-07-04T14:21:10.557707+00:00
5
false
# Intuition\nSince we can change two elements to any arbitrary value, we can always change them to be the same value such as the low score is always zero. \n\nNow that the low score is out of the way (think of it as simply deleting two elements), we only have to try and minimize the high score to solve the problem. We ...
0
0
['Greedy', 'Python3']
0
minimum-score-by-changing-two-elements
C++ solution with explanation using greedy
c-solution-with-explanation-using-greedy-4r7r
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
roy258
NORMAL
2024-06-17T19:14:20.066634+00:00
2024-06-17T19:14:20.066663+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $...
0
0
['Greedy', 'C++']
0
minimum-score-by-changing-two-elements
Solution with sorting and changing the edges of the array.
solution-with-sorting-and-changing-the-e-82e2
Intuition\n \nEven thought the math in this question looks complex, there are some things to note:\n1. low compelxity doesnt matter, since you can always change
I1FAZEfFom
NORMAL
2024-06-17T07:16:08.294828+00:00
2024-06-17T07:16:08.294865+00:00
2
false
# Intuition\n<!-- \nEven thought the math in this question looks complex, there are some things to note:\n1. low compelxity doesnt matter, since you can always change numbers to the a same number in the array (or just both of them to the same number), resulting it to be 0.\n2. that being said, minimizing the high Score...
0
0
['C#']
0
minimum-score-by-changing-two-elements
simple 4 line solution
simple-4-line-solution-by-aryan_upadhyay-71gj
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
aryan_upadhyay
NORMAL
2024-06-02T15:07:48.452074+00:00
2024-06-02T15:07:48.452099+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
Easy sorting
easy-sorting-by-theberlinbird-bnsr
```\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n nums.sort()\n \n p1 = nums[-1] - nums[2]\n p2 = nums[-
theberlinbird
NORMAL
2024-05-01T10:15:58.727978+00:00
2024-05-01T10:15:58.728000+00:00
2
false
```\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n nums.sort()\n \n p1 = nums[-1] - nums[2]\n p2 = nums[-3] - nums[0]\n p3 = nums[-2] - nums[1]\n \n return min([p1, p2, p3])\n
0
0
['Sorting', 'Python3']
0
minimum-score-by-changing-two-elements
Simple python3 solution | O(n) time, O(1) memory | 250 ms - faster than 95.89% solutions
simple-python3-solution-on-time-o1-memor-zlfs
Complexity\n- Sorting:\n\n - Time complexity: O(n \cdot \log(n))\n - Space complexity: O(n)\n\n- Using heap:\n\n - Time complexity: O(n \cdot \log(k)) = O(n)
tigprog
NORMAL
2024-04-10T13:00:57.813574+00:00
2024-04-10T13:00:57.813597+00:00
1
false
# Complexity\n- Sorting:\n\n - Time complexity: $$O(n \\cdot \\log(n))$$\n - Space complexity: $$O(n)$$\n\n- Using heap:\n\n - Time complexity: $$O(n \\cdot \\log(k)) = O(n)$$\n - Space complexity: $$O(k) = O(1)$$\n\n\nwhere `k = 3`\n\n# Code\n``` python3 []\n# using sorting\n\nclass Solution:\n def minimizeSum(...
0
0
['Math', 'Two Pointers', 'Sorting', 'Heap (Priority Queue)', 'Python3']
0
minimum-score-by-changing-two-elements
2 Line Python Solution || Beats 96.67%
2-line-python-solution-beats-9667-by-dod-hnsu
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Dodda_Sai_Sachin
NORMAL
2024-03-19T10:10:03.496579+00:00
2024-03-19T10:10:03.496608+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
O(N) solution using max/min heap
on-solution-using-maxmin-heap-by-003213-kfj3
Intuition\n\nInstead of sorting whole array, use max/min heap to maintain top 3 largest element and top 3 smallest element.\n\n# Approach\n\n# Complexity\n- Tim
003213
NORMAL
2024-03-02T13:45:19.181420+00:00
2024-03-02T13:45:19.181456+00:00
4
false
# Intuition\n\nInstead of sorting whole array, use max/min heap to maintain top 3 largest element and top 3 smallest element.\n\n# Approach\n\n# Complexity\n- Time complexity:\nO(N)\nBut I don\'t know why this solution takes longer that typical sorting solutions.\n\n- Space complexity:\nO(N)\n\n# Code\n```\nclass Solut...
0
0
['Java']
0
minimum-score-by-changing-two-elements
Simple solution | Sorting | 3 lines
simple-solution-sorting-3-lines-by-ayush-7mpt
Intuition\nWe are getting a chance to change two numbers, so we can ignore the 1st condition of score, The low score is min(|nums[i] - nums[j]|) for all possibl
ayushannand
NORMAL
2024-02-24T11:10:29.099539+00:00
2024-02-24T11:10:29.099557+00:00
2
false
# Intuition\nWe are getting a chance to change two numbers, so we can ignore the 1st condition of score, `The low score is min(|nums[i] - nums[j]|) for all possible i & j`\nSo, say we are changing `ith` and `jth` indexes we can always make them equal to any other 3rd index, say `k`, to make `low = 0` \nNow we need to ...
0
0
['Math', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
simple c++ solution
simple-c-solution-by-spavanii822-z90h
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
spavanii822
NORMAL
2024-01-27T09:26:46.600138+00:00
2024-01-27T09:26:46.600169+00:00
2
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:o(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O...
0
0
['C++']
0
minimum-score-by-changing-two-elements
O(N) -> 95% | best solution c++
on-95-best-solution-c-by-manaspatidar-hj7m
Intuition\n Describe your first thoughts on how to solve this problem. \nthe min 2 and max 2 elements are responsible to make the high score more high and the l
ManasPatidar
NORMAL
2024-01-21T16:19:24.730456+00:00
2024-01-21T16:19:24.730480+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nthe min 2 and max 2 elements are responsible to make the high score more high and the low score can be set to zero by making two min elements equal\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\napproach 1-> first...
0
0
['C++']
0
minimum-score-by-changing-two-elements
🚀 Python Short and Fast (93.02%) Solution with friendly explanation 🚀
python-short-and-fast-9302-solution-with-16hd
Intuition\n Describe your first thoughts on how to solve this problem. \n- The first thing to think about after reading the problem is how the low score of nums
john621145
NORMAL
2024-01-21T14:31:47.478573+00:00
2024-01-21T14:31:47.478589+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The first thing to think about after reading the problem is how the low score of nums is determined and how the high score of nums is determined. The high score of nums will naturally be determined by the smallest and largest numbers in...
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Use PriorityQueue O(n)
use-priorityqueue-on-by-nicholasxie-9xfc
Intuition\nKeep track of largest 3 and smallest 3 elements, one pass.\nThis can be modifed and become full true O(n) by using 6 variables\n# Approach\n Describe
nicholasxie
NORMAL
2024-01-08T07:29:56.856327+00:00
2024-01-08T07:29:56.856346+00:00
3
false
# Intuition\nKeep track of largest 3 and smallest 3 elements, one pass.\nThis can be modifed and become full true O(n) by using 6 variables\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\nO(n* lg4 * 2 * 2)\nfor each element we need to insert to PQ then remove fr...
0
0
['Java']
0
minimum-score-by-changing-two-elements
easy understand
easy-understand-by-yishurensheng-9npi
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
yishurensheng
NORMAL
2023-12-31T06:01:12.571748+00:00
2023-12-31T06:01:12.571780+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$...
0
0
['C++']
0
minimum-score-by-changing-two-elements
Simple JAVA solution || Easy and Understandable
simple-java-solution-easy-and-understand-3uct
\nThink and Try First\n\n# Code\n\nclass Solution {\n public int minimizeSum(int[] nums) {\n int n = nums.length;\n Arrays.sort(nums);\n
Rohan__1888
NORMAL
2023-12-26T06:50:37.910524+00:00
2023-12-26T06:50:37.910555+00:00
3
false
#\nThink and Try First\n\n# Code\n```\nclass Solution {\n public int minimizeSum(int[] nums) {\n int n = nums.length;\n Arrays.sort(nums);\n int o = nums[n-1] - nums[2];\n int t = nums[n-1-2] - nums[0];\n int h = nums[n-1-1] - nums[1];\n return Math.min(o,Math.min(t,h));\n ...
0
0
['Java']
0
minimum-score-by-changing-two-elements
Java | O(N) solution | Beats 100%
java-on-solution-beats-100-by-himanshuck-c50k
Intuition\n\nThe Intuition is first sort the array and then find the minimum between 3 values ->\n\nWe can change 2 elements, and we have to find the absolute v
himanshuckh
NORMAL
2023-11-24T16:18:05.897931+00:00
2023-11-25T17:02:35.278283+00:00
2
false
# Intuition\n\nThe Intuition is first sort the array and then find the minimum between 3 values ->\n\nWe can change 2 elements, and we have to find the absolute value, the minimum would always be 0. So we need to minimze the maximum value.\n\nTo do this, we have sort the array.\n\nNow, once sorted to minimze the maximu...
0
0
['Java']
0
minimum-score-by-changing-two-elements
Java 100% faster than all users
java-100-faster-than-all-users-by-yanivc-8ghu
Intuition\nThe high score means the difference between the highest value and the lowest value. The low score means the difference between the two numbers which
yanivcohen
NORMAL
2023-11-12T00:33:00.554745+00:00
2023-11-12T00:33:00.554777+00:00
1
false
# Intuition\nThe high score means the difference between the highest value and the lowest value. The low score means the difference between the two numbers which are closest to each other. The question allows us to change two numbers. We will start by acknowledging that changing two numbers to be the same will result i...
0
0
['Java']
0
minimum-score-by-changing-two-elements
O(n) | Easy to Understand | Golang
on-easy-to-understand-golang-by-drafttin-qg8b
Suppse max1, max2, max3 represent the three largest numbers, and min1, min2 and min3 represent the three smallest numbers. By modifying two elements in the arra
drafttin
NORMAL
2023-11-05T13:14:50.013641+00:00
2023-11-05T13:14:50.013658+00:00
7
false
Suppse max1, max2, max3 represent the three largest numbers, and min1, min2 and min3 represent the three smallest numbers. By modifying two elements in the array. We can reduce the score to *min(max1 - min3, max3 - min1, max2 - min2)*\n\n# Code\n```\nfunc minimizeSum(nums []int) int {\n max1, max2, max3 := math.MinInt...
0
0
['Go']
0
minimum-score-by-changing-two-elements
Python. Easy code, using sorting
python-easy-code-using-sorting-by-zhanar-7jgs
\n# Approach\n We are trying to minimize the difference between elements, so we are checking the edges of the sorted array. \n\n\n# Code\n\nclass Solution:\n
zhanara
NORMAL
2023-10-31T07:53:59.524110+00:00
2023-10-31T07:53:59.524131+00:00
3
false
\n# Approach\n We are trying to minimize the difference between elements, so we are checking the edges of the sorted array. \n\n\n# Code\n```\nclass Solution:\n def minimizeSum(self, nums: List[int]) -> int:\n nums = sorted(nums)\n return min(nums[-1]-nums[2], nums[-3]-nums[0], nums[-2]-nums[1])\n```
0
0
['Python3']
0
minimum-score-by-changing-two-elements
Easy taking all cases possible
easy-taking-all-cases-possible-by-napan-84yr
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
napan
NORMAL
2023-10-18T03:58:28.241985+00:00
2023-10-18T03:58:28.242014+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
Easy taking all cases possible
easy-taking-all-cases-possible-by-napan-osgx
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
napan
NORMAL
2023-10-18T03:58:04.769464+00:00
2023-10-18T03:58:04.769493+00:00
0
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['C++']
0
minimum-score-by-changing-two-elements
Easy C++ 2 liner code
easy-c-2-liner-code-by-aryangarg0729-35i0
Complexity\n- Time complexity:O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(1)\n Add your space complexity here, e.g. O(n) \n\n#
aryangarg0729
NORMAL
2023-10-04T09:41:26.041663+00:00
2023-10-04T09:41:26.041681+00:00
4
false
# Complexity\n- Time complexity:$$O(nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n sort(nums.begin(),nums.end());\n ...
0
0
['Greedy', 'Sorting', 'C++']
0
minimum-score-by-changing-two-elements
easy 3 steps solution
easy-3-steps-solution-by-sonu781-xr7z
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time
Sonu781
NORMAL
2023-09-19T07:07:21.944828+00:00
2023-09-19T07:07:21.944872+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(1)\n<!-- Add your space complexity here, e....
0
0
['C++']
0
minimum-score-by-changing-two-elements
C++ Simple Solution using sorting
c-simple-solution-using-sorting-by-ujjwa-hnp8
Complexity\n- Time complexity:\nO(n log n)\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n
ujjwal141
NORMAL
2023-08-28T18:56:00.767696+00:00
2023-08-28T18:56:26.907319+00:00
7
false
# Complexity\n- Time complexity:\nO(n log n)\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Solution {\npublic:\n int minimizeSum(vector<int>& nums) {\n int n = nums.size();\n sort(nums.begin(), nums.end());\n \n // nums[0] = nums[n-1], nums[1]=a[n-1] for mx1\n int mx1 = abs(nums...
0
0
['Sorting', 'C++']
0
minimum-insertion-steps-to-make-a-string-palindrome
[Java/C++/Python] Longest Common Sequence
javacpython-longest-common-sequence-by-l-2zpa
Intuition\nSplit the string s into to two parts,\nand we try to make them symmetrical by adding letters.\n\nThe more common symmetrical subsequence they have,\n
lee215
NORMAL
2020-01-05T04:01:48.044745+00:00
2020-01-10T03:06:47.692895+00:00
33,278
false
## **Intuition**\nSplit the string `s` into to two parts,\nand we try to make them symmetrical by adding letters.\n\nThe more common symmetrical subsequence they have,\nthe less letters we need to add.\n\nNow we change the problem to find the length of longest common sequence.\nThis is a typical dynamic problem.\n<br>\...
301
6
[]
36
minimum-insertion-steps-to-make-a-string-palindrome
[C++] Simple DP (Memoization) and Bottom-up with O(n) Space
c-simple-dp-memoization-and-bottom-up-wi-51en
Observation\nLet\'s imagine matching the characters of the string like a palindrome, from the begining and the end with 2 pointers i and j.\nWe may encounter 2
phoenixdd
NORMAL
2020-01-05T04:00:58.122845+00:00
2024-11-25T04:01:34.105622+00:00
17,592
false
**Observation**\nLet\'s imagine matching the characters of the string like a palindrome, from the begining and the end with 2 pointers `i` and `j`.\nWe may encounter 2 scenarios:\n1) The character at `i` matches character at `j`.\n2) The characters don\'t match each other\n\nIn case of 1 we just increase the pointer `i...
222
5
['Dynamic Programming', 'Memoization', 'C++']
21
minimum-insertion-steps-to-make-a-string-palindrome
516. Longest Palindromic Subsequence
516-longest-palindromic-subsequence-by-v-rad5
If we figure out the longest palindromic subsequence, then we can tell the miminum number of characters to add or remove to make the string a palindrome. \n\nSo
votrubac
NORMAL
2020-01-05T04:03:33.868440+00:00
2021-04-06T17:22:48.665695+00:00
11,484
false
If we figure out the longest palindromic subsequence, then we can tell the miminum number of characters to add or remove to make the string a palindrome. \n\nSo, we can simply reuse [516. Longest Palindromic Subsequence](https://leetcode.com/problems/longest-palindromic-subsequence/).\n```CPP\nint minInsertions(string ...
118
4
[]
14
minimum-insertion-steps-to-make-a-string-palindrome
✅✅Python🔥Java 🔥C++🔥Simple Solution🔥Easy to Understand🔥
pythonjava-csimple-solutioneasy-to-under-dmr4
Please UPVOTE \uD83D\uDC4D\n\n!! BIG ANNOUNCEMENT !!\nI am Giving away my premium content videos related to computer science and data science and also will be s
cohesk
NORMAL
2023-04-22T00:07:36.886825+00:00
2023-04-22T13:16:20.902755+00:00
15,936
false
# Please UPVOTE \uD83D\uDC4D\n\n**!! BIG ANNOUNCEMENT !!**\nI am Giving away my premium content videos related to computer science and data science and also will be sharing well-structured assignments and study materials to clear interviews at top companies to my first 10,000 Subscribers. So, **DON\'T FORGET** to Subsc...
90
2
['String', 'Dynamic Programming', 'C++', 'Java', 'Python3']
1
minimum-insertion-steps-to-make-a-string-palindrome
Using LCS 🔥 C++🔥Simple Explanation 🔥Easy approach 🔥
using-lcs-csimple-explanation-easy-appro-4j9r
PLEASE UPVOTE \uD83D\uDC4D\n# Approach\n- ##### To make a string s palindrome, we need to add characters to the string such that it becomes the same when read f
ribhav_32
NORMAL
2023-04-22T00:31:16.081993+00:00
2023-04-22T00:36:51.099654+00:00
6,787
false
# **PLEASE UPVOTE \uD83D\uDC4D**\n# Approach\n- ##### To make a string s palindrome, we need to add characters to the string such that it becomes the same when read from both sides. \n- ##### The idea is to find the LCS between the original string s and its reverse string s\'. The length of LCS will give us the number ...
48
0
['String', 'Dynamic Programming', 'C++']
1
minimum-insertion-steps-to-make-a-string-palindrome
[Java/Python 3] DP - longest common subsequence w/ brief explanation and analysis.
javapython-3-dp-longest-common-subsequen-ea5a
Q & A:\n\nQ: Can you please explain more how exactly lcs with its reverse helps?\nA: An example could be illustrative. e.g., "mbadm". Let\'s mark the characters
rock
NORMAL
2020-01-05T04:01:49.500516+00:00
2023-04-22T13:34:56.726064+00:00
6,432
false
**Q & A:**\n\nQ: Can you please explain more how exactly lcs with its reverse helps?\nA: An example could be illustrative. e.g., "mbadm". Let\'s mark the characters not in LCS:\n"m`b`a`d`m"\nReverse:\n"m`d`a`b`m"\nWe need at least 2 insertions - `b` and `d` - to make them palindromes:\n"m`bd`a`db`m" or\n"m`db`a`bd`m"\n...
39
1
['Dynamic Programming', 'Java', 'Python3']
5
minimum-insertion-steps-to-make-a-string-palindrome
[C++] Intuition & Explanation Recursion To Iteration With Codes
c-intuition-explanation-recursion-to-ite-cy75
INTUITION\n Rather than thinking of it from some other problem(LCS, which most have done), I feel that it is better to visualize it as a new problem. \n When tr
gagandeepahuja09
NORMAL
2020-01-05T04:17:38.854477+00:00
2020-01-05T04:40:05.845826+00:00
2,980
false
# INTUITION\n* Rather than thinking of it from some other problem(LCS, which most have done), I feel that it is better to visualize it as a new problem. \n* When trying to check if palindrome or building a palindrome, we start from start and end chars of string\n* If chars are same, we could change it to a subproblem f...
37
1
[]
5
minimum-insertion-steps-to-make-a-string-palindrome
[Java] Longest Common Subsequence Solution - Clean code
java-longest-common-subsequence-solution-avsr
Idea\n- If we know the longest palindromic sub-sequence is x and the length of the string is n then, what is the answer to this problem? It is n - x as we need
hiepit
NORMAL
2020-01-05T04:01:11.025146+00:00
2021-07-13T02:47:38.432117+00:00
2,813
false
**Idea**\n- If we know the longest palindromic sub-sequence is `x` and the length of the string is `n` then, what is the answer to this problem? It is `n - x` as we need `n - x` insertions to make the remaining characters also palindrome.\n\n```java\nclass Solution {\n public int minInsertions(String s) {\n S...
31
1
[]
6
minimum-insertion-steps-to-make-a-string-palindrome
✔️✔️Easy Solutions in Java ✔️✔️, Python ✔️, and C++ ✔️🧐Look at once 💻 with Exaplanation
easy-solutions-in-java-python-and-c-look-nft5
Intuition\n Describe your first thoughts on how to solve this problem. \n>To make a given string s a palindrome, we need to insert characters at some positions
Vikas-Pathak-123
NORMAL
2023-04-22T06:30:51.401617+00:00
2023-04-22T06:30:51.401661+00:00
1,743
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n>To make a given string `s` a palindrome, we need to insert characters at some positions in the string. If we can find the longest common subsequence (LCS) between the given string `s` and its reverse, we can find the characters that are ...
23
2
['Dynamic Programming', 'Python', 'C++', 'Java', 'JavaScript']
0