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
flatten-deeply-nested-array
100% recursive memoization
100-recursive-memoization-by-mailmeaaqib-oylc
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nRecursion \n\n# Complex
mailmeaaqib
NORMAL
2023-04-12T11:07:56.543186+00:00
2023-04-21T16:02:14.807238+00:00
2,363
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nRecursion \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....
2
0
['JavaScript']
1
flatten-deeply-nested-array
Recursive solution
recursive-solution-by-bahoang3105-h236
Code\n\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n if (n === 0) return arr;\n let res = [
bahoang3105
NORMAL
2023-04-12T06:44:26.478857+00:00
2023-04-14T03:14:29.957743+00:00
1,118
false
# Code\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n if (n === 0) return arr;\n let res = [];\n for (let i = 0; i < arr.length; i++) {\n if (Array.isArray(arr[i])) {\n res.push(...flat(arr[i], n-1));\n } else {\n res.push(arr[i])...
2
0
['JavaScript']
0
flatten-deeply-nested-array
JavaScript
javascript-by-adchoudhary-4a8l
Code
adchoudhary
NORMAL
2025-03-03T01:39:57.595423+00:00
2025-03-03T01:39:57.595423+00:00
182
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { const stack = [...arr.map(item => [item, n])]; const result = []; while (stack.length > 0) { const [item, depth] = stack.pop(); if (Array.isArray(item) && depth > 0) { ...
1
0
['JavaScript']
0
flatten-deeply-nested-array
|| Shallow & Deep Copy || Recursion || Lot's of Concept || JS
shallow-deep-copy-recursion-lots-of-conc-1g4q
CodeThe Array slice() method returns selected elements in an array as a new array. It selects from a given start, up to a (not inclusive) given end. This method
Ashish_Ujjwal
NORMAL
2025-02-22T10:01:40.533659+00:00
2025-02-22T10:01:40.533659+00:00
137
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { if(n === 0){ console.log(arr); return arr.slice() } // it create shallow copy of array // Q. Why we are using slice method ... // Ans. This is because in ca...
1
0
['JavaScript']
0
flatten-deeply-nested-array
With Recursion
with-recursion-by-davidchills-3ob8
Code
davidchills
NORMAL
2025-02-01T00:20:41.236353+00:00
2025-02-01T00:20:41.236353+00:00
204
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { const out = []; const concat = function (sub, currentDepth) { for (let i = 0; i < sub.length; i++) { if (Array.isArray(sub[i]) && currentDepth < n) { ...
1
0
['Recursion', 'JavaScript']
0
flatten-deeply-nested-array
Easy Explanation
easy-explanation-by-pratyushpanda91-ch7i
Explanation:Helper Function:The recursive helper function flattenHelper takes the current array and its depth as arguments. If the current depth is greater than
pratyushpanda91
NORMAL
2025-01-26T13:45:44.069044+00:00
2025-01-26T13:45:44.069044+00:00
192
false
# Explanation: ### Helper Function: The recursive helper function flattenHelper takes the current array and its depth as arguments. - If the current depth is greater than or equal to the specified n, the function stops recursing and returns the array as-is. - Otherwise, it iterates through each element of the array. ...
1
0
['JavaScript']
0
flatten-deeply-nested-array
flatten func | 96.55% Beats | 79 ms | JavaScript
flatten-func-9655-beats-79-ms-php-by-ma7-v0qu
Code
Ma7med
NORMAL
2025-01-14T17:23:09.280784+00:00
2025-01-15T08:35:59.828853+00:00
710
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { const result = []; // Helper function to handle flattening recursively function flatten(item, depth) { if (Array.isArray(item) && depth < n) { for (let i...
1
0
['JavaScript']
1
flatten-deeply-nested-array
Without Recursion || Easy Solution than others || C++ || 👍😊
easy-solution-than-others-c-by-adarsh002-qafk
IntuitionApproachComplexity Time complexity: Space complexity: Code
adarsh0024
NORMAL
2024-12-18T17:35:51.573695+00:00
2024-12-28T16:39:45.029528+00:00
101
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
1
['JavaScript']
1
flatten-deeply-nested-array
Easy JS Soln Using Recursion
easy-js-soln-using-recursion-by-akhil148-b0l6
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
Akhil1489
NORMAL
2024-08-02T08:06:07.992445+00:00
2024-08-02T08:06:07.992470+00:00
549
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)$$ --...
1
0
['JavaScript']
0
flatten-deeply-nested-array
One line solution
one-line-solution-by-abhilashabhi2003-usmr
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
abhilashabhi2003
NORMAL
2024-03-18T08:38:42.716173+00:00
2024-03-18T08:38:42.716216+00:00
360
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)$$ --...
1
0
['JavaScript']
2
flatten-deeply-nested-array
Array.prototype.flat Approach
arrayprototypeflat-approach-by-lannuttia-xj49
Intuition\nThis is something that can be handled using Array.prototype.flat\n\n# Approach\nI just made flat a wrapper function for Array.\n\n# Code\n\n/**\n * @
lannuttia
NORMAL
2023-12-20T22:49:59.946401+00:00
2023-12-20T22:49:59.946429+00:00
19
false
# Intuition\nThis is something that can be handled using Array.prototype.flat\n\n# Approach\nI just made flat a wrapper function for Array.\n\n# Code\n```\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {Array}\n */\nvar flat = function (arr, n) {\n return arr.flat(n)\n};\n```
1
1
['JavaScript']
1
flatten-deeply-nested-array
Java||BFS
javabfs-by-nikhilneo1-7ydc
Intuition\nThe goal of this problem is to flatten a nested array with a specified depth. We can achieve this by using a breadth-first approach where we process
nikhilneo1
NORMAL
2023-08-28T02:42:54.317212+00:00
2023-08-28T02:42:54.317239+00:00
213
false
# Intuition\nThe goal of this problem is to flatten a nested array with a specified depth. We can achieve this by using a breadth-first approach where we process the array elements level by level up to the given depth.\n\n# Approach\n1. We start by initializing a queue to hold the elements of the array.\n2. We iterate ...
1
0
['Breadth-First Search', 'Java']
0
flatten-deeply-nested-array
99% Easy DFS recursive solution with explanations ✅
99-easy-dfs-recursive-solution-with-expl-eenz
Hello everyone! So, I\'ve come up with a solution to resolve this problem, by the way i\'m new to JS so if you have any advice you\'re welcome. \uD83D\uDE01\n\n
RayanYI
NORMAL
2023-08-15T17:05:19.564267+00:00
2023-08-15T17:05:19.564291+00:00
168
false
**Hello everyone! So, I\'ve come up with a solution to resolve this problem, by the way i\'m new to JS so if you have any advice you\'re welcome. \uD83D\uDE01**\n\n# Intuition\nWhich algorithm can i use to keep tracking the deep ?`\uD83D\uDCA1DFS`\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n...
1
0
['Depth-First Search', 'Recursion', 'JavaScript']
0
flatten-deeply-nested-array
🐰 Easy solution || 🥕Short & Simple || 🥕
easy-solution-short-simple-by-gg8w7-bfxu
\n\n# Code\n\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n const ans =[]\n const traver
GG8w7
NORMAL
2023-04-13T03:25:20.590228+00:00
2023-04-13T03:26:09.929479+00:00
126
false
\n\n# Code\n```\n/**\n * @param {any[]} arr\n * @param {number} depth\n * @return {any[]}\n */\nvar flat = function (arr, n) {\n const ans =[]\n const traverse=(ele,i)=>{\n if(i > n || !Array.isArray(ele))return ans.push(ele)\n ele.forEach(e=>traverse(e ,i + 1))\n }\n traverse(arr,0)\n retu...
1
0
['JavaScript']
0
flatten-deeply-nested-array
2625. Flatten Deeply Nested Array Solution
2625-flatten-deeply-nested-array-solutio-pimu
IntuitionThis problem is about flattening nested arrays to a given depth n. It tests our understanding of recursion, array traversal, and conditional logic base
runl4AVDwJ
NORMAL
2025-04-09T15:15:43.750434+00:00
2025-04-09T15:15:43.750434+00:00
2
false
# **Intuition** This problem is about **flattening nested arrays** to a given depth `n`. It tests our understanding of **recursion**, **array traversal**, and **conditional logic based on depth**. Flattening means converting nested arrays into a single-level array, but only up to `n` levels deep. If `n = 0`, we retur...
0
0
['JavaScript']
0
flatten-deeply-nested-array
my Answer
my-answer-by-rwc8cinz7h-qwtq
IntuitionApproachComplexity Time complexity: Space complexity: Code
RwC8cINz7h
NORMAL
2025-03-29T20:22:15.458713+00:00
2025-03-29T20:22:15.458713+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
['JavaScript']
0
flatten-deeply-nested-array
Flatten Deeply Nested Array
flatten-deeply-nested-array-by-shalinipa-49jf
IntuitionApproachComplexity Time complexity: Space complexity: Code
ShaliniPaidimuddala
NORMAL
2025-03-25T09:00:18.469192+00:00
2025-03-25T09:00:18.469192+00:00
2
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
['JavaScript']
0
flatten-deeply-nested-array
SberTest
sbertest-by-wasabully-hgtt
Интуиция
wasabully
NORMAL
2025-03-24T16:01:58.281593+00:00
2025-03-24T16:01:58.281593+00:00
1
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function(array, depth) { const result = []; function flatten(arr, level) { for (let item of arr) { if (Array.isArray(item) && level > 0) { flatten(item, level - 1); } else { ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Рекурсия
rekursiia-by-artur-jk-pbq7
IntuitionApproachComplexity Time complexity: Space complexity: Code
Artur-jk
NORMAL
2025-03-24T14:10:23.496643+00:00
2025-03-24T14:10:23.496643+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
['JavaScript']
0
flatten-deeply-nested-array
Efficiently Flatten Deeply Nested Arrays with Controlled Depth
efficiently-flatten-deeply-nested-arrays-kaq6
IntuitionThe idea is to iteratively flatten the array up to the given depth. We use a while loop to control the depth and a nested while loop to traverse the ar
doviethoang159
NORMAL
2025-03-11T02:20:28.153382+00:00
2025-03-11T02:20:28.153382+00:00
4
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> The idea is to iteratively flatten the array up to the given depth. We use a while loop to control the depth and a nested while loop to traverse the array and flatten it. # Approach <!-- Describe your approach to solving the problem. --> 1...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Faster recursive solution without spread operator
faster-recursive-solution-without-spread-s1x8
IntuitionThe initial thought is to create a solution that flattens a nested array up to a specified depth. The problem requires recursively processing array ele
HakobYer
NORMAL
2025-03-09T14:06:10.009513+00:00
2025-03-09T14:06:10.009513+00:00
3
false
# Intuition The initial thought is to create a solution that flattens a nested array up to a specified depth. The problem requires recursively processing array elements, where we need to: - Handle nested arrays by diving deeper when depth allows - Collect non-array elements into a result array - Stop recursion when ei...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Solution Walkthrough
solution-walkthrough-by-tcw53qyc6i-16rv
IntuitionWe need a recursive function that can flatten the array based on n. For this, the function needs to know how deeply nested it is.Approach We begin with
tCw53qyc6i
NORMAL
2025-03-06T22:20:25.560728+00:00
2025-03-06T22:20:25.560728+00:00
2
false
# Intuition We need a recursive function that can flatten the array based on `n`. For this, the function needs to know how deeply nested it is. # Approach 1. We begin with a simple copy of `arr`: ```javascript [] var flat = function (arr, n) { let res = []; for (const item of arr) res.push(item); return...
0
0
['JavaScript']
0
flatten-deeply-nested-array
flat it out!
flat-it-out-by-ecabigting-jpbq
IntuitionApproachComplexity Time complexity: Space complexity: Code
ecabigting
NORMAL
2025-03-05T11:31:09.934351+00:00
2025-03-05T11:31:09.934351+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
['JavaScript']
0
flatten-deeply-nested-array
Solution
solution-by-aradhanadevi_jadeja-6ngm
Code
Aradhanadevi_Jadeja
NORMAL
2025-03-02T09:33:33.625235+00:00
2025-03-02T09:33:33.625235+00:00
6
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { if (n === 0) return arr; let result = []; for(let item of arr){ if (Array.isArray(item) && n > 0){ result.push(...flat(item, n-1)); }else{ ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
flatten-deeply-nested-array easy way
flatten-deeply-nested-array-easy-way-by-iov4u
Code
devmazaharul
NORMAL
2025-03-02T04:37:37.561920+00:00
2025-03-02T04:37:37.561920+00:00
3
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n=0) { return arr.flat(n) } ```
0
0
['JavaScript']
0
flatten-deeply-nested-array
Flatten Deeply Nested Array (JS) - Easy Solution
flatten-deeply-nested-array-js-easy-solu-wbpq
IntuitionApproachComplexity Time complexity: Space complexity: Code
alli_vinay
NORMAL
2025-02-26T06:23:30.714697+00:00
2025-02-26T06:23:30.714697+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
['JavaScript']
0
flatten-deeply-nested-array
easy solution
easy-solution-by-haneen_ep-31yv
IntuitionApproachComplexity Time complexity: Space complexity: Code
haneen_ep
NORMAL
2025-02-23T07:02:38.532009+00:00
2025-02-23T07:02:38.532009+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
['JavaScript']
0
flatten-deeply-nested-array
for ... of.. recursive
for-of-recursive-by-rrazvan-rmhz
Code
rrazvan
NORMAL
2025-02-20T13:43:18.699191+00:00
2025-02-20T13:43:18.699191+00:00
8
false
# Code ```typescript [] type MultiDimensionalArray = (number | MultiDimensionalArray)[]; var flat = function (arr: MultiDimensionalArray, n: number): MultiDimensionalArray { const res = []; const flatUtil = (arr: MultiDimensionalArray, n: number) => { for (const val of arr) { if (Array.is...
0
0
['TypeScript']
0
flatten-deeply-nested-array
Solution!!
solution-by-eishi-y73h
IntuitionApproachComplexity Time complexity: Space complexity: Code
eishi
NORMAL
2025-02-15T07:23:32.036456+00:00
2025-02-15T07:23:32.036456+00:00
3
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
['JavaScript']
0
flatten-deeply-nested-array
Flatten Deeply Nested Array || Easy Solution
flatten-deeply-nested-array-easy-solutio-j3rb
Complexity Time complexity: O(n2) Space complexity: O(n) Code
nitinkumar-19
NORMAL
2025-02-05T17:01:18.452118+00:00
2025-02-05T17:02:05.270859+00:00
6
false
# Complexity - Time complexity: O(n2) - Space complexity: O(n) # Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { let ans = []; for(const el of arr){ if(Array.isArray(el) && n>0){ ans.push(...flat(el, n-1)); ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
One line solution!
one-line-solution-by-we6m4c74zc-7vi1
IntuitionApproachComplexity Time complexity: Space complexity: Code
We6m4C74zC
NORMAL
2025-02-05T13:03:22.024345+00:00
2025-02-05T13:03:22.024345+00:00
3
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
['JavaScript']
0
flatten-deeply-nested-array
Easy JavaScript Solution
easy-javascript-solution-by-rajasibi-1hxw
IntuitionApproachComplexity Time complexity: Space complexity: Code
RajaSibi
NORMAL
2025-01-30T05:14:45.746073+00:00
2025-01-30T05:14:45.746073+00:00
3
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
['JavaScript']
0
flatten-deeply-nested-array
Flattening Multi-Dimensional Arrays in JavaScript: A Simple Approach
flattening-multi-dimensional-arrays-in-j-n2nc
DescriptionThis solution provides a straightforward way to flatten multi-dimensional arrays in JavaScript based on a specified depth. It is designed for beginne
raed_al_masri
NORMAL
2025-01-27T07:41:54.233991+00:00
2025-01-27T07:41:54.233991+00:00
1
false
# Description This solution provides a straightforward way to flatten `multi-dimensional arrays` in JavaScript based on a `specified depth`. It is designed for beginners and explains the logic behind the code` step-by-step`. # Code Explanation 1. **Function Declaration**: The main function flat takes two parameters: `...
0
0
['JavaScript']
0
flatten-deeply-nested-array
LC #2625
lc-2625-by-jaalle-ntw3
IntuitionApproachComplexity Time complexity: Space complexity: Code
jaalle
NORMAL
2025-01-26T19:19:00.780014+00:00
2025-01-26T19:19:00.780014+00:00
5
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
['TypeScript', 'JavaScript']
0
flatten-deeply-nested-array
Easy and way to solve Flat Array - 43ms
easy-and-way-to-solve-flat-array-43ms-by-o7xd
IntuitionApproachComplexity Time complexity: Space complexity: Code
srinivas4596
NORMAL
2025-01-26T06:51:52.264325+00:00
2025-01-26T06:51:52.264325+00:00
2
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
['JavaScript']
0
flatten-deeply-nested-array
Recursion
recursion-by-stuymedova-a30f
Code
stuymedova
NORMAL
2025-01-22T12:48:13.002972+00:00
2025-01-22T12:48:13.002972+00:00
3
false
# Code ```javascript [] var flat = function (arr, n) { const res = []; for (let i = 0; i < arr.length; i++) { if (Array.isArray(arr[i]) && n) { res.push(...flat(arr[i], n - 1)); } else { res.push(arr[i]); } } return res; }; ```
0
0
['JavaScript']
0
flatten-deeply-nested-array
Simple Solution with explanation of the program and approach to solve the problem step by step
simple-solution-with-explanation-of-the-ywyb1
IntuitionUnderstand the given condition and think the logic to the given problem and the return value.ApproachWe have to flatten the array until the depth n wit
Shashankpatelc
NORMAL
2025-01-22T02:42:01.227610+00:00
2025-01-22T02:42:01.227610+00:00
3
false
- - - # Intuition <!-- Describe your first thoughts on how to solve this problem. --> Understand the given condition and think the logic to the given problem and the return value. - - - # Approach <!-- Describe your approach to solving the problem. --> We have to flatten the array until the depth `n` without using the ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
2625. Flatten Deeply Nested Array
2625-flatten-deeply-nested-array-by-g8xd-4dp0
IntuitionApproachComplexity Time complexity: Space complexity: Code
G8xd0QPqTy
NORMAL
2025-01-19T05:37:35.510632+00:00
2025-01-19T05:37:35.510632+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
['JavaScript']
0
flatten-deeply-nested-array
While loop + splice + typeof
while-loop-splice-typeof-by-natteererer-3hsd
Code
natteererer
NORMAL
2025-01-18T00:06:27.042881+00:00
2025-01-18T00:06:27.042881+00:00
3
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { let index = 0; let count = 0; while(n > 0){ while(index < arr.length){ if(String(typeof arr[index]) === 'object'){ count = arr[index].length...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Better solution ✅🚀
better-solution-by-its_me_1-7pi8
IntuitionThe task is to flatten an array to a specified depth: If an element is an array and the current depth allows further flattening, expand that array into
its_me_1
NORMAL
2025-01-16T11:07:27.063744+00:00
2025-01-16T11:07:27.063744+00:00
4
false
# Intuition The task is to flatten an array to a specified depth: - If an element is an array and the current depth allows further flattening, expand that array into its elements. - Otherwise, retain the element as is. A stack-based approach provides an iterative alternative to recursion, allowing better control ov...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Flatten array
flatten-array-by-moonlayt-j43h
IntuitionFirstly, we need to understand, what way we will use - recursive or loop, and start implement what we want.Approach As we can see, if n===0, we can ret
MOONLAYT
NORMAL
2025-01-14T19:28:22.224271+00:00
2025-01-14T19:28:22.224271+00:00
7
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> Firstly, we need to understand, what way we will use - recursive or loop, and start implement what we want. # Approach <!-- Describe your approach to solving the problem. --> 1. As we can see, if `n===0`, we can return given array as is, s...
0
0
['TypeScript']
0
flatten-deeply-nested-array
|| Beginner approach ||
beginner-approach-by-ybcnvxeaod-do3k
IntuitionApproachComplexity Time complexity: Space complexity: Code
UjjawalSingh123
NORMAL
2025-01-13T09:04:12.528247+00:00
2025-01-13T09:04:12.528247+00:00
2
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
['JavaScript']
0
flatten-deeply-nested-array
Flatten the array solution(Two sollutions)
flatten-the-array-solutiontwo-sollutions-jspa
Code
pankaj3765
NORMAL
2025-01-10T03:04:27.597233+00:00
2025-01-10T03:04:27.597233+00:00
4
false
# Code ```javascript [] /** * @param {Array} arr * @param {number} depth * @return {Array} */ var flat = function (arr, n) { const result = arr.reduce((acc, curr, index)=>{ if(Array.isArray(curr) && n>0){ acc.push(...flat(curr, n-1)); } else { acc.push(curr) ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
#2625. Flatten Deeply Nested
2625-flatten-deeply-nested-by-dheeraj732-bhg6
IntuitionWhen given a nested array and a depth, the task is to flatten the array up to the specified depth. Initially, it seems straightforward to iteratively o
Dheeraj7321
NORMAL
2025-01-05T11:46:02.050459+00:00
2025-01-05T11:46:02.050459+00:00
5
false
# Intuition When given a nested array and a depth, the task is to flatten the array up to the specified depth. Initially, it seems straightforward to iteratively or recursively traverse the array and unpack its elements based on the depth. The key challenge lies in properly handling nested arrays while respecting the d...
0
0
['JavaScript']
0
flatten-deeply-nested-array
Truly a JavaScript miracle!
truly-a-javascript-miracle-by-timeforcha-gz57
IntuitionAt first, I considered the array as one-dimensional and thought I could loop through each element to dive into the 2nd, 3rd, and 4th dimensions. Howeve
timeforchangegrandma
NORMAL
2025-01-04T04:53:20.678910+00:00
2025-01-04T04:53:20.678910+00:00
3
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> At first, I considered the array as one-dimensional and thought I could loop through each element to dive into the 2nd, 3rd, and 4th dimensions. However, it became clear that this approach would be quite challenging. # Approach <!-- Describ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
flat
flat-by-ka11den-g353
IntuitionApproachComplexity Time complexity: Space complexity: Code
ka11den
NORMAL
2025-01-01T11:08:23.621446+00:00
2025-01-01T11:08:23.621446+00:00
2
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
['JavaScript']
0
flatten-deeply-nested-array
GOOD ONE | RECURSION | EASY MEDIUM
good-one-recursion-easy-medium-by-imran7-le7v
Code
imran7908
NORMAL
2024-12-30T05:16:55.638972+00:00
2024-12-30T05:16:55.638972+00:00
4
false
# Code ```javascript [] function flatten(array, currentDepth, maxDepth, result) { if (currentDepth > maxDepth) { result.push(array); return; } for (let el of array) { if (Array.isArray(el)) { flatten(el, currentDepth + 1, maxDepth, result); } else { r...
0
0
['JavaScript']
0
flatten-deeply-nested-array
easy solution
easy-solution-by-virendangi123-jb6o
IntuitionApproachComplexity Time complexity: Space complexity: Code
Virendangi123
NORMAL
2024-12-26T14:33:14.780925+00:00
2024-12-26T14:33:14.780925+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
['JavaScript']
0
flatten-deeply-nested-array
JS solution with example
js-solution-with-example-by-muskan_kutiy-49ie
IntuitionApproachComplexity Time complexity: Space complexity: Code
Muskan_Kutiyal
NORMAL
2024-12-25T09:47:31.218908+00:00
2024-12-25T09:47:31.218908+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
['JavaScript']
0
flatten-deeply-nested-array
Simple Recursive Approach (JS)
simple-recursive-approach-js-by-karsian-t3qs
ApproachRecursive ApproachComplexity Time complexity: O(N∗n) Space complexity:O(N+n) Code
Karsian
NORMAL
2024-12-25T09:39:41.464503+00:00
2024-12-25T09:39:41.464503+00:00
3
false
# Approach <!-- Describe your approach to solving the problem. --> Recursive Approach # Complexity - Time complexity: $$O(N*n)$$ <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:$$O(N+n)$$ <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```javascript [] /** * @param {Array} arr ...
0
0
['Recursion', 'JavaScript']
0
flatten-deeply-nested-array
First Problem Solve
first-problem-solve-by-salman_00-67an
IntuitionApproachComplexity Time complexity: Space complexity: Code
Salman_00
NORMAL
2024-12-23T11:58:59.172467+00:00
2024-12-23T11:58:59.172467+00:00
3
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
['JavaScript']
0
flatten-deeply-nested-array
Recursive if(Array.isArray(elem) && n > 0) {
recursive-ifarrayisarrayelem-n-0-by-roma-vezs
IntuitionApproachComplexity Time complexity: Space complexity: Code
roman_gravit
NORMAL
2024-12-20T18:19:27.479496+00:00
2024-12-20T18:19:27.479496+00:00
3
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
['JavaScript']
0
flatten-deeply-nested-array
2625. Flatten Deeply Nested Array
2625-flatten-deeply-nested-array-by-anik-351o
IntuitionApproachComplexity Time complexity:- o(m) Space complexity:- o(m) Code
Anikaleet
NORMAL
2024-12-18T12:59:11.618159+00:00
2024-12-18T12:59:11.618159+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(m)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:- o(m)\n<!-- Add your space complexity here, e.g....
0
0
['JavaScript']
0
flatten-deeply-nested-array
Basic recursion
basic-recursion-by-raulzc3-lxiv
IntuitionI see that this is going to be a recursive function since I would have to flatten the nested arrays too.ApproachFirst I have to iterate the given array
raulzc3
NORMAL
2024-12-17T21:02:02.044146+00:00
2024-12-17T21:02:02.044146+00:00
2
false
# Intuition\nI see that this is going to be a recursive function since I would have to flatten the nested arrays too.\n\n\n# Approach\nFirst I have to iterate the given array and check if the depth is grater than 0, if not, return the array since the job is done. If n>0, iterate the array and check every position: if t...
0
0
['JavaScript']
0
flatten-deeply-nested-array
简单的递归
jian-dan-de-di-gui-by-caizhenci-scru
IntuitionApproachComplexity Time complexity: Space complexity: Code
caizhenci
NORMAL
2024-12-15T15:03:20.207675+00:00
2024-12-15T15:03:20.207675+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
['JavaScript']
0
flatten-deeply-nested-array
Recursive solution
recursive-solution-by-user7669j-pt5w
IntuitionApproachComplexity Time complexity: O(n), where n is the total number of elements and sub-elements in the array. Space complexity: O(n) due to the resu
user7669j
NORMAL
2024-12-13T19:33:08.909827+00:00
2024-12-13T19:33:08.909827+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)$$ -->\nO(n), where n is the total number of elements and sub-elements in the array....
0
0
['JavaScript']
0
flatten-deeply-nested-array
Simple ... Just use arr.Flat(n) . Check it now
simple-just-use-arrflatn-check-it-now-by-qgmc
null
divanshurohilla16
NORMAL
2024-12-11T13:39:14.435958+00:00
2024-12-11T13:39:14.435958+00:00
1
false
\n# Code\n```javascript []\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {Array}\n */\nvar flat = function (arr, n) {\n return arr.flat(n);\n};\n```
0
0
['JavaScript']
0
flatten-deeply-nested-array
JavaScript simple O(n) solution
javascript-simple-on-solution-by-enmalaf-epuu
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
enmalafeev
NORMAL
2024-12-06T09:41:42.173536+00:00
2024-12-06T09:41:42.173565+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(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $...
0
0
['JavaScript']
0
flatten-deeply-nested-array
js Easy
js-easy-by-hacker_bablu_123-p5o0
Intuition\n Describe your first thoughts on how to solve this problem. \nThe function utilizes a recursive approach to reduce the depth of the nested array laye
Hacker_Bablu_123
NORMAL
2024-12-02T17:33:50.690276+00:00
2024-12-02T17:33:50.690302+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe function utilizes a recursive approach to reduce the depth of the nested array layer by layer. For each recursive call, the function decreases the allowed depth by 1 until it reaches 0, at which point the array is no longer flattened ...
0
0
['JavaScript']
0
flatten-deeply-nested-array
More you should know about Flatten || Best Soln
more-you-should-know-about-flatten-best-1mkkw
\n\uD83D\uDCA1 It is a process through which we can reduce the dimension of the array\n\n \n\n- We can use concat() method for flattening the array\n\njsx\nlet
AdityaSingh21
NORMAL
2024-11-30T10:35:50.801879+00:00
2024-11-30T10:35:50.801913+00:00
3
false
<aside>\n\uD83D\uDCA1 It is a process through which we can reduce the dimension of the array\n\n</aside>\n\n- We can use concat() method for flattening the array\n\n```jsx\nlet arr = [[1,2],[3,[4,9]],[5,6]];\n\nlet flattened= [].concat(...arr);\nconsole.log(flattened); //[ 1, 2, 3, [ 4, 9 ], 5, 6 ]\n```\n\n- Use array....
0
0
['JavaScript']
0
flatten-deeply-nested-array
JavaScript | Typescript Solution with recursion
javascript-typescript-solution-with-recu-548n
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\n- Space comp
sudhanshu221b
NORMAL
2024-11-28T21:23:26.338492+00:00
2024-11-28T21:23:26.338526+00:00
6
false
# 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$$O(n)$$\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$ (If we consider the resulting array)\n\n\n# Code\n```typescrip...
0
0
['Recursion', 'TypeScript']
0
flatten-deeply-nested-array
Explained with help of an example
explained-with-help-of-an-example-by-him-kwge
Example Walkthrough:\n- For input arr = [1, [2, [3, 4], 5], 6] and n = 2, here\u2019s what happens step-by-step:\n - The helper function starts with the oute
himanshusaini0345
NORMAL
2024-11-28T12:38:15.104410+00:00
2024-11-28T12:38:15.104441+00:00
6
false
# Example Walkthrough:\n- For input arr = [1, [2, [3, 4], 5], 6] and n = 2, here\u2019s what happens step-by-step:\n - The helper function starts with the outer array [1, [2, [3, 4], 5], 6] and depth 0.\n - It adds 1 to res.\n - It sees the sub-array [2, [3, 4], 5] and recursively calls helper with thi...
0
0
['TypeScript']
0
flatten-deeply-nested-array
recursion
recursion-by-user5469al-n8wv
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
user5469al
NORMAL
2024-11-26T10:31:15.661782+00:00
2024-11-26T10:31:15.661804+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
['JavaScript']
0
flatten-deeply-nested-array
Recursive check
recursive-check-by-svygzhryr-7xcl
Intuition\nIt\'s basically just recursive iteration through current array.\n\n# Approach\nCreate a function which will be iterating through current array and if
Svygzhryr
NORMAL
2024-11-25T05:39:13.131364+00:00
2024-11-25T05:39:13.131396+00:00
3
false
# Intuition\nIt\'s basically just recursive iteration through current array.\n\n# Approach\nCreate a function which will be iterating through current array and if current item is an array, recursively iterate through it as well if we still not exceeded allowed depth.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- S...
0
0
['TypeScript']
0
flatten-deeply-nested-array
Optimized Recursive Array Flattening -- Best Solution!! Well documented!!
optimized-recursive-array-flattening-bes-p3yd
\n# Runtime Performance\n- Runtime: 89 ms \n- Beats: 91.32% of submissions\n\nThis high performance is due to not using array spread operations. The only issue
rippl
NORMAL
2024-11-21T17:00:00.150773+00:00
2024-11-21T17:45:29.972823+00:00
4
false
\n# Runtime Performance\n- **Runtime**: `89 ms` \n- **Beats**: `91.32%` of submissions\n\nThis high performance is due to not using array spread operations. The only issue is by not using the spread you are passing the sub-arrays by reference.\n\n# Intuition\nI approached this problem as a graph problem. Instead of us...
0
0
['TypeScript']
0
flatten-deeply-nested-array
[js] [Symbol.iterator] is solution
js-symboliterator-is-solution-by-andydan-u8tm
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
andydanilov
NORMAL
2024-11-16T19:54:02.645785+00:00
2024-11-16T19:54:02.645816+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
['JavaScript']
0
flatten-deeply-nested-array
Каф кефтеме
kaf-kefteme-by-whitnessss-czk0
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
Whitnessss
NORMAL
2024-11-14T14:44:44.756915+00:00
2024-11-14T14:44:44.756944+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
['JavaScript']
0
flatten-deeply-nested-array
Flatten Deeply Nested Array
flatten-deeply-nested-array-by-maimuna_j-pymm
\n\n# Code\njavascript []\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {Array}\n */\nvar flat = function (arr, n) {\n if (n === 0) {\n
Maimuna_Javed
NORMAL
2024-11-14T14:30:14.630032+00:00
2024-11-14T14:30:14.630079+00:00
1
false
\n\n# Code\n```javascript []\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {Array}\n */\nvar flat = function (arr, n) {\n if (n === 0) {\n return arr;\n }\n return arr.flat(n);\n};\n```
0
0
['JavaScript']
0
flatten-deeply-nested-array
Best Solution in JAVASCRIPT solution with O(N) complexity
best-solution-in-javascript-solution-wit-8exe
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
samrat1010
NORMAL
2024-11-08T18:32:13.611069+00:00
2024-11-08T18:32:13.611099+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(n)\n\n\n- Space complexity: O(n)\n\n# Code\n```javascript []\n/**\n * @param {Array} arr\n * @param {number} depth\n * @return {A...
0
0
['JavaScript']
0
sort-an-array
C++ Clean Code Solution | Fastest | All (15+) Sorting Methods | Detailed
c-clean-code-solution-fastest-all-15-sor-93iw
Table of Content:\n STL\n\t Method1: Standard \n\t Method2: Stable\n Insertion Sort\n\t Method1: Iterative\n\t Method2: Recursive\n Selection Sort\n\t Method1:
umesh72614
NORMAL
2021-08-13T14:38:40.343511+00:00
2022-10-13T07:31:28.158609+00:00
48,751
false
### Table of Content:\n* STL\n\t* Method1: Standard \n\t* Method2: Stable\n* Insertion Sort\n\t* Method1: Iterative\n\t* Method2: Recursive\n* Selection Sort\n\t* Method1: Standard\n\t* Method2: Standard using inbuilt\n* Bubble Sort\n* Quick Sort\n\t* Method1: Standard\n\t* Method2: Randomised\n* Merge Sort\n\t* Method...
930
1
['Merge Sort', 'Bucket Sort', 'Radix Sort', 'Counting Sort', 'C++']
34
sort-an-array
[Python] bubble, insertion, selection, quick, merge, heap
python-bubble-insertion-selection-quick-q027g
in real life, we use\n\n def sortArray(self, nums):\n return sorted(nums)\n\n\nbut we are playing leetcode right now...\n\nclass Solution:\n def so
cc189
NORMAL
2019-04-18T00:22:09.408179+00:00
2020-05-25T08:09:32.982186+00:00
65,429
false
in real life, we use\n```\n def sortArray(self, nums):\n return sorted(nums)\n```\n\nbut we are playing leetcode right now...\n```\nclass Solution:\n def sortArray(self, nums: List[int]) -> List[int]:\n # self.quickSort(nums)\n # self.mergeSort(nums)\n # self.bubbleSort(nums)\n ...
407
4
[]
31
sort-an-array
7 Sorting Algorithms (quick sort, top-down/bottom-up merge sort, heap sort, etc.)
7-sorting-algorithms-quick-sort-top-down-ab7t
7 Sorting Algorithms:\n1. quick sort\n2. top-down merge sort\n3. bottom-up merge sort\n4. heap sort\n5. selection sort\n6. insertion sort\n7. bubble sort (TLE)\
dreamyjpl
NORMAL
2020-01-28T01:52:21.916753+00:00
2020-02-10T01:18:18.062313+00:00
50,862
false
7 Sorting Algorithms:\n1. quick sort\n2. top-down merge sort\n3. bottom-up merge sort\n4. heap sort\n5. selection sort\n6. insertion sort\n7. bubble sort (TLE)\n\nThe implementations are as below:\n1. quick sort\n```java\nclass Solution {\n public List<Integer> sortArray(int[] nums) {\n List<Integer> res = ne...
302
3
['Sorting', 'Merge Sort', 'Java']
27
sort-an-array
7-line quicksort to write in interviews (Python)
7-line-quicksort-to-write-in-interviews-cr9k1
This is my go-to solution when asked this question in interviews. It\'s short, simple to write, very bug free, and looks very clean and pythonic. Writing this v
twohu
NORMAL
2019-04-18T07:11:23.634157+00:00
2019-06-02T06:30:30.263362+00:00
27,278
false
This is my go-to solution when asked this question in interviews. It\'s short, simple to write, very bug free, and looks very clean and pythonic. Writing this version of quicksort is very effective in communicating your understanding of the algorithm and its concepts to the interviewer.\n\nThe only tradeoff in the code...
215
12
['Sorting', 'Python']
32
sort-an-array
Python 3 (Eight Sorting Algorithms) (With Explanation)
python-3-eight-sorting-algorithms-with-e-b5vw
Sorting Algorithms:\n1. Selection Sort\n2. Bubble Sort\n3. Insertion Sort\n4. Binary Insertion Sort\n5. Counting Sort\n6. QuickSort\n7. Merge Sort\n8. Bucket So
junaidmansuri
NORMAL
2019-12-26T15:00:09.095166+00:00
2019-12-27T07:34:36.043267+00:00
21,630
false
_Sorting Algorithms:_\n1. Selection Sort\n2. Bubble Sort\n3. Insertion Sort\n4. Binary Insertion Sort\n5. Counting Sort\n6. QuickSort\n7. Merge Sort\n8. Bucket Sort\n____________________________________________\n\n1) _Selection Sort:_\nThis program sorts the list by finding the minimum of the list, removing it from the...
186
5
['Sorting', 'Counting Sort', 'Python', 'Python3']
10
sort-an-array
✅💯🔥Explanations No One Will Give You🎓🧠3 Detailed Approaches🎯🔥Extremely Simple And Effective🔥
explanations-no-one-will-give-you3-detai-7nsc
\n \n \n A year from now you may wish you had started today.\n \n \n \n --- Karen L
heir-of-god
NORMAL
2024-07-25T06:30:11.144675+00:00
2024-07-25T06:34:31.438570+00:00
28,303
false
<blockquote>\n <p>\n <b>\n A year from now you may wish you had started today.\n </b> \n </p>\n <p>\n --- Karen Lamb ---\n </p>\n</blockquote>\n\n# \uD83D\uDC51Problem Explanation and Understanding:\n\n## \uD83C\uDFAF Problem Description...
163
37
['Array', 'Divide and Conquer', 'Sorting', 'Merge Sort', 'Counting Sort', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
22
sort-an-array
✅ Java | Merge Sort | Easy
java-merge-sort-easy-by-kalinga-x5v5
Merge Sort Time Complexity -> Best :- O(N log N)\tAverage :- O(N log N)\tWorst :- O(N log N)\t\nSpace Complexity :- O(N)\nStable and not in-place\nExplanation :
kalinga
NORMAL
2023-03-01T00:38:15.709826+00:00
2023-03-01T00:44:03.412722+00:00
20,640
false
**Merge Sort Time Complexity -> Best :- O(N log N)\tAverage :- O(N log N)\tWorst :- O(N log N)\t\nSpace Complexity :- O(N)\nStable and not in-place\nExplanation :- [Link](https://youtu.be/ogjf7ORKfd8)**\n```\nclass Solution {\n public int[] sortArray(int[] nums) {\n mergeSort(nums,0,nums.length-1);\n r...
140
1
['Sorting', 'Merge Sort', 'Java']
10
sort-an-array
C++ merge, insertion, bubble, quick, heap
c-merge-insertion-bubble-quick-heap-by-s-hlra
Bubble sort\n\n\t// bubbleSort(nums);\n\tvoid bubbleSort(vector<int>& nums){\n for(int i = nums.size() - 1; i >= 0; i--)\n for(int j = 0; j <
sunhaozhe
NORMAL
2019-12-11T09:58:29.066133+00:00
2020-08-17T14:21:11.342217+00:00
18,699
false
Bubble sort\n```\n\t// bubbleSort(nums);\n\tvoid bubbleSort(vector<int>& nums){\n for(int i = nums.size() - 1; i >= 0; i--)\n for(int j = 0; j < i; j++)\n if(nums[j] > nums[j + 1]) \n swap(nums[j], nums[j + 1]);\n }\n```\n\n*****************************************...
109
4
['C', 'Sorting', 'Heap (Priority Queue)', 'Merge Sort', 'C++']
15
sort-an-array
🚀Simplest Solution🚀3 Approaches||🔥Heap Sort | Merge Sort || Priority Queue ||🔥C++
simplest-solution3-approachesheap-sort-m-jydb
Consider\uD83D\uDC4D\n\n Please Upvote If You Find It Helpful\n\n # Intuition \n Describe your first thoughts on how to solve this problem. \
naman_ag
NORMAL
2023-03-01T01:45:01.743843+00:00
2023-03-01T09:53:42.947536+00:00
15,434
false
# Consider\uD83D\uDC4D\n```\n Please Upvote If You Find It Helpful\n```\n<!-- # 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 you...
104
1
['Divide and Conquer', 'C', 'Heap (Priority Queue)', 'Merge Sort', 'C++']
9
sort-an-array
Explanation which makes the concept clear to interpret... Beats 98.75%
explanation-which-makes-the-concept-clea-e5r7
no misunderstandings please legal upvotes from my peers..\n\n# Approach\nThe main function sortArray contains a nested function quick_sort, which is a common pa
Aim_High_212
NORMAL
2024-07-25T00:13:31.195569+00:00
2024-07-25T09:41:20.162511+00:00
15,778
false
## no misunderstandings please legal upvotes from my peers..\n\n# Approach\nThe main function sortArray contains a nested function quick_sort, which is a common pattern to encapsulate the recursive logic within the sorting function and allows us to use variables from the outer scope.\n\nquick_sort takes two arguments, ...
94
11
['Python', 'C++', 'Python3', 'JavaScript']
15
sort-an-array
Merge Sort
merge-sort-by-eddiecarrillo-vqq8
\nclass Solution {\n public int[] sortArray(int[] nums) {\n int N = nums.length;\n mergeSort(nums, 0, N-1);\n return nums;\n }\n \
eddiecarrillo
NORMAL
2019-07-08T00:03:06.606069+00:00
2019-07-08T00:03:06.606118+00:00
39,988
false
```\nclass Solution {\n public int[] sortArray(int[] nums) {\n int N = nums.length;\n mergeSort(nums, 0, N-1);\n return nums;\n }\n \n \n void mergeSort(int[] nums, int start, int end){\n if (end - start+1 <= 1) return; //Already sorted.\n int mi = start + (end - start)...
61
3
[]
7
sort-an-array
Merge Sort|Radix sort|counting sort|heap sort||47ms Beats 99.41%
merge-sortradix-sortcounting-sortheap-so-9odo
Intuition\n Describe your first thoughts on how to solve this problem. \n1. Try merge sort which is stable & O(n log n) time\n2. Radix sort is a stable sort wit
anwendeng
NORMAL
2024-07-25T00:06:33.345214+00:00
2024-07-25T04:40:26.112508+00:00
12,490
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. Try merge sort which is stable & O(n log n) time\n2. Radix sort is a stable sort with 64 buckets with 3 passes & O(3n) time\n3. Counting sort is very suitible for this question which can be done very quickly.\n4. Heap sort is unstable...
54
3
['Array', 'Divide and Conquer', 'Sorting', 'Heap (Priority Queue)', 'Merge Sort', 'Radix Sort', 'Counting Sort', 'C++']
13
sort-an-array
912. Sort an Array (Sorting Algorithms)
912-sort-an-array-sorting-algorithms-by-csv9y
Few Sorting Algorithms:\n1. Selection Sort \n1. Bubble Sort\n1. Insertion Sort\n1. QuickSort\n1. Merge Sort\n\nSelection Sort - O(n^2)\n\n\nvar selectionSort =
kondaldurgam
NORMAL
2020-09-16T07:49:21.124837+00:00
2020-09-20T01:26:32.587857+00:00
9,507
false
**Few Sorting Algorithms**:\n1. Selection Sort \n1. Bubble Sort\n1. Insertion Sort\n1. QuickSort\n1. Merge Sort\n\n**Selection Sort - O(n^2)**\n\n```\nvar selectionSort = function(nums) {\n var n = nums.length;\n for (var i = 0; i <n-1; i++) {\n var min = i;\n for (var j = i+1; j < n; j++ ) {\n ...
47
1
['JavaScript']
8
sort-an-array
Merge Sort for Interviews! Short and Pythonic.
merge-sort-for-interviews-short-and-pyth-kzus
\ndef sortArray(self, nums: List[int]) -> List[int]:\n def mergeTwoSortedArrays(a, b , res):\n i, j, k = 0, 0, 0\n while i<len(a) a
azaansherani
NORMAL
2022-04-19T21:41:45.208435+00:00
2022-04-19T21:44:46.497630+00:00
4,734
false
```\ndef sortArray(self, nums: List[int]) -> List[int]:\n def mergeTwoSortedArrays(a, b , res):\n i, j, k = 0, 0, 0\n while i<len(a) and j<len(b):\n if a[i]<b[j]:\n res[k] = a[i]\n i+=1\n else:\n res[k] =...
41
0
['Merge Sort', 'Python', 'Python3']
6
sort-an-array
✅ Easy 3 step Sort Cpp / Java / Py / JS Solution | MergeSort _DivideNdConquer🏆|
easy-3-step-sort-cpp-java-py-js-solution-agr2
You may be wondering why we don\'t use Bubble Sort, Insertion Sort, or Selection Sort for this problem?\nThe constraint specifies that the solution must achieve
dev_yash_
NORMAL
2024-07-25T02:49:46.441974+00:00
2024-08-09T00:28:16.867077+00:00
9,158
false
#### You may be wondering why we don\'t use Bubble Sort, Insertion Sort, or Selection Sort for this problem?\nThe constraint specifies that the solution must achieve a time complexity of O(n log n).. or better. Algorithms like Bubble Sort, Insertion Sort, and Selection Sort have a time complexity of O(n^2), which is i...
36
0
['Array', 'Divide and Conquer', 'C', 'Sorting', 'Heap (Priority Queue)', 'Python', 'Java', 'Python3', 'JavaScript']
9
sort-an-array
Very Easy 100% Easiest Logic Ever (Fully Explained Step by Step)(C++, JavaScript, Java)
very-easy-100-easiest-logic-ever-fully-e-nx09
Intuition\nIf you wanna to solve this problem then you have a good grip on Recusrion because you have to solve this problem in O(nlogn) which is only possible b
EmraanHash
NORMAL
2023-03-01T05:56:15.295819+00:00
2023-03-01T06:58:38.653367+00:00
7,996
false
# Intuition\nIf you wanna to solve this problem then you have a good grip on Recusrion because you have to solve this problem in O(nlogn) which is only possible by using Merge sort or Quick Sort. but here in my solution I am using Merge Sort Algorithm\n\n# Approach\nHere\'s how the algorithm works step by step:\n\n**Di...
34
0
['C++', 'Java', 'JavaScript']
6
sort-an-array
Java QuickSort + SelectionSort + MergeSort summary
java-quicksort-selectionsort-mergesort-s-hpck
https://leetcode.com/submissions/detail/222979198/\n\nclass Solution {\n \n private static final int QUICKSORTSHOLD = 50;\n private static final int ME
scorego
NORMAL
2019-04-17T03:19:02.044324+00:00
2019-04-17T03:19:02.044383+00:00
13,728
false
https://leetcode.com/submissions/detail/222979198/\n```\nclass Solution {\n \n private static final int QUICKSORTSHOLD = 50;\n private static final int MERGESORTSHOLD = 300;\n \n public int[] sortArray(int[] nums) {\n if (nums == null || nums.length < 2){\n return nums;\n }\n ...
30
2
[]
10
sort-an-array
Java | Easy to Understand | 5 lines
java-easy-to-understand-5-lines-by-akash-t4d0
# Intuition \n\n\n# Approach : PriorityQueue\n- Step 1 : Take one ans array to store the sorted array and PriorityQueue pq. Default PriorityQueue is Min Heap
Akash_Markad_001
NORMAL
2023-03-01T04:13:00.566107+00:00
2023-03-01T04:13:00.566153+00:00
5,099
false
<!-- # Intuition -->\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach : PriorityQueue\n- **Step 1** : Take one ```ans``` array to store the sorted array and PriorityQueue ```pq```. Default PriorityQueue is Min Heap , It store all elements in ascending order.\n- **Step 2** : Add all ele...
28
0
['Array', 'Sorting', 'Heap (Priority Queue)', 'Java']
4
sort-an-array
Optimized Counting Sort | 3-ms Beats 100 % | Java | Python | C++ | JavaScript | Go
optimized-counting-sort-3-ms-beats-100-j-bqvr
\n# Problem Explanation:\n\nThis problem is asking us to create a function that sorts an array of numbers from smallest to largest (ascending order). However, t
kartikdevsharma_
NORMAL
2024-07-25T04:23:30.129063+00:00
2024-07-25T06:42:24.654835+00:00
3,684
false
\n# Problem Explanation:\n\n***This problem is asking us to create a function that sorts an array of numbers from smallest to largest (ascending order). However, there are some specific requirements we need to follow:***\n\n \n We can\'t use any built-in sorting functions.\n Our solution needs to be efficient,...
26
1
['Array', 'Divide and Conquer', 'Sorting', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']
3
sort-an-array
All 15 sorting methods solution is here_
all-15-sorting-methods-solution-is-here_-24i3
\nTable of Content:\nSTL\nMethod1: Standard\nMethod2: Stable\nInsertion Sort\nMethod1: Iterative\nMethod2: Recursive\nSelection Sort\nMethod1: Standard\nMethod2
NextThread
NORMAL
2022-01-13T05:37:12.621713+00:00
2022-01-13T05:37:12.621756+00:00
3,957
false
```\nTable of Content:\nSTL\nMethod1: Standard\nMethod2: Stable\nInsertion Sort\nMethod1: Iterative\nMethod2: Recursive\nSelection Sort\nMethod1: Standard\nMethod2: Standard using inbuilt\nBubble Sort\nQuick Sort\nMethod1: Standard\nMethod2: Randomised\nMerge Sort\nMethod1: Outplace Merging\nMethod2: Inplace Merging\nG...
24
0
['Recursion', 'C', 'Sorting', 'Heap (Priority Queue)', 'Merge Sort', 'Iterator']
3
sort-an-array
Python clean Quicksort
python-clean-quicksort-by-bindloss-7qtd
\nclass Solution(object):\n def sortArray(self, nums):\n self.quickSort(nums, 0, len(nums)-1)\n return nums\n\n def quickSort(self, nums, st
bindloss
NORMAL
2019-11-15T08:58:11.479201+00:00
2021-09-14T11:43:10.095472+00:00
5,829
false
```\nclass Solution(object):\n def sortArray(self, nums):\n self.quickSort(nums, 0, len(nums)-1)\n return nums\n\n def quickSort(self, nums, start, end):\n if end <= start:\n return\n mid = (start + end) // 2\n nums[start], nums[mid] = nums[mid], nums[start]\n ...
24
1
['Python']
9
sort-an-array
Java | Counting Sort | O(n) time | Clean code
java-counting-sort-on-time-clean-code-by-9xvv
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
judgementdey
NORMAL
2024-07-25T00:06:10.468241+00:00
2024-07-25T00:06:10.468264+00:00
4,515
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```\nclass Solution {\n public int[] sortArray(int[] nums) {\n var map = new int[100001];\n\n for (var n : nums)\n ...
22
4
['Array', 'Sorting', 'Java']
14
sort-an-array
Java Solution|| Explained || 3 Methods || Hybrid sorting - Insertion, Quick & Merge sort || Fast
java-solution-explained-3-methods-hybrid-54ln
Explanation:\n OOH the question is asking us to sort an array, so simple right? use Arrays.sort(nums) and be done with life, but stop let\'s try not to be lazy
muhsinmansoor_
NORMAL
2022-08-25T20:03:08.323578+00:00
2022-08-25T20:03:08.323602+00:00
3,612
false
**Explanation:**\n* OOH the question is asking us to sort an array, so simple right? use Arrays.sort(nums) and be done with life, but stop let\'s try not to be lazy today? we are going to solve this using top three basic sorting algorithms -- Insertion sort, Quick sort and Merge sort depending on the size of array.\n1...
22
0
['Sorting', 'Merge Sort', 'Java']
5
sort-an-array
I will never ever forget merge sort again
i-will-never-ever-forget-merge-sort-agai-m4rs
i learned merge\'s sort from : https://www.youtube.com/watch?v=mB5HXBb_HY8\ncopy paste on youtube if link doesn\'t works\nhe explained really well , i really ap
RohanPrakash
NORMAL
2020-05-14T18:16:12.922125+00:00
2020-05-19T16:58:14.201673+00:00
5,657
false
i learned merge\'s sort from : https://www.youtube.com/watch?v=mB5HXBb_HY8\ncopy paste on youtube if link doesn\'t works\n**he explained really well** , i really appreciate his beirf explanation, watch this and then **come back here if you were not able to code**.\n\n**assuming you still needs help in coding part ( yea...
21
1
['Recursion', 'Sorting', 'Merge Sort', 'C++']
5
sort-an-array
Merge Sort Python3
merge-sort-python3-by-ganjinaveen-f48u
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
GANJINAVEEN
NORMAL
2023-03-01T11:21:12.527932+00:00
2023-03-01T11:21:12.527981+00:00
2,982
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)$$ --...
19
0
['Python3']
3
sort-an-array
Python quicksort
python-quicksort-by-littletonconnor-70ra
\n\nclass Solution:\n def sortArray(self, nums: List[int]) -> List[int]:\n self.quicksort(nums, 0, len(nums) - 1)\n return nums\n \n def
littletonconnor
NORMAL
2019-08-08T17:56:04.844388+00:00
2019-08-08T17:56:04.844430+00:00
14,212
false
\n```\nclass Solution:\n def sortArray(self, nums: List[int]) -> List[int]:\n self.quicksort(nums, 0, len(nums) - 1)\n return nums\n \n def quicksort(self, nums, lower, upper):\n if lower < upper:\n pivot = self.partition(nums, lower, upper)\n self.quicksort(nums, low...
19
1
[]
6
sort-an-array
C++ solution || with explanation || Let's code it💻
c-solution-with-explanation-lets-code-it-wbt5
Upvote if you found this solution helpful\uD83D\uDD25\n\n# Approach\nBasically the question is asking us to implement the merge sort algorithm to sort the array
piyusharmap
NORMAL
2023-03-01T03:24:32.788091+00:00
2023-03-01T03:24:32.788142+00:00
5,558
false
# Upvote if you found this solution helpful\uD83D\uDD25\n\n# Approach\nBasically the question is asking us to implement the merge sort algorithm to sort the array in ascending order.\nIn Merge sort we divide the given array into two parts, sort the parts individually and then merge those parts to get a sorted array.\nT...
18
0
['Array', 'Sorting', 'Merge Sort', 'C++']
2
sort-an-array
✅ One Line Solution
one-line-solution-by-mikposp-dyw6
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)CodeTime complexity: O(n∗log(n)). Space complexity:
MikPosp
NORMAL
2024-07-25T09:26:17.050273+00:00
2025-01-12T10:22:06.951764+00:00
1,256
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly) # Code Time complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$. ```python3 class Solution: def sortArray(self, a: List[int]) -> List[int]: return (f:=lambda a:len(a)==1 and a or merge(f(a[:(m:=...
15
0
['Array', 'Divide and Conquer', 'Sorting', 'Merge Sort', 'Python', 'Python3']
1
sort-an-array
Python 3 || a cheat version and a legal version || T/S: 90% / 17%
python-3-a-cheat-version-and-a-legal-ver-fufr
I think the time% and space% on this problem are extremely skewed because of the scofflaws who usedsort(),sortedorheapq, not heeding the admonition on using "bu
Spaulding_
NORMAL
2023-03-01T19:55:22.357406+00:00
2024-05-31T17:12:24.740305+00:00
4,167
false
I think the time% and space% on this problem are extremely skewed because of the scofflaws who used`sort()`,`sorted`or`heapq`, not heeding the admonition on using "built-in functions.".\n\nUsing `Counter`,`chain`,`max`,or,`mn` techically makes me a scofflaw too, so I included a non-scofflaw version below as well.\n\nMy...
15
0
['Python3']
5
sort-an-array
Quick Sort & Merge Sort in Python, Easy to Understand, Standard Template!
quick-sort-merge-sort-in-python-easy-to-j1123
Two Methods:\n1. Quick Sort\n2. Merge Sort\n\n1. Standard Quick Sort Tempate,\n\nIn the while loop, the reason we use "nums[left] < pivot" instead of "nums[left
GeorgePot
NORMAL
2022-02-19T16:48:37.945168+00:00
2022-05-08T14:32:47.489937+00:00
3,268
false
**Two Methods:**\n**1. Quick Sort**\n**2. Merge Sort**\n\n**1. Standard Quick Sort Tempate**,\n\nIn the while loop, the reason we use "**nums[left] < pivot**" instead of "nums[left] <= pivot" is to **avoid falling into forever loop**.\n**For example:**\nnums = [1, 1, 1], pivot will be 1.\nIf we use "nums[left] <= pivot...
14
0
['Sorting', 'Merge Sort', 'Python']
1
sort-an-array
mergesort in python3
mergesort-in-python3-by-dqdwsdlws-vjm8
\nclass Solution:\n def sortArray(self, nums: List[int]) -> List[int]:\n #mergesort\n if len(nums) <= 1:\n return nums\n midd
dqdwsdlws
NORMAL
2020-10-22T15:08:44.555362+00:00
2020-10-22T15:08:44.555409+00:00
1,494
false
```\nclass Solution:\n def sortArray(self, nums: List[int]) -> List[int]:\n #mergesort\n if len(nums) <= 1:\n return nums\n middle = len(nums) // 2\n left = self.sortArray(nums[:middle])\n right = self.sortArray(nums[middle:])\n merged = []\n while left and...
14
0
['Merge Sort', 'Python3']
0