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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
final-array-state-after-k-multiplication-operations-i | C++ || Heap | c-heap-by-shishirrsiam-ytna | Complexity
Time complexity:
Space complexity:
Code | shishirRsiam | NORMAL | 2024-12-16T03:28:39.110697+00:00 | 2024-12-16T03:28:39.110697+00:00 | 297 | false | \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)$$ -->\n\n# Code\n```cpp []\ntypedef pair<long, int> pi;\nclass Solution {\npublic:\n vector<int> getFinalState(vector<int>& nums, int k, int multiplier)... | 4 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅ Easy to Understand | 100% | Heap | Detailed Video Explanation | Java | C++ | Python🔥 | easy-to-understand-100-heap-detailed-vid-ypzm | IntuitionThe problem involves modifying the smallest elements of an array multiple times while keeping track of their positions. A priority queue (min-heap) is | sahilpcs | NORMAL | 2024-12-16T03:08:22.194915+00:00 | 2024-12-16T03:08:22.194915+00:00 | 914 | false | # Intuition\nThe problem involves modifying the smallest elements of an array multiple times while keeping track of their positions. A priority queue (min-heap) is well-suited for efficiently extracting and updating the smallest elements. By maintaining the order of elements based on value and index, we can efficiently... | 4 | 0 | ['Array', 'Heap (Priority Queue)', 'Python', 'C++', 'Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | Efficient Array Transformation Using Min-Heap Optimization || Eassy Solution | efficient-array-transformation-using-min-c38e | IntuitionThe task involves transforming an integer array by repeatedly selecting the minimum element, multiplying it by a constant, and updating the array. Usin | Aman_8808_Singh | NORMAL | 2024-12-16T02:46:43.247414+00:00 | 2024-12-16T02:46:43.247414+00:00 | 97 | false | # Intuition\nThe task involves transforming an integer array by repeatedly selecting the minimum element, multiplying it by a constant, and updating the array. Using a min-heap allows efficient access to the smallest element, ensuring we process elements correctly in ascending order.\n\n# Approach\n1. Initialization:\n... | 4 | 0 | ['Array', 'Heap (Priority Queue)', 'C++'] | 1 |
final-array-state-after-k-multiplication-operations-i | Simple Java || C++ Code ☠️ | simple-java-c-code-by-abhinandannaik1717-8bmf | \n\n# Code\njava []\nclass Solution {\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n while(k!=0){\n int[] ans = help(n | abhinandannaik1717 | NORMAL | 2024-08-25T07:45:43.520010+00:00 | 2024-08-25T07:45:43.520039+00:00 | 922 | false | \n\n# Code\n```java []\nclass Solution {\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n while(k!=0){\n int[] ans = help(nums);\n int min = ans[0];\n int mi = ans[1];\n min *= multiplier;\n nums[mi] = min;\n k--;\n }\... | 4 | 0 | ['Array', 'C++', 'Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Leetcode weekly contest 412 || Simplest Approach || No PriorityQueue || 100% beats || 3ms | leetcode-weekly-contest-412-simplest-app-dnoa | Intuition\nTo solve the problem, you need to perform k operations on an array where each operation involves finding the minimum value, replacing it with its pro | Viswas12 | NORMAL | 2024-08-25T04:12:50.000808+00:00 | 2024-08-25T04:12:50.000827+00:00 | 138 | false | # Intuition\nTo solve the problem, you need to perform k operations on an array where each operation involves finding the minimum value, replacing it with its product with a multiplier, and repeating this process k times. The challenge is to efficiently handle these operations, especially when k is large.\n\n# Approach... | 4 | 0 | ['Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | Java Simple Solution | Linear Solution | java-simple-solution-linear-solution-by-1fs4j | Code\njava []\nclass Solution {\n private int helper(int[] nums){\n int min_idx = 0;\n int min = nums[0];\n for(int i=1;i<nums.length; i | Shree_Govind_Jee | NORMAL | 2024-08-25T04:03:30.123464+00:00 | 2024-08-25T04:03:30.123499+00:00 | 449 | false | # Code\n```java []\nclass Solution {\n private int helper(int[] nums){\n int min_idx = 0;\n int min = nums[0];\n for(int i=1;i<nums.length; i++){\n if(min > nums[i]){\n min = nums[i];\n min_idx=i;\n }\n }\n return min_idx;\n }\... | 4 | 1 | ['Array', 'Math', 'Heap (Priority Queue)', 'Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | simple solution with simple logic | simple-solution-with-simple-logic-by-muh-zrp3 | IntuitionApproachcreate a new array with the elements of nums (for tracking the out put array).
create a while loop for checking the condition to break the loop | Muhamed_Reswan | NORMAL | 2024-12-16T05:18:30.577958+00:00 | 2024-12-16T05:18:30.577958+00:00 | 168 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\ncreate a new array with the elements of nums (for tracking the out put array). \ncreate a while loop for checking the condition to break the loop.\nif k > 0 enter wit... | 3 | 0 | ['Array', 'JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅✅ Most easy and simple solution 🔥🔥 | most-easy-and-simple-solution-by-ishanba-il7a | Intuition
The problem is asking us to perform k operations on an array, where each operation involves finding the smallest element in the array, multiplying it | ishanbagra | NORMAL | 2024-12-16T05:07:21.363188+00:00 | 2024-12-16T05:07:21.363188+00:00 | 152 | false | Intuition\nThe problem is asking us to perform k operations on an array, where each operation involves finding the smallest element in the array, multiplying it by a multiplier, and replacing it with the updated value. After completing the k operations, we return the final state of the array.\n\nWe can efficiently achi... | 3 | 0 | ['Array', 'Heap (Priority Queue)', 'C++'] | 1 |
final-array-state-after-k-multiplication-operations-i | Python || Heap | test-by-shishirrsiam-mvpx | Complexity
Time complexity:
Space complexity:
Code | shishirRsiam | NORMAL | 2024-12-16T03:16:36.337530+00:00 | 2024-12-16T03:22:49.902684+00:00 | 262 | false | \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)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]:\n minHeap = [(... | 3 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'Python', 'Python3'] | 1 |
final-array-state-after-k-multiplication-operations-i | Kotlin Heap | kotlin-heap-by-agent-10-0ine | Code\nkotlin []\nclass Solution {\n fun getFinalState(nums: IntArray, k: Int, multiplier: Int): IntArray {\n val pq = PriorityQueue<Int>() { a,b->\n | agent-10 | NORMAL | 2024-10-11T12:04:27.527600+00:00 | 2024-10-11T12:04:27.527631+00:00 | 30 | false | # Code\n```kotlin []\nclass Solution {\n fun getFinalState(nums: IntArray, k: Int, multiplier: Int): IntArray {\n val pq = PriorityQueue<Int>() { a,b->\n val cr = nums[a].compareTo(nums[b])\n if(cr != 0) cr else a.compareTo(b)\n }\n pq.addAll(nums.indices)\n repeat(k... | 3 | 0 | ['Kotlin'] | 3 |
final-array-state-after-k-multiplication-operations-i | Simple || Easy to Understand || 100% Beats | simple-easy-to-understand-100-beats-by-k-6nwv | 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 | kdhakal | NORMAL | 2024-09-03T18:15:17.396380+00:00 | 2024-09-03T18:15:17.396412+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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Solution | solution-by-zefry7-ebim | 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 | zefry7 | NORMAL | 2024-08-25T09:57:27.317406+00:00 | 2024-08-25T09:57:27.317445+00:00 | 110 | 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)$$ --... | 3 | 0 | ['JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% Easy Java Solution Using Priority Queue | beats-100-easy-java-solution-using-prior-urxv | Intuition\nThe problem asks us to maximize the sum of an array by multiplying the smallest element by a given multiplier k times. A greedy approach can be used | its264 | NORMAL | 2024-08-25T05:27:26.602933+00:00 | 2024-08-25T05:44:10.905682+00:00 | 137 | false | # Intuition\nThe problem asks us to maximize the sum of an array by multiplying the smallest element by a given multiplier k times. A greedy approach can be used here, where we repeatedly multiply the smallest element until k operations are performed.\n\n# Approach\n1)Create a priority queue: Use a min-heap priority qu... | 3 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | simple and easy C++ solution 😍❤️🔥 | simple-and-easy-c-solution-by-shishirrsi-a56t | \n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook | shishirRsiam | NORMAL | 2024-08-25T04:26:45.611096+00:00 | 2024-08-25T04:26:45.611114+00:00 | 349 | false | \n# if it\'s help, please up \u2B06 vote! \u2764\uFE0F\n\n###### Let\'s Connect on LinkedIn: www.linkedin.com/in/shishirrsiam\n###### Let\'s Connect on Facebook: www.fb.com/shishirrsiam\n\n\n# Complexity\n- Time complexity: O((n+k)logn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\... | 3 | 0 | ['Greedy', 'Heap (Priority Queue)', 'C++'] | 4 |
final-array-state-after-k-multiplication-operations-i | Easy Beats 100% | easy-beats-100-by-jaycodingninja-16n3 | Intuition\n Describe your first thoughts on how to solve this problem. \nGet the smallest element and multiply it but the multiplier.\n# Approach\n Describe you | JayCodingNinja | NORMAL | 2024-08-25T04:05:41.548629+00:00 | 2024-08-25T04:05:41.548656+00:00 | 346 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nGet the smallest element and multiply it but the multiplier.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Iterate k times.\n- In each iteration, find the smallest element in the vector nums using min_element.\n-... | 3 | 0 | ['C++'] | 1 |
final-array-state-after-k-multiplication-operations-i | 1ms 100% beat in java very easiest code 😊. | 1ms-100-beat-in-java-very-easiest-code-b-naxy | Code | Galani_jenis | NORMAL | 2025-01-09T08:32:55.580565+00:00 | 2025-01-09T08:32:55.580565+00:00 | 62 | false | 
# Code
```java []
class Solution {
public int[] getFinalState(int[] nums, int k, int multiplier) {
for (int i = 0; i < k; i++) {
... | 2 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | java || 1ms || faster code || easy to understand | java-1ms-faster-code-easy-to-understand-ulb9i | class Solution {\n\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n int n = nums.length;\n\n for (int j = 0; j < k; j++) {\n | Seema_Kumari1 | NORMAL | 2024-12-18T05:20:12.752285+00:00 | 2024-12-18T05:20:12.752321+00:00 | 6 | false | class Solution {\n\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n int n = nums.length;\n\n for (int j = 0; j < k; j++) {\n // Find the index of the smallest element in the array\n int minIndex = 0;\n for (int i = 0; i < n; i++) {\n if... | 2 | 0 | ['Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | 🔥 BEATS 100% | 💡BEGINNER FRIENDLY |✅ MULTI-LANGUAGE ✅ | 🌟JAVA | C++ | PYTHON | SWIFT | DART🚀 | beats-100-beginner-friendly-multi-langua-4n1s | IntuitionFind the smallest number in the list and multiply it by a given value. Repeat this process k times.ApproachIterate through the list to find the minimum | mehravarun666 | NORMAL | 2024-12-17T10:21:29.952730+00:00 | 2024-12-17T10:21:29.952730+00:00 | 21 | false | \n\n# Intuition\n**Find the smallest number in the list and multiply it by a given value. Repeat this process k times.**\n\n# Approach\n**Iterate through the list to find t... | 2 | 0 | ['Array', 'Greedy', 'Swift', 'C++', 'Java', 'Python3', 'Dart'] | 0 |
final-array-state-after-k-multiplication-operations-i | Simple solution with Kotlin | simple-solution-with-kotlin-by-penguida-cb2t | Complexity
Time complexity: 1 ms | 100 %
Space complexity: 41.81 mb | 31.58 %
Code | penguida | NORMAL | 2024-12-16T19:13:44.713173+00:00 | 2024-12-16T19:13:44.713173+00:00 | 7 | false | # Complexity\n- Time complexity: 1 ms | 100 %\n\n- Space complexity: 41.81 mb | 31.58 %\n\n# Code\n```kotlin []\nclass Solution {\n fun getFinalState(nums: IntArray, k: Int, multiplier: Int): IntArray {\n if(multiplier == 1) return nums\n\n repeat(k){\n val pos = findMin(nums)\n n... | 2 | 0 | ['Kotlin'] | 0 |
final-array-state-after-k-multiplication-operations-i | Final Array State After K Multiplication Operations | final-array-state-after-k-multiplication-2e3y | Approach
Run a loop for k iterations.
In each iteration:
Find the minimum value in the array.
Multiply this minimum value by the multiplier.
Update the array w | HarisubashThangavel | NORMAL | 2024-12-16T16:56:38.344113+00:00 | 2024-12-16T16:56:38.344113+00:00 | 9 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n1. Run a loop for k iterations.\n2. In each iteration:\n * Find the minimum value in the array.\n * Multiply this minimum value by the multiplier.\n * Update the array with the modified minimum value while keeping other values unchanged.\n\nR... | 2 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | SIMPLE AND EASY SOLUTION IN JAVA || BEATS 100% USERS..... | simple-and-easy-solution-in-java-beats-1-lcfn | Complexity
Time complexity: O(K*N)
Space complexity: O(1)
Code | abhayCodez | NORMAL | 2024-12-16T16:21:09.980437+00:00 | 2024-12-16T16:21:09.980437+00:00 | 28 | false | # Complexity\n- Time complexity: O(K*N)\n\n- Space complexity: O(1)\n# Code\n```java []\nclass Solution {\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n for(int i=1;i<=k;i++){\n int min = minimum(nums);\n nums[min] *= multiplier;\n }\n return nums;\n ... | 2 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% | Brute Force | beats-100-brute-force-by-akshatchawla130-0dty | IntuitionApproachComplexity
Time complexity: O(k*n)
Space complexity:I= O(1)
Code | akshatchawla1307 | NORMAL | 2024-12-16T15:13:25.799775+00:00 | 2024-12-16T15:13:25.799775+00:00 | 8 | 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(k*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:I= O(1)\n<!-- Add your space complexity here, e.... | 2 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | ||💀|| 1 MS🔥-- BEATS 100%✅-- EASY JAVA SOLUTION | 1-ms-beats-100-easy-java-solution-by-san-bg1x | IntuitionThe problem involves modifying an array by multiplying its smallest element by a given multiplier repeatedly for k iterations. The goal is to return th | sanketborse | NORMAL | 2024-12-16T12:51:46.829699+00:00 | 2024-12-16T12:58:50.889209+00:00 | 12 | false | # Intuition\n\nThe problem involves modifying an array by multiplying its smallest element by a given multiplier repeatedly for k iterations. The goal is to return the modified array after all operations.\n\nThe intuition is straightforward:\n- Find the smallest element in the array.\n- Multiply this smallest element b... | 2 | 0 | ['Array', 'Math', 'Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅Simple Brute force, two loop, ⭐Beats 100%✅ ⭐Java solution⭐✅ | simple-brute-force-two-loop-beats-100-ja-sr58 | IntuitionI applied brute force approach, (first loop) we need to run operation k times, (second loop) In each operation we need to find minimun(x) and then repl | bhaskarindiapandey | NORMAL | 2024-12-16T12:23:42.811666+00:00 | 2024-12-16T12:23:42.811666+00:00 | 11 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nI applied brute force approach, (first loop) we need to run operation k times, (second loop) In each operation we need to find minimun(x) and then replace that one with (x*multiplier).\n# Approach\n<!-- Describe your approach to solving t... | 2 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Easy Priority Queue Solution 🚀🏆 | easy-priority-queue-solution-by-sanchitb-a5ir | IntuitionWe need to perform k operations on an integer array. In each operation, we identify the smallest value, multiply it by a given multiplier, and then rep | sanchitbajaj02 | NORMAL | 2024-12-16T11:13:42.834706+00:00 | 2024-12-16T11:13:42.834706+00:00 | 78 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe need to perform `k` operations on an integer array. In each operation, we identify the smallest value, multiply it by a given `multiplier`, and then replace the original value with the new one. The main challenge is to efficiently trac... | 2 | 0 | ['Heap (Priority Queue)', 'Simulation', 'JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | Swift | Simple | swift-simple-by-rokimkar-vpop | ApproachSort the nums array keeping indices location intact. pick the first number from the array(it will be lowest always and index does not matter), now multi | rokimkar | NORMAL | 2024-12-16T09:37:30.364589+00:00 | 2024-12-16T09:37:30.364589+00:00 | 39 | false | # Approach\nSort the nums array keeping indices location intact. pick the first number from the array(it will be lowest always and index does not matter), now multiply the number with multiplier, delete the number from array and insert it back in the array based on value(binary searh) if multiplied value already exists... | 2 | 0 | ['Swift'] | 1 |
final-array-state-after-k-multiplication-operations-i | C++ || Priority Queue || Easy Approach | c-priority-queue-easy-approach-by-that_1-t9bu | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | that_1guy__ | NORMAL | 2024-12-16T09:23:17.037852+00:00 | 2024-12-16T09:23:17.037852+00:00 | 60 | 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)$$ --... | 2 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'C++'] | 1 |
final-array-state-after-k-multiplication-operations-i | Beats 100% of users runtime | beats-100-of-users-runtime-by-dev_bhatt2-46np | Complexity
Time complexity:O(N) | dev_bhatt202 | NORMAL | 2024-12-16T08:44:02.086129+00:00 | 2024-12-16T08:44:02.086129+00:00 | 13 | false | # Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n```java []\nclass Solution {\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n int[] arr = new int[2];\n\n for (int i = 0; i < k; i++) {\n arr = getMin(nums);\n nums[ar... | 2 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | 0 ms BEATS 100% || EASY 3 LINES OF CODE | 0-ms-beats-100-easy-3-lines-of-code-by-d-btwn | Code | deepakk2510 | NORMAL | 2024-12-16T08:23:35.836946+00:00 | 2024-12-16T08:23:35.836946+00:00 | 68 | false | \n\n# Code\n```cpp []\nclass Solution {\npublic:\n vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {\n while(k--){\n auto min_itr = min_element(nums.begin(),nums.end());\n *min_itr = (*min_itr)*multiplier;\n }\n return nums;\n }\n};\n``` | 2 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% Easy Approach 🔥 | beats-100-easy-approach-by-anushka_011-e06g | IntuitionThe task is to repeatedly update the smallest element in the array by multiplying it with a given multiplier. After k operations, return the final stat | Anushka_011 | NORMAL | 2024-12-16T08:18:36.911024+00:00 | 2024-12-16T08:18:36.911024+00:00 | 69 | false | # Intuition\nThe task is to repeatedly update the smallest element in the array by multiplying it with a given multiplier. After k operations, return the final state of the array.\n\n# Approach\nFor each of the k operations:\n- Find the smallest element in the array using min_element.\n- Update the first occurrence of ... | 2 | 0 | ['Array', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Java Solution | java-solution-by-ruch21-0rgz | Code | ruch21 | NORMAL | 2024-12-16T08:04:21.745043+00:00 | 2024-12-16T08:04:39.258628+00:00 | 163 | false | \n# Code\n```java []\nclass Solution {\n class Node implements Comparable<Node> {\n int num;\n int idx;\n public Node(int num, int idx) {\n this.num = num;\n this.idx = idx;\n }\n @Override\n public int compareTo(Node n) {\n if(this.num == n.... | 2 | 0 | ['Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | 🔥SIMPILL💯 % 🎯 |✨SUPER EASY BEGINNERS 👏 | simpill-super-easy-beginners-by-codewith-hsyg | IntuitionThe problem revolves around performing k operations on an array to modify the smallest element each time. Each modification multiplies the smallest ele | CodeWithSparsh | NORMAL | 2024-12-16T06:56:12.623007+00:00 | 2024-12-16T07:04:58.128115+00:00 | 312 | false | \n\n\n\n---\n\n# Intuition\nThe problem revolves around performing `k` operations on an array to modify the smallest element each time. Each modification multiplies the smallest element by a given multiplie... | 2 | 0 | ['Array', 'Math', 'C', 'Heap (Priority Queue)', 'C++', 'Java', 'Go', 'Python3', 'JavaScript', 'Dart'] | 1 |
final-array-state-after-k-multiplication-operations-i | Beats 100% of user with C++ | beats-100-of-user-with-c-by-sahilsaw-1lam | IntuitionThe problem involves repeatedly applying a transformation to the smallest element in the array and tracking its position. This suggests using a data st | SahilSaw | NORMAL | 2024-12-16T06:47:50.956419+00:00 | 2024-12-16T06:47:50.956419+00:00 | 17 | false | # Intuition\nThe problem involves repeatedly applying a transformation to the smallest element in the array and tracking its position. This suggests using a data structure that efficiently retrieves and updates the smallest elements, such as a priority queue (min-heap). By keeping track of indices, we ensure the correc... | 2 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | 100% acceptance | 2 methods | using loops | heaps | 100-acceptance-2-methods-using-loops-hea-rvb4 | we can go to the array k times and for each time we will calculate the minimum value as well as its index in the array
that minimum index is then updated with t | Shyyshawarma | NORMAL | 2024-12-16T05:51:44.711658+00:00 | 2024-12-16T05:51:44.711658+00:00 | 83 | false | <!-- # Intuition -->\n\n\nwe can go to the array k times and for each time we will calculate the minimum value as well as its index in the array\nthat mini... | 2 | 0 | ['C++'] | 1 |
final-array-state-after-k-multiplication-operations-i | 🚀 Efficient Solution using nested loop🌟 | efficient-solution-using-nested-loop-by-waw3n | IntuitionThe problem requires us to modify an array k times by repeatedly multiplying the smallest element by a given multiplier. Each operation seeks the curre | shoaibkhalid65 | NORMAL | 2024-12-16T04:10:44.946898+00:00 | 2024-12-16T04:10:44.946898+00:00 | 167 | false | # Intuition\nThe problem requires us to modify an array k times by repeatedly multiplying the smallest element by a given multiplier. Each operation seeks the current minimum, modifies it, and updates the array. This leads to an iterative optimization of the array values.\n\n# Approach\nInitialization:\nStart with the ... | 2 | 0 | ['Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | C# Solution for Find Array State After K Multiplication Operations I Problem | c-solution-for-find-array-state-after-k-7p3sr | IntuitionThe problem involves performing k operations where the smallest element in the array is updated. Instead of scanning the array repeatedly to find the m | Aman_Raj_Sinha | NORMAL | 2024-12-16T04:02:10.132093+00:00 | 2024-12-16T04:02:10.132093+00:00 | 77 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem involves performing k operations where the smallest element in the array is updated. Instead of scanning the array repeatedly to find the minimum, the intuition behind this solution is to use a priority queue (min-heap) to:\n1... | 2 | 0 | ['C#'] | 0 |
final-array-state-after-k-multiplication-operations-i | Heap vs. Peep: The Battle of Brains vs. Brawn in Multiplying the Smallest! | 2 Solutions | heap-vs-peep-the-battle-of-brains-vs-bra-3u7h | IntuitionThe problem involves repeatedly multiplying the smallest element of an array by a given multiplier k times. The goal is to efficiently determine the fi | ParthSaini1353 | NORMAL | 2024-12-16T04:00:56.566712+00:00 | 2024-12-16T04:00:56.566712+00:00 | 23 | false | # Intuition\nThe problem involves repeatedly multiplying the smallest element of an array by a given multiplier k times. The goal is to efficiently determine the final state of the array.\n\nKey observation: At each step, the smallest element in the array needs to be identified and updated.\nOptimization trade-off: The... | 2 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅Final Array State After K Multiplication Operations I - Simple Java Solution | Beats 100%✅ | final-array-state-after-k-multiplication-ohs9 | Intuition 💡The problem asks us to perform a series of operations on an array. In each operation, we find the smallest number, multiply it by a given multiplier, | Ram4366 | NORMAL | 2024-12-16T03:51:55.796216+00:00 | 2024-12-16T03:51:55.796216+00:00 | 26 | false | # Intuition \uD83D\uDCA1\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem asks us to perform a series of operations on an array. In each operation, we find the smallest number, multiply it by a given multiplier, and replace the number in the array. We repeat this process k times.\n\nTo ... | 2 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | (8ms) PriorityQueue(PairComparator) | 8ms-priorityqueuepaircomparator-by-sav20-xe52 | ApproachPriorityQueue(PairComparator)ComplexityCodeAnd this is just an interesting option: | sav20011962 | NORMAL | 2024-12-16T03:29:26.211108+00:00 | 2024-12-16T06:02:45.066061+00:00 | 48 | false | # Approach\nPriorityQueue(PairComparator)\n# Complexity\n\n# Code\n```kotlin []\nclass Solution {\n object PairComparator : Comparator<Pair<Int,Int>> {\n override fun compare(a: Pair<Int,Int>, b: ... | 2 | 0 | ['Kotlin'] | 1 |
final-array-state-after-k-multiplication-operations-i | C#: Min Heap Approach | c-min-heap-approach-by-niteeshyarra-ad30 | IntuitionAs this question is asking to work with the mininum element each time after an operation is done, think of how you can obtain a minimum element efficen | niteeshyarra | NORMAL | 2024-12-16T01:57:55.179982+00:00 | 2024-12-16T01:57:55.179982+00:00 | 146 | false | # Intuition\nAs this question is asking to work with the mininum element each time after an operation is done, think of how you can obtain a minimum element efficently. Sorting the array? Works!! you sort the array after each operation. you sort the array k time and you will have k * n log n\n\nEven efficient way is to... | 2 | 0 | ['C#'] | 2 |
final-array-state-after-k-multiplication-operations-i | One-Line Solution | Beats 100% | C++ | one-line-solution-beats-100-c-by-benjami-9wx0 | IntuitionModify the smallest element in the array k times using the multiplier.ApproachRepeatedly use min_element to find and update the smallest element in the | benjami4n | NORMAL | 2024-12-16T01:29:17.887344+00:00 | 2024-12-16T01:29:17.887344+00:00 | 274 | false | \n\n\n# Intuition\nModify the smallest element in the array `k` times using the multiplier.\n\n# Approach\nRepeatedly use `min_element` to find and update the smallest element in the array `k` times, direct... | 2 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Easy Heap | easy-heap-by-mechan0-393j | Complexity
Time complexity:
O(nlogn)
Space complexity:
O(n)
Code | mechan0 | NORMAL | 2024-12-16T00:50:21.062665+00:00 | 2024-12-16T00:50:21.062665+00:00 | 110 | false | # Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n```swift []\nimport Collections\nclass Solution {\n struct Entry: Comparable {\n let val: Int\n let index: Int\n public static func < (lhs: Entry, rhs: Entry) -> Bool {\n return lhs.val == rhs.val ? lhs... | 2 | 0 | ['Swift', 'Heap (Priority Queue)'] | 2 |
final-array-state-after-k-multiplication-operations-i | Simple brute force Rust solution in 4 lines. Time O(n*k), space O(1). | simple-brute-force-rust-solution-in-4-li-0jor | Approach\nBecause the array is at most 100 elements long it is very fast to find the smallest element each time we perform the operation by doing a linear searc | JSorngard | NORMAL | 2024-11-19T14:33:41.051384+00:00 | 2024-11-19T14:33:41.051419+00:00 | 62 | false | # Approach\nBecause the array is at most 100 elements long it is very fast to find the smallest element each time we perform the operation by doing a linear search.\n\n# Complexity\n- Time complexity: O(n*k)\n\n- Space complexity: O(1)\n\n# Code\n```rust []\nimpl Solution {\n pub fn get_final_state(mut nums: Vec<i32... | 2 | 0 | ['Simulation', 'Rust'] | 0 |
final-array-state-after-k-multiplication-operations-i | Solution with explanation | solution-with-explanation-by-ravi_ksk-66rg | Intuition\n1. We need to maintain the elements of the array in sorted order with their indexes. \na. For this we can use PriorityQueue\nb. Custom compare functi | ravi_ksk | NORMAL | 2024-08-25T06:58:42.819831+00:00 | 2024-08-25T06:58:42.819858+00:00 | 332 | false | # Intuition\n1. We need to maintain the elements of the array in sorted order with their indexes. \na. For this we can use PriorityQueue\nb. Custom compare function to compare element value and their index if they are equal.\n\n```\n [1, 1]\n / \\\n [2, 0] [3, 2]\n / \\\n[5, 3] [6, 4]\n```\n... | 2 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Easiest Solution With Explanation Javascript, JAVA | easiest-solution-with-explanation-javasc-jxl5 | Intuition\nThe goal is to repeatedly apply an operation on an array nums to achieve the final state. The operation involves finding the smallest number in the a | hashcoderz | NORMAL | 2024-08-25T04:38:48.571990+00:00 | 2024-08-25T04:38:48.572019+00:00 | 347 | false | ## Intuition\nThe goal is to repeatedly apply an operation on an array nums to achieve the final state. The operation involves finding the smallest number in the array and multiplying it by a given multiplier. We need to perform this operation k times.\n\n## Approach\n1. Initialization: Start by iterating while there a... | 2 | 0 | ['Java', 'TypeScript', 'JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | beats 100% | beats-100-by-shobit000-dww4 | Intuition\n Repeated Minimization: We need to repeatedly find and modify the smallest value in the array. Given that k operations need to be performed, this mea | shobit000 | NORMAL | 2024-08-25T04:21:26.240228+00:00 | 2024-08-25T04:21:26.240245+00:00 | 82 | false | # Intuition\n Repeated Minimization: We need to repeatedly find and modify the smallest value in the array. Given that k operations need to be performed, this means repeatedly updating the smallest element for a specified number of operations.\n\nOrder Preservation: When multiple minimum values are present, the first o... | 2 | 0 | ['Java'] | 2 |
final-array-state-after-k-multiplication-operations-i | beats 100% time ans space||SIMPLE SOLUTION FOR BEGINNERS||JAVA,C++,PYTHON | beats-100-time-ans-spacesimple-solution-yqu5u | \n\nTo solve the problem, we need to perform k operations on the array nums, where in each operation, we DO THE FOLOWING :\n\n1. Find the minimum value in nums. | MD__JAKIR1128__ | NORMAL | 2024-08-25T04:13:37.812064+00:00 | 2024-08-25T05:52:35.704328+00:00 | 21 | false | \n\nTo solve the problem, we need to perform `k` operations on the array `nums`, where in each operation, we DO THE FOLOWING :\n\n1. Find the minimum value in `nums`.\n2. Replace the first occurrence of that mi... | 2 | 0 | [] | 1 |
final-array-state-after-k-multiplication-operations-i | Using inbuilt functin min_function in 0 ms runtime easy C++ solution | using-inbuilt-functin-min_function-in-0-wlllb | Code | sameerrswami | NORMAL | 2025-04-09T17:27:57.275572+00:00 | 2025-04-09T17:27:57.275572+00:00 | 8 | false |
# Code
```cpp []
class Solution {
public:
vector<int> getFinalState(vector<int>& nums, int k, int m) {
for(int i=0;i<k;i++){
int x=*min_element(nums.begin(),nums.end());
for(int &n:nums){
if(n==x){
n*=m;
break;
... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Final Array State After K Multiplication Operations I | final-array-state-after-k-multiplication-53p6 | IntuitionApproachComplexity
Time complexity:
O(n2)
Space complexity:
O(1)Code | Vinil07 | NORMAL | 2025-04-01T04:55:51.971317+00:00 | 2025-04-01T04:55:51.971317+00:00 | 37 | 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)$$ -->
O(n2)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(1... | 1 | 0 | ['Array', 'Math', 'Simulation', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | MinHeap | minheap-by-samuel_k276-oxco | Approach
Heap Initialization:
Store each number along with its index as a tuple (value, index).
This helps us maintain order while modifying values.
Proce | Samuel_k276 | NORMAL | 2025-03-31T20:28:35.884416+00:00 | 2025-03-31T20:28:35.884416+00:00 | 23 | false | # Approach
1. Heap Initialization:
- Store each number along with its index as a tuple `(value, index)`.
- This helps us maintain order while modifying values.
2. Processing k Operations:
- Pop the **smallest value** from the heap (since `heapq` implements a min heap).
- Multiply it by `multiplier` and push it bac... | 1 | 1 | ['Heap (Priority Queue)', 'Python3'] | 0 |
final-array-state-after-k-multiplication-operations-i | Java Code || Simple Logic || Beats 100% | java-code-simple-logic-beats-100-by-adit-ok7z | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | AdityaRalhan | NORMAL | 2025-03-19T17:22:13.365808+00:00 | 2025-03-19T17:22:13.365808+00:00 | 61 | 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
`... | 1 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Simple Solution | simple-solution-by-shreyas_kumar_m-ldcj | Code | Shreyas_kumar_m | NORMAL | 2025-03-02T02:24:17.243719+00:00 | 2025-03-02T02:24:17.243719+00:00 | 23 | false |
# Code
```javascript []
/**
* @param {number[]} nums
* @param {number} k
* @param {number} multiplier
* @return {number[]}
*/
var getFinalState = function(nums, k, multiplier) {
for(let i=0;i<k;i++){
let min = Math.min(...nums);
let ind = nums.indexOf(min);
nums[ind] = min*multiplier;
... | 1 | 0 | ['JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beginner's friendly solution 🔥 | Simple and easy to understand ✅ | beginners-friendly-solution-simple-and-e-xhpf | IntuitionThe problem requires modifying the k smallest elements in an array by multiplying them with a given multiplier. The goal is to update the array k times | NadeemMohammed | NORMAL | 2025-02-28T04:56:37.456799+00:00 | 2025-02-28T04:56:37.456799+00:00 | 20 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires modifying the k smallest elements in an array by multiplying them with a given multiplier. The goal is to update the array k times while always modifying the smallest element in each step.
# Approach
<!-- Describe your... | 1 | 0 | ['JavaScript'] | 0 |
final-array-state-after-k-multiplication-operations-i | Java easiest solution | java-easiest-solution-by-shreyagarg63-rdln | Complexity
Time complexity: O(N^2)
Space complexity: O(1)
Code | ShreyaGarg63 | NORMAL | 2025-02-23T18:16:30.931718+00:00 | 2025-02-23T18:16:30.931718+00:00 | 59 | false | # Complexity
- Time complexity: O(N^2)
- Space complexity: O(1)
# Code
```java []
class Solution {
public int[] getFinalState(int[] nums, int k, int multiplier) {
while(k>0){
int min = 0;
for(int i=0; i<nums.length; i++){
if(nums[i] < nums[min]){
... | 1 | 0 | ['Array', 'Math', 'Simulation', 'Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beat 100% using loops | beat-100-using-loops-by-vamshikrishnan-arqb | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | vamshikrishnan | NORMAL | 2025-02-17T13:38:08.726546+00:00 | 2025-02-17T13:38:08.726546+00:00 | 52 | 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
`... | 1 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | 100 % beats | | C++ 🎊 🔥 | 100-beats-c-by-varuntyagig-ib28 | Complexity
Time complexity:
O(k∗n)
Space complexity:
O(1)
Code | varuntyagig | NORMAL | 2025-02-07T18:32:35.804360+00:00 | 2025-02-07T18:32:35.804360+00:00 | 35 | false | # Complexity
- Time complexity:
$$O(k*n)$$
- Space complexity:
$$O(1)$$
# Code
```cpp []
class Solution {
public:
vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {
int indices = -1, mini = INT_MAX;
while (k) {
for (int i = 0; i < nums.size(); i++) {
... | 1 | 0 | ['Array', 'Math', 'Simulation', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beat 100 % || Cpp STL || ONLY 4 LINES!!!!!|| UPVOTE!!!! | beat-100-cpp-stl-only-4-lines-upvote-by-lhi9g | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | cardze | NORMAL | 2024-12-30T07:56:22.295686+00:00 | 2024-12-30T07:57:24.727378+00:00 | 18 | 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
`... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | EASY TO UNDERSTAND | BEGINNER FRIENDLY | 3ms RUNTIME | C# | easy-to-understand-beginner-friendly-3ms-3lmh | \npublic class Solution {\n public int[] GetFinalState(int[] nums, int k, int multiplier) {\n \n for(int i=0; i< k; i++){\n int min | tyagideepti9 | NORMAL | 2024-12-16T17:24:33.093000+00:00 | 2024-12-16T17:24:33.093036+00:00 | 4 | false | ```\npublic class Solution {\n public int[] GetFinalState(int[] nums, int k, int multiplier) {\n \n for(int i=0; i< k; i++){\n int min = nums.Min();\n int index = Array.IndexOf(nums, min);\n \n nums[index] = min*multiplier;\n }\n \n retur... | 1 | 0 | [] | 0 |
final-array-state-after-k-multiplication-operations-i | priority queue | priority-queue-by-mr_stark-nzeo | \nclass Solution {\npublic:\n \n static bool comp(pair<int,int> x, pair<int,int> y)\n {\n return x.second<y.second;\n }\n vector<int> getF | mr_stark | NORMAL | 2024-12-16T07:32:12.229453+00:00 | 2024-12-16T07:32:12.229491+00:00 | 20 | false | ```\nclass Solution {\npublic:\n \n static bool comp(pair<int,int> x, pair<int,int> y)\n {\n return x.second<y.second;\n }\n vector<int> getFinalState(vector<int>& a, int k, int m) {\n \n priority_queue<pair<int,int> , vector<pair<int,int>> , greater<pair<int,int>>> pq;\n int ... | 1 | 0 | ['C'] | 0 |
final-array-state-after-k-multiplication-operations-i | Shortest Python solutions (4 and 6 lines) | shortest-python-solutions-4-and-6-lines-qtol4 | Code | sjamr10 | NORMAL | 2024-12-28T15:32:00.089863+00:00 | 2024-12-28T15:32:00.089863+00:00 | 29 | false | # Code
```python3 []
class Solution:
# Time Complexity: O(n * k)
# Space Complexity: O(1)
def getFinalState0(self, nums: List[int], k: int, multiplier: int) -> List[int]:
for _ in range(k):
idx = min(range(len(nums)), key=lambda x: nums[x])
nums[idx] *= multiplier
ret... | 1 | 0 | ['Python3'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% || Easy Sol || used iterator || without priority_queue solution | beats-100-easy-sol-used-iterator-with-pr-2trw | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | oso_valid | NORMAL | 2024-12-25T20:17:38.834200+00:00 | 2024-12-26T18:33:07.910164+00:00 | 13 | 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
`... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | beats 100% using recursion(backtracking) c++💥💣🔥 | beats-100-using-recursionbacktracking-c-f73c4 | IntuitionThe problem requires repeatedly modifying the smallest element of the array by multiplying it by a given factor m for k iterations.
The main observatio | nourine-rgb | NORMAL | 2024-12-17T10:10:44.728861+00:00 | 2024-12-17T10:10:44.728861+00:00 | 4 | false | # Intuition\n\nThe problem requires repeatedly modifying the smallest element of the array by multiplying it by a given factor m for k iterations.\nThe main observation is that findin... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% using 1 nested loop | simple-answer-that-beats-100-by-saksham_-tc5p | IntuitionApproachComplexity
Time complexity: O(n)
Space complexity: O(1)
Code | Saksham_Gupta_ | NORMAL | 2024-12-17T06:51:40.253115+00:00 | 2024-12-17T06:57:07.506584+00:00 | 9 | 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(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. $... | 1 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Mutable & Immutable scala solutions | mutable-scala-solution-by-poiug07-5xhi | IntuitionI just code.ApproachSame approach as countless others.Complexity
Time complexity: O(max(n,klogn)) Assuming priority queue construction is O(n).
Spac | poiug07 | NORMAL | 2024-12-17T01:01:26.241566+00:00 | 2024-12-17T01:16:31.020179+00:00 | 9 | false | # Intuition\nI just code.\n\n# Approach\nSame approach as countless others.\n\n# Complexity\n- Time complexity: $O(\\text{max}(n, k \\log n))$ _Assuming priority queue construction is $O(n)$_.\n\n- Space complexity: $O(n)$\n\n# Code\n```scala []\nimport scala.collection.mutable.PriorityQueue\nobject Solution {\n def... | 1 | 0 | ['Scala'] | 1 |
final-array-state-after-k-multiplication-operations-i | Basic approach | Python | basic-approach-python-by-deviraju999-xojt | IntuitionApproachLoop through the 'k' and replace the smallest with the new multiplied numberComplexity
Time complexity:
Space complexity:
Code | deviraju999 | NORMAL | 2024-12-16T23:51:58.078976+00:00 | 2024-12-16T23:51:58.078976+00:00 | 12 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nLoop through the \'k\' and replace the smallest with the new multiplied number\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... | 1 | 0 | ['Python'] | 0 |
final-array-state-after-k-multiplication-operations-i | Brute force C++ solution | brute-force-c-solution-by-mohamed-elsogh-auxh | Code | Mohamed-Elsogher | NORMAL | 2024-12-16T22:15:27.267419+00:00 | 2024-12-16T22:15:27.267419+00:00 | 6 | false | # Code\n```cpp []\nclass Solution {\npublic:\n vector<int> getFinalState(vector<int>& nums, int k, int multiplier) {\n \n\n while(k--){\n int min = INT_MAX;\n int mini = -1;\n for(int i = 0 ; i < nums.size() ; i++){\n if(nums[i] < min){\n min = nums[i];... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Python min heap, beats 100% | python-min-heap-beats-100-by-martensova-zy4k | IntuitionUse a priority queue / heap to keep track of the current minumum value in the array.ApproachBuild a heap using Python's heapq module. Populate it with | martensova | NORMAL | 2024-12-16T21:57:50.308246+00:00 | 2024-12-16T21:57:50.308246+00:00 | 7 | false | # Intuition\nUse a priority queue / heap to keep track of the current minumum value in the array.\n\n# Approach\nBuild a heap using Python\'s `heapq` module. Populate it with (`value`, `index`) pairs based on the original list.\nNow we do the following steps `k` times.\n1. Pop the smallest value from the heap.\n2. Upda... | 1 | 0 | ['Python3'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅ Python - Quick and Easy - 100% ✅ | python-quick-and-easy-100-by-danielol-0lsk | Code | DanielOL | NORMAL | 2024-12-16T20:57:29.620023+00:00 | 2024-12-16T20:57:29.620023+00:00 | 12 | false | # Code\n```python3 []\nclass Solution:\n def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]:\n \n pq = []\n\n for i, n in enumerate(nums):\n heapq.heappush(pq, (n, i))\n\n while k > 0:\n\n n, i = heapq.heappop(pq)\n\n heapq.heap... | 1 | 0 | ['Python3'] | 1 |
final-array-state-after-k-multiplication-operations-i | 🚀Beats 99%, Python3, Heap, easy to understand🚀 | beats-99-python3-heap-easy-to-understand-1nfy | Complexity
Time complexity: O(nlogn)
Space complexity: O(n)
Code | mak2rae | NORMAL | 2024-12-16T20:27:11.719007+00:00 | 2024-12-16T20:27:11.719007+00:00 | 9 | false | # Complexity\n- Time complexity: O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]:\n min... | 1 | 0 | ['Heap (Priority Queue)', 'Python3'] | 0 |
final-array-state-after-k-multiplication-operations-i | ✅😮only 4 lines| beats 100%🔥🔥🔥 | beats-100-4-lines-solution-for-beginners-mmdj | IntuitionApproachComplexity
Time complexity:O(k*n)
Space complexity:O(1)
Code | robusttt | NORMAL | 2024-12-16T19:40:41.050329+00:00 | 2024-12-16T20:53:55.517121+00:00 | 11 | 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(k*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. $... | 1 | 0 | ['Array', 'Math', 'Heap (Priority Queue)', 'Simulation', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | 🎉BEATS 100%🏆| Most Efficient O(k * n) time🕒 Easiest Greedy Approach Explained🌟 | PHP | beats-100-most-efficient-ok-n-time-easie-gl3x | Intuition:The problem asks you to modify an array nums by performing k operations. In each operation:
Find the smallest number in the array (min(nums)).
Multipl | webdevanjali | NORMAL | 2024-12-16T18:55:09.051976+00:00 | 2024-12-16T19:01:39.260445+00:00 | 8 | false | # Intuition:\nThe problem asks you to modify an array `nums` by performing `k` operations. In each operation:\n- Find the smallest number in the array (`min(nums)`).\n- Multiply that smallest number by a given `multiplier`.\n- Update the array by replacing the smallest number with its multiplied value.\n\nThe idea is t... | 1 | 0 | ['Array', 'Math', 'PHP', 'Simulation'] | 0 |
final-array-state-after-k-multiplication-operations-i | Easy solution simple implementation of min heap | easy-solution-simple-implementation-of-m-jg36 | Intuitionmin heap and arrayApproachmake a min heap , store elements and its idx , at top of min heap min element and its idx will be present , take that out and | Shivesh977 | NORMAL | 2024-12-16T18:44:57.101308+00:00 | 2024-12-16T18:44:57.101308+00:00 | 10 | false | # Intuition\nmin heap and array \n\n# Approach\nmake a min heap , store elements and its idx , at top of min heap min element and its idx will be present , take that out and multiply with multiplier and again push in heap , again repeat this k times , at end pop out elements of heap and store in vector and return that... | 1 | 0 | ['C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | BYOH approach (Bring Your Own Heap :) ) | byoh-approach-bring-your-own-heap-by-kus-nazq | IntuitionJust a Greedy Approach with custom made min heapComplexity
Time complexity:
klog(n)
Space complexity:
o(n)
Code | kushalbanik | NORMAL | 2024-12-16T17:46:49.311869+00:00 | 2024-12-16T17:57:08.531879+00:00 | 18 | false | # Intuition\nJust a Greedy Approach with custom made min heap\n\n# Complexity\n- Time complexity:\n klog(n)\n\n- Space complexity:\n o(n)\n\n# Code\n```java []\nclass Solution {\n class heap{\n private void heapify(int idx,int n,Pair<Integer,Integer>[] nums){\n int lid... | 1 | 0 | ['Heap (Priority Queue)', 'Java'] | 1 |
final-array-state-after-k-multiplication-operations-i | Simple C code | simple-c-code-by-mukesh1855-4tsb | Code | mukesh1855 | NORMAL | 2024-12-16T17:35:43.797899+00:00 | 2024-12-16T17:35:43.797899+00:00 | 16 | false | \n# Code\n```c []\n\nint* getFinalState(int* nums, int size, int k, int multiplier, int* returnSize) {\n int *arr = malloc(4*size);\n *returnSize = size;\n for(int i=0;i<size;i++) arr[i] = nums[i];\n for(int i=0;i<k;i++)\n {\n int min = arr[0],ind=0;\n for(int j=0;j<size;j++)\n {\n ... | 1 | 0 | ['C'] | 0 |
final-array-state-after-k-multiplication-operations-i | Easiest Java Solution | easiest-java-solution-by-nikita_singhal-3of7 | IntuitionApproachComplexity
Time complexity: O(k*n)
Code | Nikita_singhal | NORMAL | 2024-12-16T17:12:08.106526+00:00 | 2024-12-16T17:12:08.106526+00:00 | 5 | 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(k*n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n public int[] getFinalStat... | 1 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | Beats 100% in Python, TC: O(k) SC: O(1) | beats-100-in-python-by-amreshgiri-q941 | IntuitionIn every step of the loop, get the min value and multiple it by the multiplier.Complexity
Time complexity:
O(k)
Space complexity:
O(1)
Code | amreshgiri | NORMAL | 2024-12-16T16:56:51.303788+00:00 | 2024-12-16T16:59:54.287168+00:00 | 6 | false | # Intuition\nIn every step of the loop, get the min value and multiple it by the multiplier.\n\n\n\n# Complexity\n- Time complexity:\nO(k)\n\n- Space complexity:\nO(1)\n\n# Code\n```python3 []\nclass Solution:\n def getFinalState(self, nums: List[int], k: int, multiplier: int) -> List[int]:\n for i in range(k... | 1 | 0 | ['Array', 'Python3'] | 0 |
final-array-state-after-k-multiplication-operations-i | Golang beats 100% | golang-beats-100-by-nname6617-z51l | #IntuitionSimple golang solution beats 100% runtime cause of fast stack operationsApproach
GetSmallestIndex
Reiterets over every element in nums to return its i | nname6617 | NORMAL | 2024-12-16T16:54:34.131945+00:00 | 2024-12-16T16:54:34.131945+00:00 | 52 | false | #Intuition \n<!-- Describe your first thoughts on how to solve this problem. -->\nSimple golang solution beats 100% runtime cause of fast stack operations \n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- GetSmallestIndex\nReiterets over every element in nums to return its index\n- Main solutio... | 1 | 0 | ['Go'] | 1 |
final-array-state-after-k-multiplication-operations-i | Brute-Force Approach || 0 ms Beats 100.00% 🚀|| Explanation✔|| Please Upvote ⬆ | brute-force-approach-0-ms-beats-10000-ex-c3h7 | IntuitionThe problem requires performing a specific operation k times on the array. Each operation involves finding the smallest element in the array and updati | Abhijithsr13 | NORMAL | 2024-12-16T16:52:17.512928+00:00 | 2024-12-16T16:52:17.512928+00:00 | 3 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires performing a specific operation k times on the array. Each operation involves finding the smallest element in the array and updating it. The brute-force approach is straightforward: iterate through the array to find t... | 1 | 0 | ['Array', 'Math', 'C++'] | 0 |
final-array-state-after-k-multiplication-operations-i | Intuitive solution Java code beats 100% B) | intuitive-solution-java-code-beats-100-b-xkue | Complexity
Time complexity:
O(n∗k)
Space complexity:
O(n)
Code | jahnvi_777 | NORMAL | 2024-12-16T16:44:36.399277+00:00 | 2024-12-16T16:44:36.399277+00:00 | 12 | false | # Complexity\n- Time complexity:\n$$O(n*k)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```java []\nclass Solution {\n public int[] getFinalState(int[] nums, int k, int multiplier) {\n int n = nums.length;\n for(int i = 0 ; i < k ; i++){\n int m = nums[0];\n for(int x: nums) m =... | 1 | 0 | ['Java'] | 0 |
final-array-state-after-k-multiplication-operations-i | most easy Solution | most-easy-solution-by-yashtripathi6969-8h6y | IntuitionUsing STLApproachJust find the min element in vector and multiply it and replace it .
Do this k timesComplexity
Time complexity:
O(k.n)
Space complexit | yashtripathi6969 | NORMAL | 2024-12-16T16:43:40.014642+00:00 | 2024-12-16T16:43:40.014642+00:00 | 7 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nUsing STL\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\nJust find the min element in vector and multiply it and replace it .\nDo this k times\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity h... | 1 | 0 | ['C++'] | 0 |
unique-binary-search-trees-ii | Divide-and-conquer. F(i) = G(i-1) * G(n-i) | divide-and-conquer-fi-gi-1-gn-i-by-liais-3x9o | This problem is a variant of the problem of [Unique Binary Search Trees][1]. \n\nI provided a solution along with explanation for the above problem, in the ques | liaison | NORMAL | 2015-02-04T15:31:14+00:00 | 2018-10-25T18:23:40.042019+00:00 | 46,521 | false | This problem is a variant of the problem of [Unique Binary Search Trees][1]. \n\nI provided a solution along with explanation for the above problem, in the question ["DP solution in 6 lines with explanation"](https://leetcode.com/problems/unique-binary-search-trees/discuss/31666/DP-Solution-in-6-lines-with-explanation.... | 350 | 0 | ['Divide and Conquer', 'Java'] | 39 |
unique-binary-search-trees-ii | Java Solution with DP | java-solution-with-dp-by-jianwu-zb8e | Here is my java solution with DP:\n\n\n public static List generateTrees(int n) {\n List[] result = new List[n + 1];\n result[0] = new ArrayLis | jianwu | NORMAL | 2014-08-24T18:26:18+00:00 | 2018-10-25T15:59:18.853413+00:00 | 81,940 | false | Here is my java solution with DP:\n\n\n public static List<TreeNode> generateTrees(int n) {\n List<TreeNode>[] result = new List[n + 1];\n result[0] = new ArrayList<TreeNode>();\n if (n == 0) {\n return result[0];\n }\n\n result[0].add(null);\n for (int len = 1; l... | 287 | 3 | ['Java'] | 52 |
unique-binary-search-trees-ii | 🚀 C++ || Detailed Explanation || Recursive Tree || With Comments | c-detailed-explanation-recursive-tree-wi-lqht | Problem\n> Given n, find all structurally unique BST\'s (binary search trees) that has n nodes with unique values from 1 to n\n\nStrategy:\nWe will use a recurs | sdkaur | NORMAL | 2022-03-14T16:01:59.465468+00:00 | 2022-03-14T16:08:52.327131+00:00 | 15,863 | false | **Problem**\n> Given n, find all structurally unique BST\'s (binary search trees) that has n nodes with unique values from 1 to n\n\n**Strategy:**\nWe will use a **recursive helper function** `bst(start, end)` that receives a range (*start to end*, within n) and returns all BST\'s rooted in that range.\n\nNow let\'s lo... | 278 | 1 | ['Recursion', 'C'] | 20 |
unique-binary-search-trees-ii | Should-be-6-Liner | should-be-6-liner-by-stefanpochmann-8dg5 | If only LeetCode had a TreeNode(val, left, right) constructor... sigh. Then I wouldn't need to provide my own and my solution would be six lines instead of elev | stefanpochmann | NORMAL | 2015-06-11T00:38:37+00:00 | 2018-10-16T09:39:57.259290+00:00 | 34,830 | false | If only LeetCode had a `TreeNode(val, left, right)` constructor... sigh. Then I wouldn't need to provide my own and my solution would be six lines instead of eleven.\n\n def generateTrees(self, n):\n def node(val, left, right):\n node = TreeNode(val)\n node.left = left\n node.... | 205 | 12 | ['Python'] | 35 |
unique-binary-search-trees-ii | [Python] DFS with Memoization - Clean & Concise | python-dfs-with-memoization-clean-concis-wcyd | Idea\n- Let dfs(left, right) return all valid BSTs where values in the BST in range [left..right].\n- Then dfs(1, n) is our result.\n- To solve dfs(left, right) | hiepit | NORMAL | 2021-09-02T07:16:09.874480+00:00 | 2021-09-02T09:34:13.610682+00:00 | 11,847 | false | **Idea**\n- Let `dfs(left, right)` return all valid BSTs where values in the BST in range `[left..right]`.\n- Then `dfs(1, n)` is our result.\n- To solve `dfs(left, right)`, we just\n\t- Generate `root` value in range `[left...right]`\n\t- Get left subtrees by `leftNodes = dfs(left, root-1)`\n\t- Get right subtrees by ... | 167 | 1 | [] | 10 |
unique-binary-search-trees-ii | ✅ Recursion & DP [VIDEO] Catalan Number - Unique BST | recursion-dp-video-catalan-number-unique-nfdh | Given an integer \( n \), the task is to return all the structurally unique BST\'s (binary search trees) that have exactly \( n \) nodes of unique values from \ | vanAmsen | NORMAL | 2023-08-05T00:22:20.783064+00:00 | 2023-08-05T03:50:06.259959+00:00 | 17,180 | false | Given an integer \\( n \\), the task is to return all the structurally unique BST\'s (binary search trees) that have exactly \\( n \\) nodes of unique values from \\( 1 \\) to \\( n \\).\n\n# Intuition Recursion & Dynamic Programming\nThe problem can be solved by utilizing the properties of a BST, where the left subtre... | 113 | 3 | ['Dynamic Programming', 'Recursion', 'C++', 'Java', 'Go', 'Python3', 'Rust', 'JavaScript', 'C#'] | 9 |
unique-binary-search-trees-ii | Share a C++ DP solution with O(1) space | share-a-c-dp-solution-with-o1-space-by-w-sj9p | The basic idea is that we can construct the result of n node tree just from the result of n-1 node tree.\nHere's how we do it: only 2 conditions: 1) The nth no | wangxinlei | NORMAL | 2015-01-04T06:37:57+00:00 | 2018-10-24T23:11:03.922843+00:00 | 36,048 | false | The basic idea is that we can construct the result of n node tree just from the result of n-1 node tree.\nHere's how we do it: only 2 conditions: 1) The nth node is the new root, so `newroot->left = oldroot;`\n2) the nth node is not root, we traverse the old tree, every time the node in the old tree has a right child,... | 108 | 2 | [] | 23 |
unique-binary-search-trees-ii | My Accepted C++ solution (recursive, less than 30 lines) | my-accepted-c-solution-recursive-less-th-mrel | explaination:\nGiven a tree which n nodes, it has the follwing form: \n(0)root(n-1)\n(1)root(n-2)\n(2)root(n-3)\nwhere (x) denotes the trees with x nodes.\n\nN | chn | NORMAL | 2014-11-05T12:28:04+00:00 | 2018-10-05T15:44:48.631068+00:00 | 17,373 | false | **explaination:**\nGiven a tree which n nodes, it has the follwing form: \n(0)root(n-1)\n(1)root(n-2)\n(2)root(n-3)\nwhere (x) denotes the trees with x nodes.\n\nNow take n=3 for example. Given n=3, we have [1 2 3] in which each of them can be used as the tree root.\n\nwhen root=1: [1 # 2 # 3]; [1 # 3 2];\nwhen root=2... | 85 | 3 | [] | 26 |
unique-binary-search-trees-ii | 【Video】3 important points | video-3-important-points-by-niits-auvc | Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculatio | niits | NORMAL | 2024-12-05T12:03:18.956080+00:00 | 2024-12-05T12:03:18.956098+00:00 | 3,237 | false | # Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculation of the range. left range should be between start and current root - 1 as end value because all values of left side must be smaller than current root. right ... | 79 | 0 | ['Dynamic Programming', 'Backtracking', 'Tree', 'Binary Search Tree', 'Binary Tree', 'C++', 'Java', 'Python3', 'JavaScript'] | 1 |
unique-binary-search-trees-ii | Small C++ solution | small-c-solution-by-tushargupta1999-6l21 | \nclass Solution {\npublic:\n vector<TreeNode*> generateTrees(int n, int s = 1) {\n vector<TreeNode*> ans;\n if(n < s)\n return {nul | tushargupta1999 | NORMAL | 2021-09-02T16:16:29.339907+00:00 | 2021-09-02T16:19:19.114622+00:00 | 4,234 | false | ```\nclass Solution {\npublic:\n vector<TreeNode*> generateTrees(int n, int s = 1) {\n vector<TreeNode*> ans;\n if(n < s)\n return {nullptr};\n\t\t\t\n\t\t// Consider every number in range [s,n] as root \n for(int i=s; i<=n; i++) {\n\t\t\n\t\t\t// generate all possible trees in range ... | 69 | 0 | ['Recursion', 'C'] | 7 |
unique-binary-search-trees-ii | Recursive python solution | recursive-python-solution-by-shenggu-uvk6 | class Solution(object):\n def generateTrees(self, n):\n """\n :type n: int\n :rtype: List[TreeNode]\n """\n | shenggu | NORMAL | 2015-09-29T22:12:10+00:00 | 2018-10-25T19:29:44.145556+00:00 | 14,851 | false | class Solution(object):\n def generateTrees(self, n):\n """\n :type n: int\n :rtype: List[TreeNode]\n """\n if n == 0:\n return [[]]\n return self.dfs(1, n+1)\n \n def dfs(self, start, end):\n if sta... | 67 | 0 | ['Python'] | 13 |
unique-binary-search-trees-ii | JAVA DP Solution and Brute Force Recursive Solution. | java-dp-solution-and-brute-force-recursi-n4oa | The first method that came to mind was the brute force solution as below. \n\n public List generateTrees(int n) {\n return generateTrees(1,n);\n | coderoath | NORMAL | 2015-04-22T20:15:35+00:00 | 2018-10-06T19:15:20.298440+00:00 | 16,819 | false | The first method that came to mind was the brute force solution as below. \n\n public List<TreeNode> generateTrees(int n) {\n return generateTrees(1,n);\n }\n \n public List<TreeNode> generateTrees(int start,int end){ \n List<TreeNode> trees = new ArrayList<TreeNode>();\n ... | 66 | 1 | ['Dynamic Programming', 'Recursion', 'Java'] | 14 |
unique-binary-search-trees-ii | Java Recursion Along with Recursion Tree Figure Explanation | java-recursion-along-with-recursion-tree-v6a0 | \nclass Solution {\n public List<TreeNode> generateTrees(int n) {\n if (n == 0) {\n return new ArrayList<>();\n }\n return he | Leonxi | NORMAL | 2021-01-19T00:17:42.126770+00:00 | 2021-01-20T16:21:02.908532+00:00 | 4,106 | false | ```\nclass Solution {\n public List<TreeNode> generateTrees(int n) {\n if (n == 0) {\n return new ArrayList<>();\n }\n return helper(1, n);\n }\n \n private List<TreeNode> helper(int lo, int hi) {\n List<TreeNode> result = new ArrayList<>();\n //base case\n ... | 57 | 0 | ['Recursion', 'Java'] | 4 |
unique-binary-search-trees-ii | [C++] Simple and short | c-simple-and-short-by-acce_l-99o2 | Plz upvote if you like it\n\nclass Solution {\npublic:\n vector<TreeNode*> helper(int start,int end) {\n vector<TreeNode*> v;\n if(start > end) | Acce_l | NORMAL | 2020-06-24T09:51:09.661145+00:00 | 2020-06-24T09:59:57.345394+00:00 | 3,508 | false | ***Plz upvote if you like it***\n```\nclass Solution {\npublic:\n vector<TreeNode*> helper(int start,int end) {\n vector<TreeNode*> v;\n if(start > end) {\n v.push_back(NULL);\n return v;\n }\n for(int i = start; i <= end; i++){\n auto left = helper(start,... | 56 | 0 | [] | 5 |
unique-binary-search-trees-ii | 24ms c++ easy understanding solution | 24ms-c-easy-understanding-solution-by-sx-3asn | class Solution {\n private:\n vector<TreeNode*> helper(int start, int end){\n vector<TreeNode*> res;\n if(start > end) {\n | sxycwzwzq | NORMAL | 2016-04-21T22:57:32+00:00 | 2018-10-17T07:10:08.545868+00:00 | 8,358 | false | class Solution {\n private:\n vector<TreeNode*> helper(int start, int end){\n vector<TreeNode*> res;\n if(start > end) {\n res.push_back(NULL);\n return res;\n }\n for(int i = start; i <= end; i++){\n vector<TreeNode*... | 48 | 0 | ['C++'] | 5 |
unique-binary-search-trees-ii | C++ / Python Simple and Short Recursive Solutions, With Explanation | c-python-simple-and-short-recursive-solu-ru00 | Idea:\nWe will use a recursive helper function that recieves a range (within n) and returns all subtrees in that range.\nWe have a few cases:\n1. if start > end | yehudisk | NORMAL | 2021-09-02T07:49:23.496245+00:00 | 2021-09-02T07:49:23.496287+00:00 | 4,852 | false | **Idea:**\nWe will use a recursive helper function that recieves a range (within n) and returns all subtrees in that range.\nWe have a few cases:\n1. if `start > end`, which is not supposed to happen, we return a list that contains only a null.\n2. if `start == end` it means we reached a leaf and we will return a list ... | 46 | 2 | ['C', 'Python'] | 3 |
unique-binary-search-trees-ii | Simple python solution | simple-python-solution-by-fangkunjnsy-pkjw | class Solution(object):\n def generateTrees(self, n):\n return self.cal([i for i in xrange(1, n+1)])\n \n def cal(self, lst):\n if no | fangkunjnsy | NORMAL | 2015-09-24T07:52:59+00:00 | 2018-10-10T05:34:47.067671+00:00 | 5,236 | false | class Solution(object):\n def generateTrees(self, n):\n return self.cal([i for i in xrange(1, n+1)])\n \n def cal(self, lst):\n if not lst: return [None]\n res=[]\n for i in xrange(len(lst)):\n for left in self.cal(lst[:i]):\n for right in self.cal(... | 32 | 2 | [] | 5 |
unique-binary-search-trees-ii | c++ recursive and iterative solutions. Beats 100% and doesn't create Frankenstein trees | c-recursive-and-iterative-solutions-beat-mlu5 | TL;DR\n### Recursive solution\ncpp\n /// Returns all insert orderings of [first, last) that will produce a unique tree when inserted into a tree\n std::vector | christrompf | NORMAL | 2018-09-05T10:31:47.733270+00:00 | 2019-10-14T19:32:20.496371+00:00 | 4,413 | false | # TL;DR\n### Recursive solution\n```cpp\n /// Returns all insert orderings of [first, last) that will produce a unique tree when inserted into a tree\n std::vector<std::vector<int>> unique_orderings(int first, int last)\n {\n std::vector<std::vector<int>> ret;\n if (first == last) {\n ret.emplace_back();\... | 31 | 5 | ['Recursion', 'C', 'Iterator'] | 3 |
unique-binary-search-trees-ii | Ex-Amazon explains a solution with a video, Python, JavaScript, Java and C++ | ex-amazon-explains-a-solution-with-a-vid-xyht | Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculatio | niits | NORMAL | 2023-08-05T05:45:16.084187+00:00 | 2023-08-05T14:50:48.368617+00:00 | 4,236 | false | # Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculation of the range. left range should be between start and current root - 1 as end value because all values of left side must be smaller than current root. right ... | 26 | 0 | ['C++', 'Java', 'Python3', 'JavaScript'] | 1 |
unique-binary-search-trees-ii | 【Video】3 important points | video-3-important-points-by-niits-29nc | Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculatio | niits | NORMAL | 2024-05-23T17:11:54.362202+00:00 | 2024-05-23T17:11:54.362235+00:00 | 3,738 | false | # Intuition\nThere 3 important things. \n\nOne is we try to create subtrees with some range between start(minimum) and end(maximum) value.\n\nSecond is calculation of the range. left range should be between start and current root - 1 as end value because all values of left side must be smaller than current root. right ... | 25 | 0 | ['C++', 'Java', 'Python3', 'JavaScript'] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.