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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
split-message-based-on-limit | C# || Solution | c-solution-by-vdmhunter-1gzx | Code\n\npublic class Solution\n{\n public string[] SplitMessage(string message, int limit)\n {\n var cur = 0;\n var k = 0;\n var i = | vdmhunter | NORMAL | 2022-11-13T01:03:45.320135+00:00 | 2022-11-13T01:03:45.320182+00:00 | 99 | false | # Code\n```\npublic class Solution\n{\n public string[] SplitMessage(string message, int limit)\n {\n var cur = 0;\n var k = 0;\n var i = 0;\n\n while (3 + k.ToString().Length * 2 < limit && cur + message.Length + (3 + k.ToString().Length) * k > limit * k)\n {\n k += ... | 1 | 0 | ['C#'] | 0 |
split-message-based-on-limit | Binary search | binary-search-by-changkunli-3xbp | Approach\n Describe your approach to solving the problem. \n\nBinary search the number of parts\n\n# Complexity\n- Time complexity: O(log n + n), binary search | changkunli | NORMAL | 2022-11-12T18:39:15.157761+00:00 | 2022-11-13T02:10:02.419897+00:00 | 703 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\n\nBinary search the number of parts\n\n# Complexity\n- Time complexity: O(log n + n), binary search + answer construction\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... | 1 | 0 | ['C++'] | 1 |
split-message-based-on-limit | C++ Binary Search || Easy Implementation || Video Solution || prashar32 | c-binary-search-easy-implementation-vide-cjp8 | Myself Adarsh Prashar\n\nI am top 0.02% (Globally) Candidate Master(2048) at Codeforces, Guardian (top 0.8%) at Leetcode and 6 Star (2208) at Codechef\n\nAbout | prashar32 | NORMAL | 2022-11-12T17:20:51.697134+00:00 | 2022-11-12T17:20:51.697172+00:00 | 276 | false | Myself Adarsh Prashar\n\n**I am top 0.02% (Globally) Candidate Master(2048) at Codeforces, Guardian (top 0.8%) at Leetcode and 6 Star (2208) at Codechef**\n\n**About Me -** I have a youtube channel in which I upload editorials of leetcode, codeforces and codechef contest.\n\nYou can understand my method to solve that.\... | 1 | 1 | ['Binary Tree'] | 0 |
split-message-based-on-limit | Fast, Tricky Python3 Explained | fast-tricky-python3-explained-by-ryangra-v9hw | The idea here is to iterate through all possible numbers of parts we could split into, and for each one check if it is possible to split into that many parts. W | ryangrayson | NORMAL | 2022-11-12T16:40:45.959510+00:00 | 2022-11-12T16:41:45.851193+00:00 | 195 | false | The idea here is to iterate through all possible numbers of parts we could split into, and for each one check if it is possible to split into that many parts. We can do this efficiently in O(log10(N)) time where N is the length of the message - (note that log10(N) <= 4 given the constraint of N <= 1000). Thus, worst ca... | 1 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | [C++] Brute Force, O(n) | c-brute-force-on-by-kevin1010607-m28e | Search how many chunks from 1 to n.\n\nIn each iteration:\nspace is the number of total capacity to fill message.\nlast is the capacity of last chunk.\nramain i | kevin1010607 | NORMAL | 2022-11-12T16:09:08.212429+00:00 | 2022-11-12T16:13:01.894337+00:00 | 356 | false | Search how many chunks from 1 to n.\n\nIn each iteration:\n`space` is the number of total capacity to fill message.\n`last` is the capacity of last chunk.\n`ramain` is the number of reamining character after filling the first i-1 chunks.\n\nFunction:\n`digit` is the length of a number.\n`all_len` is the sum of the leng... | 1 | 0 | ['C++'] | 1 |
split-message-based-on-limit | Leveraging Ranged Approach: Beats 80+ % | leveraging-ranged-approach-beats-80-by-a-qerk | IntuitionOver specific ranges of part numbers, overhead is predictable. Use a piece-wise buildupApproachGiven that the suffix length is subtracted from the avai | aleetlf | NORMAL | 2025-04-10T02:12:24.667708+00:00 | 2025-04-10T02:12:24.667708+00:00 | 1 | false | # Intuition
Over specific ranges of part numbers, overhead is predictable. Use a piece-wise buildup
# Approach
Given that the suffix length is subtracted from the available space per part, and that suffix length is both dependent on the current part number's width in digit and dependent on width of the total part coun... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | Find the denominator first | find-the-denominator-first-by-kchetan-2qkp | IntuitionHardest part of the problem is finding the denominator. We do this itertively checking if denomminator is 1 digit,.. 2 digit, .. n digit.Added some che | kchetan | NORMAL | 2025-04-04T06:38:20.058282+00:00 | 2025-04-04T06:38:20.058282+00:00 | 4 | false | # Intuition
Hardest part of the problem is finding the denominator. We do this itertively checking if denomminator is 1 digit,.. 2 digit, .. n digit.
Added some checks to return early.
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
O(log(length(n))) - almost O(1)
... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | C# Soluction with Binary Search | c-soluction-with-binary-search-by-icecof-m6cy | Code | IceCoffeeY | NORMAL | 2025-03-20T22:08:42.888886+00:00 | 2025-03-20T22:08:42.888886+00:00 | 2 | false | # Code
```csharp []
public class Solution {
public string[] SplitMessage(string message, int limit)
{
var n = message.Length;
var digit = 1;
while (true)
{
// 1 - 9, 10 - 99, 100 - 999, 1000, 9999....
var count = 0;
var x = 1;
for ... | 0 | 0 | ['C#'] | 0 |
split-message-based-on-limit | Homegrown Pythonic Simple Solution (28 Lines) | homegrown-pythonic-simple-solution-28-li-l2ep | IntuitionTake advantage of the static message trailer length per digit range.ApproachUse the ranges for number of available digits in 1-9, 10-99, 100-999, 1000- | baninja6 | NORMAL | 2025-03-05T01:14:55.791081+00:00 | 2025-03-05T01:14:55.791081+00:00 | 9 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Take advantage of the static message trailer length per digit range.
# Approach
<!-- Describe your approach to solving the problem. -->
Use the ranges for number of available digits in 1-9, 10-99, 100-999, 1000-9999, etc to find the righ... | 0 | 0 | ['String', 'Python3'] | 0 |
split-message-based-on-limit | [Java] Binary Search for Message Partitioning. Beats 92.48% runtime and 96.08% memory | java-binary-search-for-message-partition-8dwb | IntuitionYou can use binary search to determine the optimal number of parts, initially ranging from 1 to message.length(). Additionally, you can calculate the l | fleum | NORMAL | 2025-02-17T03:56:24.472468+00:00 | 2025-02-17T03:56:24.472468+00:00 | 19 | false | # Intuition
You can use binary search to determine the optimal number of parts, initially ranging from 1 to message.length(). Additionally, you can calculate the length of the first segment to extract, given that each part has a fixed length:
```
int x = limit - 4 - l;
```
Here, 4 accounts for the characters '<', '1', ... | 0 | 0 | ['Java'] | 1 |
split-message-based-on-limit | C++, binary search, hopefully a good explanation | c-binary-search-hopefully-a-good-explana-nuz0 | IntuitionI wanted to describe what tripped me up on this problem.I stumbled upon this problem because I wanted to practice binary search problems, so I knew goi | mklose | NORMAL | 2025-02-13T08:33:40.308029+00:00 | 2025-02-13T08:33:40.308029+00:00 | 26 | false | # Intuition
I wanted to describe what tripped me up on this problem.
I stumbled upon this problem because I wanted to practice binary search problems, so I knew going in that binary search had to be used somehow.
Initially I thought I could create a function that would create a kind of step function that goes from n... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Javascript solution | javascript-solution-by-kancerezeroglu-uycl | Example:Step 1: Finding kksasbscAvailable Space (limit * k - (sumOfDigits + totalLenOfIndicies + totalLenOfFormat))Can Fit?11139 * 1 - (1 + 1 + 3) = 4❌22269 * 2 | kancerezeroglu | NORMAL | 2025-02-07T16:01:24.881759+00:00 | 2025-02-07T16:05:59.098762+00:00 | 11 | false | # Example:
### **Step 1: Finding `k`**
| `k` | `sa` | `sb` | `sc` | Available Space (`limit * k - (sumOfDigits + totalLenOfIndicies + totalLenOfFormat)`) | Can Fit? |
|----|----|----|----|--------------------------------|---------|
| 1 | 1 | 1 | 3 | `9 * 1 - (1 + 1 + 3) = 4` | ❌ |
| 2 | 2 | 2 | 6 | `9 * 2 - (2 + 4 + 6)... | 0 | 0 | ['JavaScript'] | 0 |
split-message-based-on-limit | [Java] Two binary search faster than 100% | java-two-binary-search-faster-than-100-b-8kx4 | Intuition
First binary search searching the minimum digits we need.
Second binary search searching the minimum 'b' based on the digitswe got in the first binary | raywang945 | NORMAL | 2025-01-19T20:06:49.354245+00:00 | 2025-01-19T20:06:49.354245+00:00 | 23 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
- First binary search searching the minimum digits we need.
- Second binary search searching the minimum 'b' based on the digitswe got in the first binary search.
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | 2468. Split Message Based on Limit | 2468-split-message-based-on-limit-by-g8x-brqr | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | G8xd0QPqTy | NORMAL | 2025-01-18T16:22:30.251901+00:00 | 2025-01-18T16:22:30.251901+00:00 | 24 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Simple Easy Approach | simple-easy-approach-by-umerwajih-hmzx | IntuitionThe problem requires splitting a message into parts such that each part includes a suffix in the format <part/total> and the total length of each part | umerwajih | NORMAL | 2025-01-17T22:20:33.078314+00:00 | 2025-01-17T22:20:33.078314+00:00 | 19 | false | # Intuition
The problem requires splitting a message into parts such that each part includes a suffix in the format <part/total> and the total length of each part does not exceed the given limit. The challenge lies in dynamically adjusting the number of characters available for the message as the suffix grows in length... | 0 | 0 | ['Java'] | 1 |
split-message-based-on-limit | Python beats 91%, cheap calculation of number of iterations without fancy data structures | python-beats-91-cheap-calculation-of-num-2g8l | IntuitionThe intuition here is that we can easily calculate the number of iterations without traversing the message, by estimating the number of digits of the t | passadore | NORMAL | 2024-12-30T14:35:32.535958+00:00 | 2024-12-30T14:35:32.535958+00:00 | 22 | false | # Intuition
The intuition here is that we can easily calculate the number of iterations without traversing the message, by estimating the number of digits of the total number of chunks. Once we have that value, it is easy to return the result by travesing the message.
# Approach
Since the size of each chunk depends o... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Simple Cpp Solution. TC - O(len(message)) | simple-cpp-solution-tc-olenmessage-by-re-nua5 | Code | reet-bhaati | NORMAL | 2024-12-26T17:31:05.125195+00:00 | 2024-12-26T17:31:05.125195+00:00 | 15 | false | # Code
```cpp []
class Solution {
public:
vector<string> solve(string message, int limit, int digit){
int k;
if(digit == 1){
k = 9;
}else if(digit == 2){
k = 99;
}else if(digit == 3){
k = 999;
}else{
k = 9999;
}
... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Python solution | python-solution-by-sabyasachim999-z6tn | IntuitionApproachComplexity
Time complexity:
Space complexity:
Code | sabyasachim999 | NORMAL | 2024-12-26T07:05:02.829705+00:00 | 2024-12-26T07:05:02.829705+00:00 | 10 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
# Approach
<!-- Describe your approach to solving the problem. -->
# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
`... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | JAVA O(N) time complexity, beat 100% | java-on-time-complexity-beat-100-by-zwan-lqc3 | IntuitionTry to find the number of element in the array, and make the new string in the array with stringbuilderApproachfirst start from 1, to find the proper l | zwang3184 | NORMAL | 2024-12-20T03:18:25.469298+00:00 | 2024-12-20T03:18:25.469298+00:00 | 23 | false | # Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Try to find the number of element in the array, and make the new string in the array with stringbuilder
# Approach
<!-- Describe your approach to solving the problem. -->
first start from 1, to find the proper length of array, to make the l... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | scala solution | scala-solution-by-vititov-oh0w | scala []\nobject Solution {\n def splitMessage(message: String, limit: Int): Array[String] = {\n LazyList.range(1,6).flatMap { len =>\n lazy val x0 = L | vititov | NORMAL | 2024-12-08T20:51:51.303823+00:00 | 2024-12-08T20:51:51.303875+00:00 | 3 | false | ```scala []\nobject Solution {\n def splitMessage(message: String, limit: Int): Array[String] = {\n LazyList.range(1,6).flatMap { len =>\n lazy val x0 = List.unfold((0, 1)) { case (i, j) => Option.when(i < message.length) {\n lazy val i1 = ((i + limit - 3 - len - j.toString.length) max i + 1) min messag... | 0 | 0 | ['Scala'] | 0 |
split-message-based-on-limit | Modified Binary Search to Avoid Problem | modified-binary-search-to-avoid-problem-lszbd | Explanation\n Describe your first thoughts on how to solve this problem. \nSince the length of the message that can be expressed as a function of the number of | dddwww | NORMAL | 2024-11-12T07:10:21.900088+00:00 | 2024-11-12T07:10:21.900123+00:00 | 18 | false | # Explanation\n<!-- Describe your first thoughts on how to solve this problem. -->\nSince the length of the message that can be expressed as a function of the number of suffix is not monotonic, it creates a trouble for using Binary search. (e.g. 100 suffix will likely be able to express a message shorter than 99 messag... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | C++ soln with comments and clear code beats 85% soln time. | c-soln-with-comments-and-clear-code-beat-6p15 | Intuition\nFirst compute number of digits of denominator and then compute the denominator itself and then actual answer i.e. vector.\n\n# Approach\nOnce we know | ayusverma | NORMAL | 2024-11-09T18:44:56.274582+00:00 | 2024-11-09T18:44:56.274622+00:00 | 15 | false | # Intuition\nFirst compute number of digits of denominator and then compute the denominator itself and then actual answer i.e. vector<string>.\n\n# Approach\nOnce we know the denominator it\'s just travesal over original string to compute the final answer.\n\n# Complexity\n- Time complexity:\n$$O(n)$$\n\n- Space comple... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Simple beats 94% (self documenting) | simple-beats-94-self-documenting-by-rang-t1z9 | Intuition\nFind out the max suffix length for your inputs. \n\n# Approach\nBrute force first time to determine the buckets and then hard code the same. \n\n# Co | rangareddy | NORMAL | 2024-11-06T15:24:59.953936+00:00 | 2024-11-06T15:24:59.953970+00:00 | 21 | false | # Intuition\nFind out the max suffix length for your inputs. \n\n# Approach\nBrute force first time to determine the buckets and then hard code the same. \n\n# Complexity\n- Time complexity: O(n)\n- Space complexity: O(n)\n\n# Code\n```python3 []\nclass Solution:\n def _get_suffix_size_blocks(self):\n blocks ... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | simple o(n) linear search | simple-on-linear-search-by-ashishkumanar-3lx4 | Intuition\n Describe your first thoughts on how to solve this problem. \nAt max there can be n partitions.we iterate from 1 to n and check whether it is possibl | Ashishkumanar | NORMAL | 2024-11-02T08:05:26.202417+00:00 | 2024-11-02T08:05:26.202448+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAt max there can be n partitions.we iterate from 1 to n and check whether it is possible to split in o(1). then once we found ideal partiton size we partition the string in linear search.\n# Approach\nlets say we have m partiton.total *si... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | beats 100%, 16 line with explanations | beats-100-16-line-with-explanations-by-a-g9fo | Intuition\n\n# Approach\n1. Find the number of digits for the number messages required (3 digits if number of messages required is 100<= #messages <= 999)\n2. F | afamsmith | NORMAL | 2024-10-23T18:06:47.640217+00:00 | 2024-10-23T18:06:47.640272+00:00 | 22 | false | # Intuition\n\n# Approach\n1. Find the number of digits for the number messages required (3 digits if number of messages required is 100<= #messages <= 999)\n2. Find exact number of messages\n3. Construct the result \n\nFor step 1:\n#### Assuming limit -= 5 (not counting already required characters)\n#### 1 digit enoug... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Do binary search 4 times | do-binary-search-4-times-by-andreashzz-ox6e | Intuition\n Describe your first thoughts on how to solve this problem. \nAt first, I thought I only need to do one binary search, but then I realized that for d | AndreasHzz | NORMAL | 2024-10-22T17:49:09.888107+00:00 | 2024-10-22T17:49:09.888144+00:00 | 10 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAt first, I thought I only need to do one binary search, but then I realized that for different post length( the length of "/#number of parts>") it is not monotonic. There are at most 4 post length, since the max length is 10^4, so we do ... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | Python3 beats 100% | python3-beats-100-by-l33twarrior-5b4i | Approach\n1. reduce limit for 3 chars () and calculate number of parts based on it to get initial number of parts\n2. calculate how many digits we will need for | L33tWarrior | NORMAL | 2024-10-22T16:09:31.351463+00:00 | 2024-10-22T16:09:31.351491+00:00 | 17 | false | # Approach\n1. reduce limit for 3 chars (</>) and calculate number of parts based on it to get initial number of parts\n2. calculate how many digits we will need for total number of parts X in the message (<Y/X>) and adjust limit based on that\n3. calculate how many more spaces we will need for Y (<Y/X>)\n4. if total s... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Easy Greedy Solution | easy-greedy-solution-by-kvivekcodes-mppp | 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 | kvivekcodes | NORMAL | 2024-10-10T10:24:23.282432+00:00 | 2024-10-10T10:24:23.282467+00:00 | 17 | 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 | ['String', 'Greedy', 'C++'] | 0 |
split-message-based-on-limit | Calculate parts needed based on suffix sizes up to 9999 parts | calculate-parts-needed-based-on-suffix-s-44sy | 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 | calvitronic | NORMAL | 2024-10-09T21:24:15.231091+00:00 | 2024-10-09T21:27:34.856882+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<!-- 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 | ['Python'] | 0 |
split-message-based-on-limit | Python3 Intuitive: Assume Message Count < 9, Update as Needed O(n) O(n) | python3-intuitive-assume-message-count-9-j7be | Intuition\nAs others noted, problem reduces to finding total number of messages. Let ml=message length. While ml>0, assume total number of messages is <9, now y | jbradleyglenn | NORMAL | 2024-10-05T23:51:09.166551+00:00 | 2024-10-05T23:53:30.474487+00:00 | 15 | false | # Intuition\nAs others noted, problem reduces to finding total number of messages. Let ml=message length. While ml>0, assume total number of messages is <9, now you know how big each message is. After processing message 9, if you still have message length to send, then assume total number of messages <99 instead, and k... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Two Sub Problems - Find Number of Splits and Split Message | two-sub-problems-find-number-of-splits-a-lpl5 | Intuition\n Describe your first thoughts on how to solve this problem. \nTo split the messages, we need to know the total split, we can get out of the message. | ned1m | NORMAL | 2024-10-05T16:27:35.855949+00:00 | 2024-10-05T16:27:35.855975+00:00 | 9 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo split the messages, we need to know the total split, we can get out of the message. This breaks down the problem into 2 simpler problems.\n- Find number of split\n- Split the message\n# Approach\n<!-- Describe your approach to solving ... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | [Python3] Search lowers, if needed binary search | python3-search-lowers-if-needed-binary-s-gdd3 | python3 []\nclass Solution:\n def splitMessage(self, message: str, limit: int) -> List[str]:\n def cnt(x):\n mdig_num = len(str(x))\n | timetoai | NORMAL | 2024-09-29T15:39:57.778842+00:00 | 2024-09-29T15:39:57.778868+00:00 | 23 | false | ```python3 []\nclass Solution:\n def splitMessage(self, message: str, limit: int) -> List[str]:\n def cnt(x):\n mdig_num = len(str(x))\n res = sum(dig_num * (9 * 10 ** (dig_num - 1)) for dig_num in range(1, mdig_num))\n lst = mdig_num * ((9 * 10 ** (mdig_num - 1)) - (10 ** mdi... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | My Solution | my-solution-by-vicvictle-v324 | 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 | vicvictle | NORMAL | 2024-09-16T19:02:51.260906+00:00 | 2024-09-16T19:02:51.260933+00:00 | 12 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Python binary search solution | python-binary-search-solution-by-sreejag-epw2 | 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 | sreejagov | NORMAL | 2024-09-13T03:02:49.900654+00:00 | 2024-09-13T03:02:49.900681+00:00 | 42 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | python bruteforce | python-bruteforce-by-renolest-t2qr | 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 | Renolest | NORMAL | 2024-09-04T23:04:25.681318+00:00 | 2024-09-04T23:04:25.681350+00:00 | 7 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | ■■■■■■■■■■BINARY TREE APPROACH, BRAND NEW■■■■■■■■■■ | binary-tree-approach-brand-new-by-user58-08ut | Intuition\n Describe your first thoughts on how to solve this problem. \nbinary approacch, nlogn\ninput arange was 100,000\n\n# Approach\n Describe your approac | user5898VA | NORMAL | 2024-08-27T05:15:54.513285+00:00 | 2024-08-27T05:15:54.513308+00:00 | 4 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nbinary approacch, nlogn\ninput arange was 100,000\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nbinary search\n\n# Complexity\n- Time complexity: m * nlogn\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Easy-to-Understand Binary Search Approach in Java | easy-to-understand-binary-search-approac-nkby | Code\njava []\nclass Solution {\n public String[] splitMessage(String message, int limit) {\n int digit = 1;\n\n while (true) {\n in | user2762Pr | NORMAL | 2024-08-20T15:44:06.850797+00:00 | 2024-08-20T15:44:06.850884+00:00 | 73 | false | # Code\n```java []\nclass Solution {\n public String[] splitMessage(String message, int limit) {\n int digit = 1;\n\n while (true) {\n int left = (int) Math.pow(10, digit - 1);\n int right = (int) Math.pow(10, digit) - 1;\n\n if (left > message.length()) {\n ... | 0 | 0 | ['Binary Search', 'Java'] | 0 |
split-message-based-on-limit | Python Solution | python-solution-by-rohamghotbi-v7fr | Not my best work tbh but Does the Job\n# Code\npython3 []\nclass Solution:\n def splitMessage(self, message: str, limit: int) -> List[str]:\n if limit | rohamghotbi | NORMAL | 2024-08-20T09:49:24.946535+00:00 | 2024-08-20T09:49:24.946566+00:00 | 17 | false | Not my best work tbh but Does the Job\n# Code\n```python3 []\nclass Solution:\n def splitMessage(self, message: str, limit: int) -> List[str]:\n if limit < 6:\n return ""\n if len(message) < limit - 5:\n return [f"{message}<1/1>"]\n lo = len(message) // (limit - 5)\n ... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Java Solution | java-solution-by-lockmyre-m9gf | Intuition\nIntuition is difficult on this one. Since the question involves getting the least number of parts, binary search should be a reasonable answer; i.e., | lockmyre | NORMAL | 2024-08-10T20:33:23.659678+00:00 | 2024-08-10T20:38:42.794706+00:00 | 22 | false | # Intuition\nIntuition is difficult on this one. Since the question involves getting the least number of parts, binary search should be a reasonable answer; i.e., if the current number uses too few parts, go right. If the current number uses too many parts, go left. If the current number uses just the right amount of p... | 0 | 0 | ['Binary Search', 'Java'] | 0 |
split-message-based-on-limit | JS approach for this solution with human readable comments | js-approach-for-this-solution-with-human-ge7h | 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 | perchytheace | NORMAL | 2024-07-13T21:13:54.833647+00:00 | 2024-07-13T21:13:54.833666+00:00 | 20 | 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 |
split-message-based-on-limit | Simple O(N) code, no tricks, no embedded constants and other shits. | simple-on-code-no-tricks-no-embedded-con-7k6f | Intuition - Only the total\'s size is unknown.\n Describe your first thoughts on how to solve this problem. \n\n# Approach - As moving forward, we update a valu | pretrator | NORMAL | 2024-07-07T19:01:51.500603+00:00 | 2024-07-07T19:01:51.500628+00:00 | 79 | false | # Intuition - Only the total\'s size is unknown.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach - As moving forward, we update a value called globalRemover which allows reducing length at back\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | C++ Dividing a Message into Parts with Order-Preserving Suffixes | c-dividing-a-message-into-parts-with-ord-eu99 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires splitting a message into multiple segments such that each segment, | orel12 | NORMAL | 2024-07-07T13:48:15.874439+00:00 | 2024-07-07T13:48:15.874462+00:00 | 34 | false | ### Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires splitting a message into multiple segments such that each segment, including its suffix indicating its order, fits within a specified character limit. The suffix helps in maintaining the order and completeness of th... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | no binary search, calculate the number of messages directly | no-binary-search-calculate-the-number-of-mtsy | Approach\nCan we use 9 messages to split the original message? If we cannot, can use 99 messages to split the original message?...\nWe only has to try up to 999 | xslpeter | NORMAL | 2024-06-28T20:07:43.098664+00:00 | 2024-06-28T20:07:43.098687+00:00 | 32 | false | # Approach\nCan we use 9 messages to split the original message? If we cannot, can use 99 messages to split the original message?...\nWe only has to try up to 99999 as there\'re only 10000 chars max so max number of messages is 10000. That\'s what function findMessageCountSize() does, which returns the number of digits... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Easy Java Solution! | easy-java-solution-by-srula-4945 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires us to split a message into multiple parts where each part ends wit | srula | NORMAL | 2024-06-26T07:20:42.359324+00:00 | 2024-06-26T07:22:16.353277+00:00 | 23 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires us to split a message into multiple parts where each part ends with a suffix indicating its position. The length of each part including the suffix should not exceed a given limit, and we aim to use as few parts as pos... | 0 | 0 | ['Math', 'Java'] | 0 |
split-message-based-on-limit | Solution Beats 100% Binary Search | solution-beats-100-binary-search-by-mych-cs68 | Intuition\n Describe your first thoughts on how to solve this problem. \nBeats 100%\n\n# Approach\n Describe your approach to solving the problem. \nBinary sear | mycherryblossomsareinbloomforu | NORMAL | 2024-06-25T04:47:47.235363+00:00 | 2024-06-25T04:47:47.235393+00:00 | 19 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBeats 100%\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBinary search\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(logn)\n![Screenshot 2024-06-25 at 12.45.14\u202... | 0 | 0 | ['Python'] | 0 |
split-message-based-on-limit | Wasn't able to BS it, instead linear for pages with skipping to avoid TLE | wasnt-able-to-bs-it-instead-linear-for-p-m2v2 | 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 | murh | NORMAL | 2024-06-15T14:15:51.623399+00:00 | 2024-06-15T14:15:51.623416+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:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['C#'] | 0 |
split-message-based-on-limit | Simple Solution | simple-solution-by-gilbert2-9e4y | 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 | gilbert2 | NORMAL | 2024-05-28T04:48:50.853181+00:00 | 2024-05-28T04:48:50.853206+00:00 | 61 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | EASY || Beats 85% | easy-beats-85-by-sam78692-qctw | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \nFirst we divide the tex | Sam78692 | NORMAL | 2024-05-21T17:35:31.378771+00:00 | 2024-05-21T17:35:31.378800+00:00 | 33 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\nFirst we divide the text into words with max limit "LIMIT - 5" because ["<_/_>" (5 min characters)] then we will see how many characters will the suffix take acc to an... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | c++ solution | c-solution-by-gamer2023-nsp1 | Intuition\nthis solution is based on @lee215\'s solution in https://leetcode.com/problems/split-message-based-on-limit/solutions/2807533/python-find-the-number- | gamer2023 | NORMAL | 2024-05-06T20:36:41.158727+00:00 | 2024-05-06T20:36:41.158779+00:00 | 18 | false | # Intuition\nthis solution is based on @lee215\'s solution in https://leetcode.com/problems/split-message-based-on-limit/solutions/2807533/python-find-the-number-of-substrings\n\nwith small modifications and comments to help to understand.\n\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Co... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | dp | dp-by-jaikechen2018-zs43 | \n# Code\n\nfunc splitMessage(message string, limit int) []string {\n idxLen := 0\n ok := false\n for i:= 1; i <= len(message); i ++{\n idxLen, | jaikechen2018 | NORMAL | 2024-04-08T14:34:12.835478+00:00 | 2024-04-08T14:34:12.835506+00:00 | 9 | false | \n# Code\n```\nfunc splitMessage(message string, limit int) []string {\n idxLen := 0\n ok := false\n for i:= 1; i <= len(message); i ++{\n idxLen, ok = find(message, limit, i, idxLen)\n if ok {\n return build(message, limit, i)\n }\n }\n return nil\n}\n\nfunc build(message... | 0 | 0 | ['Go'] | 0 |
split-message-based-on-limit | An recursive implementation | an-recursive-implementation-by-jcodefun-vj9a | 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 | JCodeFun | NORMAL | 2024-04-03T22:25:40.317947+00:00 | 2024-04-03T22:26:03.504026+00:00 | 45 | 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(log_10 N * N/limit)\n- Space complexity:\n<!-- Add your space complexity h... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Java solution -> calculate necessary parts first | java-solution-calculate-necessary-parts-ub517 | Intuition\nCalculate the necessary number of parts, then fill in the array.\n\n# Approach\nFirst try to use only one part, then allocate the remaining message e | adamk90 | NORMAL | 2024-03-31T19:34:12.731184+00:00 | 2024-03-31T19:34:12.731230+00:00 | 57 | false | # Intuition\nCalculate the necessary number of parts, then fill in the array.\n\n# Approach\nFirst try to use only one part, then allocate the remaining message evenly respect to the needed suffix size. Keep on trying with increasing number of parts until we find the right number to eliminate all the message (no remain... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | Binary search, O(log2(N)), fix regular binary search not working for some cases | binary-search-olog2n-fix-regular-binary-hfs4c | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nFixed bug in binary search, search from 10, 100, 1000 ... return whenever | fath2012 | NORMAL | 2024-02-24T23:24:21.776431+00:00 | 2024-02-24T23:24:21.776463+00:00 | 29 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nFixed bug in binary search, search from 10, 100, 1000 ... return whenever the parts is too big or correct size\n\n# Complexity\n- Time complexity:\nO(log2(N))\n\n- Space complexity:\n<!-- Add your space complexity here, e.g.... | 0 | 0 | ['C++'] | 0 |
split-message-based-on-limit | Java Solution | java-solution-by-ck1612-nzsl | 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 | ck1612 | NORMAL | 2024-02-06T21:40:47.365674+00:00 | 2024-02-06T21:40:47.365706+00:00 | 55 | 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 | ['Java'] | 0 |
split-message-based-on-limit | [Python3] 99% solution | python3-99-solution-by-zhfang1111-876f | 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 | zhfang1111 | NORMAL | 2024-01-27T17:22:30.849343+00:00 | 2024-01-27T17:22:30.849368+00:00 | 190 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 0 | 0 | ['Python3'] | 0 |
split-message-based-on-limit | Brute Force O(n). Just a Simple Trick.✅✅ | brute-force-on-just-a-simple-trick-by-co-lulg | Intuition\n Describe your first thoughts on how to solve this problem. \nObservation1:\nWhen you observe every suffix will be minimum of length 5. How?\n => of | code__hard | NORMAL | 2024-01-25T20:21:46.853121+00:00 | 2024-01-25T20:21:46.853141+00:00 | 872 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nObservation1:\nWhen you observe every suffix will be minimum of length 5. How?\n<a/b> => </> of length 3 + single_digit_a + single_digit_b.\nSo if your given limit is <=5 then return [].\n\nObservation2:\nWe need to find the no_of_digits ... | 0 | 0 | ['Math', 'Python3'] | 1 |
split-message-based-on-limit | Binary search solution | binary-search-solution-by-haomingw-5fxp | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nfindLen(9, 8) > findLen(10, 8). Need to define the right bounder of binar | haomingw | NORMAL | 2024-01-23T20:58:50.900305+00:00 | 2024-01-23T20:58:50.900337+00:00 | 51 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nfindLen(9, 8) > findLen(10, 8). Need to define the right bounder of binary search in {9, 99, 999, 999} first.\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(n)\n\n# Code\n```\nclass Solution {\n publi... | 0 | 0 | ['Java'] | 0 |
split-message-based-on-limit | Binary search is wrong | binary-search-is-wrong-by-crazy_y-vnbt | \n Describe your first thoughts on how to solve this problem. \nBinary search only works when the answer is monotonic, which means if you can split it into x pa | crazy_y | NORMAL | 2024-01-16T10:33:17.048390+00:00 | 2024-01-16T10:33:17.048415+00:00 | 21 | false | \n<!-- Describe your first thoughts on how to solve this problem. -->\nBinary search only works when the answer is monotonic, which means if you can split it into x parts, it must can be split into x+1 parts. but it is not true, consider a case where you can split a long message into 999 parts, but you may not split it... | 0 | 0 | ['C++'] | 0 |
merge-in-between-linked-lists | 🔥✅✅ Beat 97.13% | ✅ Full Explanation ✅✅🔥 | beat-9713-full-explanation-by-devogabek-i3u7 | Show your appreciation by clicking the upvote button\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n\n\n\n\n\n\n\n\n | DevOgabek | NORMAL | 2024-03-20T00:08:23.602604+00:00 | 2024-03-20T18:04:48.263130+00:00 | 19,216 | false | # Show your appreciation by clicking the upvote button\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n# UPVOTE\n\n\n\n[![Screen Shot 2024-03-20... | 98 | 4 | ['Linked List', 'Python', 'C++', 'Python3', 'JavaScript'] | 17 |
merge-in-between-linked-lists | [Java/Python 3] Straight forward codes w/ comments and analysis. | javapython-3-straight-forward-codes-w-co-67li | \n\njava\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode end = list1, start = null;\n for (int i = | rock | NORMAL | 2020-11-28T16:04:08.077420+00:00 | 2020-11-29T14:06:35.337947+00:00 | 9,322 | false | \n\n```java\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode end = list1, start = null;\n for (int i = 0; i < b; ++i, end = end.next) { // locate b upon termination of the loop.\n if (i == a - 1) { // locate the node right before a.\n ... | 71 | 4 | [] | 13 |
merge-in-between-linked-lists | [C++] easy approch | c-easy-approch-by-sanjeev1709912-2g0q | null | sanjeev1709912 | NORMAL | 2020-11-28T16:05:29.476898+00:00 | 2020-11-28T16:24:22.165231+00:00 | 7,406 | false | <iframe src="https://leetcode.com/playground/aE2EFkMv/shared" frameBorder="0" width="1000" height="400"></iframe> | 62 | 3 | [] | 8 |
merge-in-between-linked-lists | Java easy solution - beats 100% Time O(n) Space - O(1) | java-easy-solution-beats-100-time-on-spa-p3pp | Approach\n Assign left pointer as list1 and traverse till you find a value\n Have middle pointer and traverse till you find b value\n Map the left to list2 and | vinsinin | NORMAL | 2020-12-30T02:13:23.647859+00:00 | 2020-12-30T02:13:23.647919+00:00 | 3,164 | false | **Approach**\n* Assign `left` pointer as `list1` and traverse till you find `a` value\n* Have `middle` pointer and traverse till you find `b` value\n* Map the `left` to `list2` and traverse till the end\n* At last assign the next element of the `list2` as the next element of the `middle` pointer\n```\nclass Solution {\... | 38 | 1 | ['Java'] | 4 |
merge-in-between-linked-lists | [Java] Straightforward solution in O(N) time | java-straightforward-solution-in-on-time-54zo | \nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode start = list1;\n for (int i = 1; | roka | NORMAL | 2020-11-28T16:02:36.038062+00:00 | 2020-11-28T16:02:36.038097+00:00 | 3,162 | false | ```\nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode start = list1;\n for (int i = 1; i < a; i++) {\n start = start.next;\n }\n \n ListNode end = start;\n for (int i = a; i <= b; i++) {\n end ... | 38 | 1 | [] | 3 |
merge-in-between-linked-lists | Basic C++ approach (Clean and Simple with explanation) | basic-c-approach-clean-and-simple-with-e-q3u5 | The basic approach is as follows :-\n\n1. Traverse the linked list to the given elements a and b\n1. Set the next of a to the head of the other given linked lis | Righley | NORMAL | 2020-11-28T22:22:02.047444+00:00 | 2020-12-06T07:18:33.519846+00:00 | 1,981 | false | The basic approach is as follows :-\n\n1. Traverse the linked list to the given elements a and b\n1. Set the next of a to the head of the other given linked list\n1. Set the next of the tail of the other given linked list to the pointer to b\n1. Return the original linked list as the final answer\n\n```\nclass Solution... | 18 | 0 | ['C'] | 2 |
merge-in-between-linked-lists | Linked List without memory leaks||154ms Beats 98.13% | linked-list-without-memory-leaks154ms-be-nndz | Intuition\n Describe your first thoughts on how to solve this problem. \nIt is no problem to obtain a solution.\nBut work for a while to remove the possiblity c | anwendeng | NORMAL | 2024-03-20T01:17:09.722269+00:00 | 2024-03-20T09:59:28.584286+00:00 | 2,386 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIt is no problem to obtain a solution.\nBut work for a while to remove the possiblity causing memory leaks.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Transverse the list1 for i=1 to a-1 do `curr=curr->next;`... | 17 | 0 | ['Linked List', 'C++'] | 2 |
merge-in-between-linked-lists | [Python 3] - 2 pointers approach code with comments - O(m+n) | python-3-2-pointers-approach-code-with-c-y30x | This is my approach to the problem using 2 pointers :\n\nclass Solution:\n def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> List | sarthak6246 | NORMAL | 2021-01-11T06:05:57.786035+00:00 | 2021-01-11T06:06:34.190646+00:00 | 1,832 | false | This is my approach to the problem using 2 pointers :\n```\nclass Solution:\n def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:\n # Define 2 pointers\n\t\tptr1 = list1\n ptr2 = list1\n i, j = 0, 0\n\t\t\n\t\t# Loop for pointer 1 to reach previous node from a... | 17 | 0 | ['Linked List', 'Python3'] | 7 |
merge-in-between-linked-lists | C++ Straightforward O(N) | c-straightforward-on-by-lzl124631x-uyug | See my latest update in repo LeetCode\n\n## Solution 1.\n\nFind the following pointers:\n p where p->next points to ath node.\n q where p points to bth node.\n\ | lzl124631x | NORMAL | 2020-11-28T16:02:27.753244+00:00 | 2020-11-28T16:29:10.088696+00:00 | 1,723 | false | See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n\n## Solution 1.\n\nFind the following pointers:\n* `p` where `p->next` points to `a`th node.\n* `q` where `p` points to `b`th node.\n\nThen we can stitch them together by assigning:\n* `B` to `p->next`\n* `q->next` to the `next` pointer o... | 16 | 2 | [] | 2 |
merge-in-between-linked-lists | Modifying the Links | Java | C++ | modifying-the-links-java-c-by-fly_ing__r-i9dl | Intuition, approach, and complexity dicussed in video solution in detail.\nhttps://youtu.be/sxUXGlvTWt8\n\n# Code\nC++\n\nclass Solution {\npublic:\n ListNod | Fly_ing__Rhi_no | NORMAL | 2024-03-20T02:33:33.106853+00:00 | 2024-03-20T02:33:33.106881+00:00 | 8,657 | false | # Intuition, approach, and complexity dicussed in video solution in detail.\nhttps://youtu.be/sxUXGlvTWt8\n\n# Code\nC++\n```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode *currNode = list1;\n int index = 0;\n while(index < a-1... | 15 | 0 | ['Linked List', 'C++', 'Java'] | 4 |
merge-in-between-linked-lists | Python | 99.50 beats | T-O(n) | python-9950-beats-t-on-by-vsahoo-m86n | \n\nclass Solution:\n def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:\n head = list1\n for _ in range(a | vsahoo | NORMAL | 2021-03-07T15:30:08.665072+00:00 | 2021-03-07T15:30:08.665113+00:00 | 1,122 | false | ```\n\nclass Solution:\n def mergeInBetween(self, list1: ListNode, a: int, b: int, list2: ListNode) -> ListNode:\n head = list1\n for _ in range(a-1):\n head = head.next\n cur = head.next\n for _ in range(b-a):\n cur = cur.next\n head.next = list2\n whi... | 15 | 1 | ['Python'] | 5 |
merge-in-between-linked-lists | Basic Approach | | Easy Explanation | | Time O(n) , Space O(1) | | C++ | | Java | | Python3 | | ✅✅🔥 | basic-approach-easy-explanation-time-on-tw6r7 | \n\nIntuition:\n\nTo solve this problem, we need to traverse list1 to find the nodes at positions a and b. Once we locate these nodes, we can splice list2 betwe | Hunter_0718 | NORMAL | 2024-03-20T00:24:43.082595+00:00 | 2024-03-20T00:40:22.778962+00:00 | 4,935 | false | \n\n**Intuition:**\n\nTo solve this problem, we need to traverse `list1` to find the nodes at positions `a` and `b`. Once we locate these nodes, we can splice `list2` between them. We\'ll connect the node be... | 14 | 2 | ['Linked List', 'C++', 'Java', 'Python3', 'Kotlin', 'JavaScript'] | 6 |
merge-in-between-linked-lists | Python | Easy | python-easy-by-khosiyat-1xw1 | see the Successfully Accepted Submission\n\n# Code\n\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# | Khosiyat | NORMAL | 2024-03-20T03:07:20.192836+00:00 | 2024-03-20T03:07:20.192862+00:00 | 555 | false | [see the Successfully Accepted Submission](https://leetcode.com/problems/merge-in-between-linked-lists/submissions/1208722799/?envType=daily-question&envId=2024-03-20)\n\n# Code\n```\n# Definition for singly-linked list.\n# class ListNode:\n# def __init__(self, val=0, next=None):\n# self.val = val\n# ... | 11 | 0 | ['Python3'] | 0 |
merge-in-between-linked-lists | Merge Linked Lists In Between Indices | merge-linked-lists-in-between-indices-by-94do | Intuition\nWe need to merge list2 into list1 by removing a portion of list1 specified by indices a and b.\n\n# Approach\nTraverse list1 until reaching the node | Stella_Winx | NORMAL | 2024-02-29T12:03:13.908272+00:00 | 2024-02-29T12:03:13.908301+00:00 | 204 | false | # Intuition\nWe need to merge list2 into list1 by removing a portion of list1 specified by indices a and b.\n\n# Approach\n*Traverse list1 until reaching the node just before index a and store this node in prev.\n\n*Keep track of the node at index a in track.\n\n*Traverse list1 until reaching the node at index b.\n\n*P... | 11 | 0 | ['C++'] | 0 |
merge-in-between-linked-lists | Rust | Linear time and no extra space (O(n + m) time and O(1) space) | rust-linear-time-and-no-extra-space-on-m-6v13 | \nuse std::mem;\n\nimpl Solution {\n pub fn merge_in_between(\n list1: Option<Box<ListNode>>, \n a: i32, \n b: i32,\n mut list2: | garciparedes | NORMAL | 2020-12-27T16:43:00.360350+00:00 | 2020-12-27T19:06:02.915082+00:00 | 185 | false | ```\nuse std::mem;\n\nimpl Solution {\n pub fn merge_in_between(\n list1: Option<Box<ListNode>>, \n a: i32, \n b: i32,\n mut list2: Option<Box<ListNode>>,\n ) -> Option<Box<ListNode>> {\n let mut head = list1.unwrap();\n \n let mut current = head.as_mut();\n ... | 11 | 0 | ['Linked List', 'Rust'] | 1 |
merge-in-between-linked-lists | 🗓️ Daily LeetCoding Challenge Day 3|| 🔥 JAVA SOL | daily-leetcoding-challenge-day-3-java-so-4oyp | I hope a good day for u!\n\n# Code\n\nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode cur | DoaaOsamaK | NORMAL | 2024-03-20T09:14:43.531847+00:00 | 2024-03-20T09:14:43.531878+00:00 | 1,040 | false | I hope a good day for u!\n\n# Code\n```\nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode currNode = list1; // Start of the first list\n int index = 0; // Variable to track current position\n // Move to the element before index "a"\n ... | 9 | 0 | ['Java'] | 1 |
merge-in-between-linked-lists | C++ Solution (Don't forget to free memory for removed nodes) | c-solution-dont-forget-to-free-memory-fo-iynr | \nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n int splitPosition = 0;\n ListNode* c | navan72 | NORMAL | 2020-12-13T17:53:10.075864+00:00 | 2020-12-13T17:54:48.541569+00:00 | 752 | false | ```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n int splitPosition = 0;\n ListNode* current = list1;\n while(splitPosition != a - 1)\n {\n current = current->next;\n splitPosition++;\n }\n \n ... | 9 | 0 | ['C'] | 0 |
merge-in-between-linked-lists | 🔥🔥Beats 100% | Easiest Approach 🚀🚀 | Must Watch 😎 | beats-100-easiest-approach-must-watch-by-ayit | \uD83E\uDD14 Intuition:\n- Traverse through list1 to find the nodes at positions a and b and their previous nodes.\n- Identify the end node of list2.\n- Link th | The_Eternal_Soul | NORMAL | 2024-03-20T02:21:11.069240+00:00 | 2024-03-20T02:21:11.069279+00:00 | 1,073 | false | \uD83E\uDD14 **Intuition:**\n- Traverse through `list1` to find the nodes at positions `a` and `b` and their previous nodes.\n- Identify the end node of `list2`.\n- Link the previous node of `a` to the head of `list2`.\n- Link the end node of `list2` to the node following `b`.\n\n\uD83D\uDEE0\uFE0F **Approach:**\n1. In... | 8 | 1 | ['Linked List', 'C', 'Python', 'C++', 'Java', 'JavaScript'] | 1 |
merge-in-between-linked-lists | C++ || Straight forward code || Simplest Approach | c-straight-forward-code-simplest-approac-sh4a | \nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode *ptr=list1;\n ListNode *pt | garvit14 | NORMAL | 2022-08-20T18:18:04.012481+00:00 | 2022-08-20T18:18:04.012525+00:00 | 912 | false | ```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode *ptr=list1;\n ListNode *ptr2=list1;\n while(a>1)\n {\n a--;\n ptr=ptr->next;\n }\n while(b)\n {\n ptr2=ptr2->next;\... | 8 | 0 | ['Linked List', 'C', 'C++'] | 2 |
merge-in-between-linked-lists | [Java] Two pointer approach | java-two-pointer-approach-by-lucifer1019-85i3 | ```\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n if(list1 == null || list2 == null){\n return null;\n | lucifer101998 | NORMAL | 2020-11-28T17:41:47.789855+00:00 | 2020-11-28T17:42:26.335890+00:00 | 989 | false | ```\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n if(list1 == null || list2 == null){\n return null;\n }\n ListNode slow,fast;\n slow=list1;\n fast=list1;\n int k=b-a+1;\n for(int i=0;i<k;i++)\n fast=fast.next;\n... | 8 | 0 | ['Two Pointers', 'Java'] | 4 |
merge-in-between-linked-lists | Beats 100%🚀➡️Intuitive Solution Full Explained ➡️[Java/C++/C/C#/JavaScript/Python3/Rust] | beats-100intuitive-solution-full-explain-7j17 | Intuition\n1. We have to get the node before a and node after b.\n2. We will attach the node before a to the start of list2, and add the the end of the list2 to | Shivansu_7 | NORMAL | 2024-03-20T09:57:02.929363+00:00 | 2024-03-20T14:00:21.282395+00:00 | 441 | false | # Intuition\n1. We have to get the node before a and node after b.\n2. We will attach the node before a to the start of list2, and add the the end of the list2 to the node after b.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. **Check for `null` lists:** \n - The method begin... | 7 | 0 | ['C', 'Python', 'C++', 'Java', 'Python3', 'Rust', 'JavaScript', 'C#'] | 4 |
merge-in-between-linked-lists | ✔️100% Beats ✔️Python ✔️C++ ✔️Java ✔️Js ✔️C# ✔️Go | 100-beats-python-c-java-js-c-go-by-otabe-k3av | \n\n\n# Approach\nThis solution creates a dummy node to handle cases where the removal starts from the head of list1. Then, it traverses to the (a-1)th node to | otabek_kholmirzaev | NORMAL | 2024-03-20T01:05:09.231261+00:00 | 2024-03-21T17:07:01.719873+00:00 | 775 | false | \n\n\n# Approach\nThis solution creates a dummy node to handle cases where the removal starts from the head of **list1**. Then, it traverses to the **(a-1)th** node to find the node before the range to... | 7 | 0 | ['C#'] | 3 |
merge-in-between-linked-lists | 🍀🍀 optimized || Neat Solution|| O(1) memory and O(n+m) space complexity | optimized-neat-solution-o1-memory-and-on-p002 | 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 | A9201 | NORMAL | 2024-03-20T00:41:01.666224+00:00 | 2024-03-20T00:41:01.666261+00:00 | 1,156 | 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)$$ --... | 7 | 0 | ['C++', 'Python3'] | 3 |
merge-in-between-linked-lists | [C++] Linked-list to Vector || Easy-Understanding | c-linked-list-to-vector-easy-understandi-8ypm | \nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n vector<int> nums1, nums2, res;\n Lis | vaibhav4859 | NORMAL | 2021-12-17T18:51:29.989314+00:00 | 2021-12-17T18:51:29.989357+00:00 | 587 | false | ```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n vector<int> nums1, nums2, res;\n ListNode* temp1 = list1, *temp2 = list2;\n while(temp1 != NULL)\n nums1.push_back(temp1->val), temp1 = temp1->next;\n \n while(t... | 7 | 2 | ['Linked List', 'C', 'C++'] | 1 |
merge-in-between-linked-lists | 🔥🔥|| Beats 100% , Easy Solution || Traverse || 🔥🔥 | beats-100-easy-solution-traverse-by-hars-a76l | \n\n# Approach\nTraverse till (a-1)th node and till (b+1)th node ,\n(a-1).next= head of list2 \ntail of list2.next =(b+1)th node\n\n\nin the code head1 is nothi | harshchand78 | NORMAL | 2024-03-20T05:38:52.094923+00:00 | 2024-03-20T16:18:27.277181+00:00 | 194 | false | \n\n# Approach\nTraverse till (a-1)th node and till (b+1)th node ,\n(a-1).next= head of list2 \ntail of list2.next =(b+1)th node\n\n\nin the code head1 is nothing but (b+1)th node and (a-1)th node is stored in list1 , rearrange variable names according to your convenience\n\n# Complexity\n- Time complexity: O(b + list2... | 6 | 0 | ['Two Pointers', 'Java'] | 3 |
merge-in-between-linked-lists | c++ || beats 96% | c-beats-96-by-niyander-smx8 | 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 | niyander | NORMAL | 2024-03-24T19:53:34.471588+00:00 | 2024-03-24T19:53:34.471618+00:00 | 803 | 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)$$ --... | 5 | 0 | ['C++'] | 0 |
merge-in-between-linked-lists | ✅ BEST C++ SOLUTION ☑️ | best-c-solution-by-2005115-uykb | PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT\n# CONNECT WITH ME\n### https://www.linkedin.com/in/pratay-nandy-9ba57b229/\n#### https://www.instagram.com/pratay_nand | 2005115 | NORMAL | 2024-03-20T17:36:32.054233+00:00 | 2024-03-20T17:36:32.054265+00:00 | 88 | false | # **PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT**\n# **CONNECT WITH ME**\n### **[https://www.linkedin.com/in/pratay-nandy-9ba57b229/]()**\n#### **[https://www.instagram.com/_pratay_nandy_/]()**\n\n# Approach\n\n\n### Let\'s break down the functionality of this function:\n\n1. **Initialization**:\n - It initializes three... | 5 | 0 | ['Linked List', 'C++'] | 0 |
merge-in-between-linked-lists | ✅Easy✨ ||C++|| Beats 100% || With Explanation|| | easy-c-beats-100-with-explanation-by-ola-gae1 | Intuition\n Describe your first thoughts on how to solve this problem. \nThe intuition of code is to merge two singly linked lists by replacing a segment of the | olakade33 | NORMAL | 2024-03-20T05:19:01.489487+00:00 | 2024-03-20T05:19:01.489522+00:00 | 467 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe intuition of code is to merge two singly linked lists by replacing a segment of the first list (from position a to b) with the entire second list. The approach involves three main steps: finding the node just before the start of the s... | 5 | 0 | ['C++'] | 1 |
merge-in-between-linked-lists | C++ easy solution || C++ | c-easy-solution-c-by-prashant_71200-hhre | Intuition\nTo solve this problem, we need to find the ath and (b+1)th nodes in the list1 and then adjust the pointers to insert list2 between them.\n# Approach\ | prashant_71200 | NORMAL | 2024-03-20T03:40:49.778904+00:00 | 2024-03-20T03:40:49.778932+00:00 | 432 | false | # Intuition\nTo solve this problem, we need to find the ath and (b+1)th nodes in the list1 and then adjust the pointers to insert list2 between them.\n# Approach\n1) Create a dummy node to simplify handling edge cases.\n2) Traverse list1 to find the ath node and the (b+1)th node.\n3) Traverse list2 to find its tail.\n4... | 5 | 0 | ['C++'] | 1 |
merge-in-between-linked-lists | Beats 100% of users with C++ || Step by Step Explain || Fast Solution || | beats-100-of-users-with-c-step-by-step-e-0oeo | Abhiraj Pratap Singh\n\n---\n\n# UPVOTE IT....\n\n\n\n---\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \n- The mergeInBetween fun | abhirajpratapsingh | NORMAL | 2024-01-12T16:56:33.258662+00:00 | 2024-01-12T16:56:33.258692+00:00 | 87 | false | # Abhiraj Pratap Singh\n\n---\n\n# UPVOTE IT....\n\n\n\n---\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- The mergeInBetween function appears to merge two singly-linked lists list1 and list2 by removing a portion of nodes from list1 between the indices a and b (inclusive) and in... | 5 | 0 | ['Linked List', 'C++'] | 1 |
merge-in-between-linked-lists | Java || 1000% beats ❤️❤️ || 0(N) || 3 Solution || Easy || ❤️❤️ | java-1000-beats-0n-3-solution-easy-by-sa-3mfy | Intuition\n Describe your first thoughts on how to solve this problem. \nPLEASE UPVOTE ME \u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\n\n# Approach\n Descr | saurabh_kumar1 | NORMAL | 2023-09-05T08:53:48.387926+00:00 | 2023-09-05T08:53:48.387947+00:00 | 685 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nPLEASE UPVOTE ME \u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\u2764\uFE0F\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:0(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- S... | 5 | 0 | ['Java'] | 0 |
merge-in-between-linked-lists | JAVA solution: Easy Explanation | java-solution-easy-explanation-by-mandip-irdb | Intuition\n Describe your first thoughts on how to solve this problem. \nThe naive approach of the solution is that, we declare a new linked list and copy the l | Mandip_Sah | NORMAL | 2023-03-24T18:01:30.480196+00:00 | 2023-03-24T18:01:30.480240+00:00 | 193 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe naive approach of the solution is that, we declare a new linked list and copy the `list1` in new list upto `a` and the further traverse `list2` and copy them in the new linked list and again traverse `list1` upto `b` and start copying... | 5 | 0 | ['Java'] | 0 |
merge-in-between-linked-lists | Python (Simple Maths) | python-simple-maths-by-rnotappl-h48m | \n def mergeInBetween(self, list1, a, b, list2):\n cur1, cur2, res1, res2 = list1, list2, [], []\n \n while cur1:\n res1.appe | rnotappl | NORMAL | 2022-07-24T17:08:00.583287+00:00 | 2022-07-24T17:33:58.837881+00:00 | 77 | false | \n def mergeInBetween(self, list1, a, b, list2):\n cur1, cur2, res1, res2 = list1, list2, [], []\n \n while cur1:\n res1.append(cur1.val)\n cur1 = cur1.next\n \n while cur2:\n res2.append(cur2.val)\n cur2 = cur2.next\n ... | 5 | 0 | [] | 0 |
merge-in-between-linked-lists | Java simple and easy to understand soln, 1 ms, faster than 100.00% , clean code with comment | java-simple-and-easy-to-understand-soln-4sx40 | PLEASE UPVOTE IF YOU LIKE THIS SOLUTION\n\n\n\nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n Lis | satyaDcoder | NORMAL | 2021-03-14T11:02:49.772538+00:00 | 2021-03-14T11:02:49.772566+00:00 | 287 | false | **PLEASE UPVOTE IF YOU LIKE THIS SOLUTION**\n\n\n```\nclass Solution {\n public ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n ListNode curr1 = list1;\n \n //find the ath prev node and bth next node of list 1\n ListNode athPrevNode = null;\n ListNode bthN... | 5 | 2 | ['Java'] | 0 |
merge-in-between-linked-lists | C++ | 100% Faster and 100% Efficient | Most Efficient | Linear Approach | | c-100-faster-and-100-efficient-most-effi-c8fp | Code -\n\n\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode *slow = list1, *fast = l | dhruv_73 | NORMAL | 2021-01-14T07:21:48.168881+00:00 | 2021-01-14T07:21:48.168918+00:00 | 612 | false | **Code** -\n\n```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode *slow = list1, *fast = list1, *temp = list2;\n while(--a){\n slow = slow -> next;\n }\n b += 2;\n while(--b){\n fast = fast -> ... | 5 | 2 | ['Linked List', 'C'] | 3 |
merge-in-between-linked-lists | [easy understanding][c++][explained] | easy-understandingcexplained-by-rajat_gu-c46f | \n//list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int | rajat_gupta_ | NORMAL | 2020-11-28T18:16:39.640210+00:00 | 2020-11-28T18:24:56.282960+00:00 | 398 | false | ```\n//list1 = [0,1,2,3,4,5], a = 3, b = 4, list2 = [1000000,1000001,1000002]\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode* prev,*tail,*head=list1;\n int x=a-1;\n while(x--) head=head->next; \n\t\t//prev and head is at index=3... | 5 | 1 | ['C', 'C++'] | 0 |
merge-in-between-linked-lists | Best/Easiest Java Code 🔥 | besteasiest-java-code-by-thepriyanshpal-ibmt | Intuition\nWe need to replace nodes from the ath node to the bth node of list1 with the entire list2. To do this, we find the node before ath and the node after | thepriyanshpal | NORMAL | 2024-03-20T08:40:36.873599+00:00 | 2024-03-20T08:40:36.873628+00:00 | 555 | false | # Intuition\nWe need to replace nodes from the ath node to the bth node of list1 with the entire list2. To do this, we find the node before ath and the node after bth in list1. Then, we connect the node before ath to the head of list2 and the tail of list2 to the node after bth.\n\n# Approach\n1. Traverse list1 until t... | 4 | 0 | ['Java'] | 0 |
merge-in-between-linked-lists | Super simple solution with step by step dry run ✅✅✅ | super-simple-solution-with-step-by-step-psf4c | https://youtu.be/CUHQHKTu51I\n\n# Code\n\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n Lis | priyankachowdhury2002 | NORMAL | 2024-03-20T03:48:42.170255+00:00 | 2024-03-20T03:53:58.124334+00:00 | 248 | false | https://youtu.be/CUHQHKTu51I\n\n# Code\n```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n ListNode* ath = list1; //pointer to find the ath position \n ListNode* bth = list1; //pointer to find the bth position\n while(a>1){ // i want the... | 4 | 0 | ['C++'] | 2 |
merge-in-between-linked-lists | Merge In Between Linked Lists - Java Solution (Beats 100%) | merge-in-between-linked-lists-java-solut-uvrt | Intuition\n Describe your first thoughts on how to solve this problem. \nMy intuition involves identifying the nodes aPrev and bNext in list1, representing the | Naveen-NaS | NORMAL | 2024-01-12T14:26:10.644940+00:00 | 2024-01-12T14:26:10.644969+00:00 | 140 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMy intuition involves identifying the nodes aPrev and bNext in list1, representing the positions before and after the removal range, and finding the last node of list2. By connecting aPrev to the head of list2 and the last node of list2 t... | 4 | 0 | ['Java'] | 2 |
merge-in-between-linked-lists | C++ solution | c-solution-by-raghavkhandelwal2710-hy14 | ```\nclass Solution {\npublic:\n ListNode mergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n \n ListNode start;\n ListNode | raghavkhandelwal2710 | NORMAL | 2021-06-07T12:43:10.229928+00:00 | 2021-06-07T12:43:10.229992+00:00 | 197 | false | ```\nclass Solution {\npublic:\n ListNode* mergeInBetween(ListNode* list1, int a, int b, ListNode* list2) {\n \n ListNode* start;\n ListNode* last;\n ListNode* curr = list1;\n \n int count = 1;\n \n while(curr){\n \n if(count == a) start =... | 4 | 0 | [] | 1 |
merge-in-between-linked-lists | JavaScript Solution | javascript-solution-by-deadication-8ukj | \nvar mergeInBetween = function(list1, a, b, list2) {\n let start = list1;\n let end = list1;\n \n for (let i = 0; i <= b && start != null && end != | Deadication | NORMAL | 2021-03-05T14:54:28.907903+00:00 | 2021-03-05T14:54:28.907947+00:00 | 559 | false | ```\nvar mergeInBetween = function(list1, a, b, list2) {\n let start = list1;\n let end = list1;\n \n for (let i = 0; i <= b && start != null && end != null; i++) {\n if (i < a - 1) start = start.next;\n if (i <= b) end = end.next;\n }\n \n let tail = list2;\n \n while (tail.nex... | 4 | 1 | ['JavaScript'] | 1 |
merge-in-between-linked-lists | C# | c-by-mhorskaya-bs0j | \npublic ListNode MergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n\tListNode p1 = list1, p2 = list1;\n\twhile (--a > 0) p1 = p1.next;\n\twhile ( | mhorskaya | NORMAL | 2020-12-02T18:58:32.757303+00:00 | 2020-12-02T18:58:32.757350+00:00 | 166 | false | ```\npublic ListNode MergeInBetween(ListNode list1, int a, int b, ListNode list2) {\n\tListNode p1 = list1, p2 = list1;\n\twhile (--a > 0) p1 = p1.next;\n\twhile (b-- > 0) p2 = p2.next;\n\tp1.next = list2;\n\twhile (p1.next != null) p1 = p1.next;\n\tp1.next = p2.next;\n\treturn list1;\n}\n``` | 4 | 0 | [] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.