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
maximum-product-of-two-elements-in-an-array
find max y=max erase this from vec z=max from the new vec baad mein y*z return :D
find-max-ymax-erase-this-from-vec-zmax-f-c0gn
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
yesyesem
NORMAL
2024-08-23T06:34:26.379278+00:00
2024-08-23T06:34:26.379317+00:00
6
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['C++']
0
maximum-product-of-two-elements-in-an-array
Simple easy approach loop solution✅✅
simple-easy-approach-loop-solution-by-kr-o6b9
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
krishnabhagat906
NORMAL
2024-04-28T04:37:28.139919+00:00
2024-04-28T04:37:28.139935+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
2
0
['Array', 'Java']
0
maximum-product-of-two-elements-in-an-array
Beats 100% || simple solution || 0ms Time complexity ||
beats-100-simple-solution-0ms-time-compl-tjiv
\n\n# Code\n\nclass Solution {\n public int maxProduct(int[] nums) {\n int max=0;\n int secondmax=0;\n for(int i=0;i<nums.length;i++)\n
Vaibhav_Shelke1
NORMAL
2024-02-15T16:53:58.977327+00:00
2024-02-15T16:53:58.977360+00:00
14
false
\n\n# Code\n```\nclass Solution {\n public int maxProduct(int[] nums) {\n int max=0;\n int secondmax=0;\n for(int i=0;i<nums.length;i++)\n {\n if(nums[i]>=max){\n secondmax=max;\n max=nums[i];\n }\n else if(nums[i]>secondmax){...
2
0
['Java']
0
movement-of-robots
A classic problem, Ants on a Plank + Prefix sum O(n log n)
a-classic-problem-ants-on-a-plank-prefix-3568
This is a variation of a very classic problem: There are some ants on a plank at some positions. They are moving right or left, and change directions when they
t747
NORMAL
2023-06-10T16:00:37.156886+00:00
2023-06-10T16:03:04.810649+00:00
9,003
false
This is a variation of a very classic [problem](https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank/#:~:text=When%20an%20ant%20reaches%20one,fall%20out%20of%20the%20plank.): There are some ants on a plank at some positions. They are moving right or left, and change directions when they bump in...
112
0
[]
20
movement-of-robots
Easy Beginner Friendly with Explanations Pass Through + Prefix Sum | C++ Python
easy-beginner-friendly-with-explanations-st3x
Intuition\n Describe your first thoughts on how to solve this problem. \nIf two objects collide then it appears that they have pass through\n> In short if the i
Chanpreet3000
NORMAL
2023-06-10T16:01:15.642242+00:00
2023-06-10T16:34:58.004211+00:00
5,608
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nIf two objects collide then it appears that they have pass through\n> In short if the ith robot is moving left then after time d it\'s position would be nums[i] - d and if it is moving right then it\'s position would be nums[i] + d\n\n**E...
65
1
['Array', 'String', 'Greedy', 'C++', 'Python3']
12
movement-of-robots
✅ Explained - Simple and Clear Python3 Code✅
explained-simple-and-clear-python3-code-0l03m
Intuition\nThe problem requires calculating the sum of distances between all pairs of robots after a given command is executed. To solve this, we can simulate t
moazmar
NORMAL
2023-06-10T16:16:07.064367+00:00
2023-06-11T17:50:20.206489+00:00
1,213
false
# Intuition\nThe problem requires calculating the sum of distances between all pairs of robots after a given command is executed. To solve this, we can simulate the movement of the robots and keep track of their positions. Whenever two robots collide, they will change their directions and continue moving. We need to ca...
12
0
['Python3']
3
movement-of-robots
Python | Easy | Explanation
python-easy-explanation-by-mohd_mustufa-f01h
When 2 robots collide, they just pass through each other. We dont have to worry about changing the direction of each robot when they collide. So we can say that
mohd_mustufa
NORMAL
2023-06-10T16:02:57.217603+00:00
2023-06-30T19:34:03.439837+00:00
1,020
false
When 2 robots collide, they just pass through each other. We dont have to worry about changing the direction of each robot when they collide. So we can say that if a robot is moving right, then after d seconds it would have moved: its current position + d. If the robot is moving left, then after d seconds it would have...
12
0
['Python3']
4
movement-of-robots
[Java/C++/Python] Ants Trick
javacpython-ants-trick-by-lee215-mn9z
Explanation\nRobots has no different,\nso we can assume rebots can go cross each other.\nUsualy it\'s a trick for ants, here is robot.\n\nThen sort A.\nFor A[i]
lee215
NORMAL
2023-06-12T14:17:04.905352+00:00
2023-06-12T14:17:04.905401+00:00
911
false
# **Explanation**\nRobots has no different,\nso we can assume rebots can go cross each other.\nUsualy it\'s a trick for ants, here is robot.\n\nThen sort `A`.\nFor `A[i]`,\nit contributes as `A[j] - A[i]` for `i + 1` times, where `j < i`\nit contributes as `A[i] - A[j]` for `n - i` times, where `i < j`.\nSo we count th...
9
0
['C', 'Python', 'Java']
2
movement-of-robots
Python 3 || 2 lines, w/ notes and example || T/S: 99% / 97%
python-3-2-lines-w-notes-and-example-ts-ah2po
Notes:\n- The problem could be rewritten as: "Each robot travelsdunits left or right based on whether its corresponding element insis LorR, respectively. Find t
Spaulding_
NORMAL
2023-06-12T17:13:53.211312+00:00
2024-06-19T01:26:29.395358+00:00
520
false
Notes:\n- The problem could be rewritten as: "Each robot travels`d`units left or right based on whether its corresponding element in`s`is `L`or`R`, respectively. Find the sum of the distances based on these final positions."\n\n- The function`(ord(ch)-79)//3 * d`maps`\'L\'`-->`-d` and`\'R\'`-->`d`\n\n- It is left to th...
8
1
['Python3']
1
movement-of-robots
Java, sorting + linear scan
java-sorting-linear-scan-by-vladislav-si-pgoy
Intuition\nThe first observation is we can ignore meetings of the robots because the meeting robots will continue their journey and we don\'t care about the rob
Vladislav-Sidorovich
NORMAL
2023-06-10T16:12:13.922646+00:00
2023-06-14T19:04:04.972863+00:00
1,653
false
# Intuition\nThe first observation is we can ignore meetings of the robots because the meeting robots will continue their journey and we don\'t care about the robot ids.\n\nThe second trick is to avoid `O(n^2)` complexity for sum distance of all pairs.\n\nEplanation of the line `long curr = i * (long)nums[i] - (n - 1 -...
7
0
['Sorting', 'Java']
5
movement-of-robots
prefixsum intution explained💯💡 || O(NlogN)
prefixsum-intution-explained-onlogn-by-s-wfsz
\n\n# Code\n\nclass Solution {\npublic:\n int mod=1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<long long int> ans;\n
steeewtOverflow
NORMAL
2023-06-10T19:46:30.950401+00:00
2023-06-10T19:46:30.950437+00:00
648
false
\n\n# Code\n```\nclass Solution {\npublic:\n int mod=1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<long long int> ans;\n int n=nums.size();\n for(int i=0; i<n; i++){\n ans.push_back(nums[i]);\n }\n //we can ignore the collsions as the order o...
5
0
['C++']
1
movement-of-robots
Robots 🤖 Keep Walking 🚶
robots-keep-walking-by-harshitmaurya-v7nh
intuition :\n\nWhen two Robots meet at some point,\nthey change their directions and continue moving again.\nBut you can assume they don\'t change direction and
HarshitMaurya
NORMAL
2023-06-10T16:02:31.448343+00:00
2023-06-13T12:27:13.648748+00:00
898
false
**intuition** :\n\nWhen two Robots meet at some point,\nthey change their directions and continue moving again.\nBut you can assume they don\'t change direction and keep moving(since they take 0 unit time).\n\nlet them walk then the question become find the sum of difference between all pair (i , j) of an Array :\n\n\n...
5
1
['Sorting', 'Java']
1
movement-of-robots
C++ sort & sum||88ms Beats 95.92%
c-sort-sum88ms-beats-9592-by-anwendeng-jsf0
Intuition\n Describe your first thoughts on how to solve this problem. \nCompute firstly the arrayA[i]=(s[i]==\'R\')?nums[i]+d:nums[i]-d.\nThen sort the array A
anwendeng
NORMAL
2023-11-04T15:40:57.643645+00:00
2023-11-04T15:40:57.643666+00:00
510
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCompute firstly the array`A[i]=(s[i]==\'R\')?nums[i]+d:nums[i]-d`.\nThen sort the array `A` such that `A[i]<A[j]` for `i<j`.\nCompute the sum of distance \n$$\n\\sum_{i<j}A[j]-A[i]\\\\\n=\\sum_{i=0}^{n-1}(2i-n+1)A[i]\n$$\n# Approach\n<!--...
4
0
['Array', 'Sorting', 'C++']
0
movement-of-robots
SIMPLE || AVOID COLLISION || C++
simple-avoid-collision-c-by-ganeshkumawa-0xge
Code\n\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n int i = 0, n = nums.size();\n for(i = 0; i < n; i++
ganeshkumawat8740
NORMAL
2023-06-11T01:52:43.350197+00:00
2023-06-11T01:52:43.350226+00:00
1,503
false
# Code\n```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n int i = 0, n = nums.size();\n for(i = 0; i < n; i++){\n if(s[i]==\'R\'){\n nums[i] += d;\n }else{\n nums[i] -= d;\n }\n }\n sort(...
4
0
['Sorting', 'Prefix Sum', 'C++']
1
movement-of-robots
BEST C++ || O(nlogn)|| Proper Intution || Easy to understand
best-c-onlogn-proper-intution-easy-to-un-oxe6
Intution\nWhen collision happens- Directions wil be RL or LR and in that case direction will change as LR or RL respectively. So, there is no net effect in ans
alltimecoding
NORMAL
2023-06-10T18:56:46.921266+00:00
2023-06-10T18:56:46.921314+00:00
783
false
# Intution\nWhen collision happens- Directions wil be RL or LR and in that case direction will change as LR or RL respectively. So, there is no net effect in answer even calculating without changing the direction.\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Spa...
4
0
['C++']
2
movement-of-robots
Java | Sorting | with explanation
java-sorting-with-explanation-by-nishant-3cwm
The logic behind : i*arr[i] - (n-1-i)*arr[i] in calculating Sum of absolute differences of all pairs in a given array:\n\nLet\'s take an example: [1,2,3,4,5] (A
nishant7372
NORMAL
2023-06-10T17:29:25.580956+00:00
2023-06-12T08:24:36.287718+00:00
508
false
### The logic behind : `i*arr[i] - (n-1-i)*arr[i]` in calculating Sum of absolute differences of all pairs in a given array:\n\nLet\'s take an example: [1,2,3,4,5] (After Sorting) (n = no. of elements = 5)\n\nSum of absolute differences of all pairs in a given array:\n\n(2-1) + (3-1) + (4-1) + (5-1) +\n(3-2) + (4-2) + ...
4
0
['Sorting', 'Java']
2
movement-of-robots
[Java] Just ignore the collision
java-just-ignore-the-collision-by-0x4c0d-nmmi
Intuition\n Describe your first thoughts on how to solve this problem. \nWe can ignore the collision, since all robots are same, we can\'t distinct each other.
0x4c0de
NORMAL
2023-06-10T16:00:40.821864+00:00
2023-06-12T06:56:50.700361+00:00
930
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can ignore the collision, since all robots are same, we can\'t distinct each other. **The robots just keep walking with collision.**\n\nSimilar problem: https://leetcode.com/problems/last-moment-before-all-ants-fall-out-of-a-plank/\n\n...
4
0
['Math', 'Prefix Sum', 'Java']
2
movement-of-robots
python3 Solution
python3-solution-by-motaharozzaman1996-qupm
\n\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n n = len(nums)\n mod=10**9+7\n for i in range(n):\
Motaharozzaman1996
NORMAL
2023-06-10T17:29:35.675947+00:00
2023-06-10T17:29:35.675978+00:00
215
false
\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n n = len(nums)\n mod=10**9+7\n for i in range(n):\n if s[i] == \'L\':\n nums[i] -= d\n else: \n nums[i] += d\n \n nums.sort()\n\n pre ...
3
0
['Python', 'Python3']
0
movement-of-robots
Video Explanation (With Intuition)
video-explanation-with-intuition-by-codi-oeby
Explanation\n\nClick here for the video\n\n# Code\n\ntypedef long long int ll;\nconst int MOD = 1e9+7;\n\nclass Solution {\npublic:\n int sumDistance(vector<
codingmohan
NORMAL
2023-06-10T17:07:56.639372+00:00
2023-06-10T17:07:56.639418+00:00
211
false
# Explanation\n\n[Click here for the video](https://youtu.be/Xpr0hg1jBEI)\n\n# Code\n```\ntypedef long long int ll;\nconst int MOD = 1e9+7;\n\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n int n = nums.size();\n \n vector<ll> final_pos(n);\n for (int ...
3
0
['C++']
0
movement-of-robots
C++ || Simple || Easily Understandable || Faster
c-simple-easily-understandable-faster-by-hu4z
Intuition\n Describe your first thoughts on how to solve this problem. \n- As given that certain index value moves in certain direction.\n- Upon collision of tw
Dark_warrior
NORMAL
2023-06-13T01:04:48.175947+00:00
2023-06-13T01:04:48.175964+00:00
78
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- As given that certain index value moves in certain direction.\n- Upon collision of two values they change their direction and start moving in opposite direction.\n- By this we can understand that when two balls collide they change their...
2
0
['Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
C++||Most Easy Solution Using Simple Logic+Prefix Sum
cmost-easy-solution-using-simple-logicpr-n6zb
\ntypedef long long ll;\nll mod=1e9+7;\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n ll n=s.size();\n fo
Arko-816
NORMAL
2023-06-11T04:00:05.083778+00:00
2023-06-11T04:00:05.083812+00:00
709
false
```\ntypedef long long ll;\nll mod=1e9+7;\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n ll n=s.size();\n for(int i=0;i<n;i++)\n {\n if(s[i]==\'R\')\n nums[i]+=d;\n else\n nums[i]-=d;\n }\n ve...
2
0
[]
1
movement-of-robots
O(n log n) simple sort and count
on-log-n-simple-sort-and-count-by-dkravi-m2hr
Key observation is that you might as well assume the robots keep moving in the direction they started in, as you don\'t care if they rebound off each other beca
dkravitz78
NORMAL
2023-06-10T21:09:09.491300+00:00
2023-06-10T21:09:09.491351+00:00
134
false
Key observation is that you might as well assume the robots keep moving in the direction they started in, as you don\'t care if they rebound off each other because we don\'t care which is which. \n\nSo, simply find the place where each finishes, then sort that as that lets us count in order without worrying about absol...
2
0
['Python3']
0
movement-of-robots
C++ with thinking process
c-with-thinking-process-by-jk15162428-fo2w
Intuition\nThe first time I saw this question, I have no idea about that LOL. I check the input range, there is a $d \sim 1e9$, and $nums \sim 1e5$, and this is
jk15162428
NORMAL
2023-06-10T17:42:12.133839+00:00
2023-06-10T17:42:12.133887+00:00
485
false
## Intuition\nThe first time I saw this question, I have no idea about that LOL. I check the input range, there is a $d \\sim 1e9$, and $nums \\sim 1e5$, and this is not a simulation, search, dynamic programming, etc. I guess it must have some method to avoid simulating $d$ seconds and get the final state, the situatio...
2
0
['C++']
1
movement-of-robots
[Java] Clean Code w/ Explanation
java-clean-code-w-explanation-by-xiangca-uict
Note that the distance between the robots doesn\'t depend on the direction in which the robots are going to move after the command, because if two robots collid
xiangcan
NORMAL
2023-06-10T16:41:32.794490+00:00
2023-06-10T16:44:27.500914+00:00
408
false
Note that the distance between the robots doesn\'t depend on the direction in which the robots are going to move after the command, because if two robots collide and change directions, the total sum of distances remains the same.\n\nAlso Note that we don\'t have to actually calculate the movements of each robot. We can...
2
0
['Java']
1
movement-of-robots
[Python 3] Let the robots pass thru each other
python-3-let-the-robots-pass-thru-each-o-zuei
Intuition\nIgnore collisions and let the robots go through each other, the net effect is the same. Calculate their final positions, and use a rolling sum to get
huangshan01
NORMAL
2023-06-10T16:06:34.244637+00:00
2023-06-10T16:08:44.338572+00:00
198
false
# Intuition\nIgnore collisions and let the robots go through each other, the net effect is the same. Calculate their final positions, and use a rolling sum to get the answer.\n\n# Code\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n n = len(nums)\n for i in rang...
2
0
['Python3']
0
movement-of-robots
C++ O(N)
c-on-by-pkacb-i7a5
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\ncollision does not change the overall final positions of the robot;\nIn c
pkacb
NORMAL
2023-06-10T16:04:15.466191+00:00
2023-06-10T16:06:09.576732+00:00
84
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\ncollision does not change the overall final positions of the robot;\nIn case 1 final positions are\nrobot1 -> -3\nrobot2 -> -1\nrobot3 -> 1\nabs(-3 - (-1)) + abs(1 - (-1)) + abs(1 - (-3)) = 8\nso if we simply add or subtract...
2
0
['C++']
0
movement-of-robots
✅ One Line Solution
one-line-solution-by-mikposp-otws
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: O(n*log
MikPosp
NORMAL
2024-08-29T10:31:37.270902+00:00
2024-09-09T21:48:48.598142+00:00
20
false
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1.1 - One Line\nTime complexity: $$O(n*log(n))$$. Space complexity: $$O(n)$$.\n```python3\nclass Solution:\n def sumDistance(self, a: List[int], s: str, d: int) -> int:\n return sum(accumula...
1
1
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'Python', 'Python3']
0
movement-of-robots
Java Clean Solution || in liner Complexity
java-clean-solution-in-liner-complexity-5wbm4
Intuition\nIf we have the array [7, 5, 3, 1] and we want to calculate the sum of the distances, we do:\n\n(7-5) + (7-3) + (7-1) = 2 + 4 + 6 = 12\n(5-3) + (5-1)
Shree_Govind_Jee
NORMAL
2024-04-08T03:27:56.993979+00:00
2024-04-08T03:27:56.994026+00:00
241
false
# Intuition\nIf we have the array `[7, 5, 3, 1]` and we want to calculate the sum of the distances, we do:\n\n`(7-5) + (7-3) + (7-1) = 2 + 4 + 6 = 12`\n`(5-3) + (5-1) = 2 + 4 = 6`\n`(3-1) = 2`\n`12 + 6 + 2 = 20` (this is `n^2`, which isn\'t good enough)\nHowever, with some math manipulation (extract common factor), we ...
1
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'Java']
0
movement-of-robots
93.13 % beats in runtime only one liner !!!
9313-beats-in-runtime-only-one-liner-by-yv89i
\n# Code\n\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n nums = sorted([num + (ord(ch) - 79) // 3 * d for num, c
ayan_101
NORMAL
2023-12-18T15:50:52.759040+00:00
2023-12-18T15:50:52.759074+00:00
15
false
\n# Code\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n nums = sorted([num + (ord(ch) - 79) // 3 * d for num, ch in zip(nums, s)]);return sum(map(mul, nums, range(1 - len(nums), len(nums), 2))) % 1000000007\n```
1
0
['Breadth-First Search', 'Probability and Statistics', 'Minimum Spanning Tree', 'Biconnected Component', 'Strongly Connected Component', 'Python3']
0
movement-of-robots
Accepted C++ solution || No Runtime Error
accepted-c-solution-no-runtime-error-by-di37g
\n\n# Complexity\n- Time complexity: O(nlog(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. O
Aditya_IIT_DHN
NORMAL
2023-12-16T10:33:56.898103+00:00
2023-12-16T10:33:56.898131+00:00
15
false
\n\n# Complexity\n- Time complexity: $$O(nlog(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. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n int MOD = 1000000007;\n int sumDistance(vector<int>& nums, string s, int d)...
1
0
['C++']
0
movement-of-robots
[C#], Prefix sum, math
c-prefix-sum-math-by-yerkon-i9cf
Intuition\n Describe your first thoughts on how to solve this problem. \n1. We can just add/subtract the d for each robot and it will work. Because collision he
yerkon
NORMAL
2023-07-03T06:11:07.329326+00:00
2023-07-03T07:16:21.897864+00:00
28
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n1. We can just **add/subtract the `d`** for each robot and it will work. Because collision here works just like no collision happens.\n```\nExamples\n1.\n[-2,0,2], s = "RLL", d = 3\nd = 1, [-1, -1, 1] ->, <-, <-. robots at -1(->, <-) wil...
1
0
['Math', 'Prefix Sum', 'C#']
0
movement-of-robots
Easy Code with complete Explanation
easy-code-with-complete-explanation-by-s-k116
Intuition and Approach\nThe main thought to solve this Question is u don\'t need to worry about the collision and change of direction. \n# Explanation (why coll
ShivamChoudhary_1
NORMAL
2023-06-11T19:12:59.625637+00:00
2023-06-11T19:12:59.625670+00:00
209
false
# Intuition and Approach\nThe main thought to solve this Question is u don\'t need to worry about the collision and change of direction. \n# Explanation (why collision don\'t affect the Ans)\nTwo cases of collision is given:-\n(i) If they collide and passes each other or can they swap their position on number line then...
1
0
['Sorting', 'Prefix Sum']
0
movement-of-robots
Beats 100%🔥|| Java Easy Code✅|| Beginner Friendly✅✅|| Sorting✅
beats-100-java-easy-code-beginner-friend-0gd0
\n# Complexity\n- Time complexity: O(NlogN)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n)
ayushmanglik2003
NORMAL
2023-06-11T06:26:59.836069+00:00
2023-06-11T06:26:59.836105+00:00
129
false
\n# Complexity\n- Time complexity: $$O(NlogN)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n static int mod = (int)(1e9 + 7);\n\n public int sumDistance(int[] nums, String s, int d)...
1
0
['Sorting', 'Java']
1
movement-of-robots
C++: move d units and sort, ignoring collision
c-move-d-units-and-sort-ignoring-collisi-rasn
when 2 robots collide, it switches direction. but for the purpose of finding the pair wisee distance, it is equivalent to switching robots and keep the same dir
lambdacode-dev
NORMAL
2023-06-11T00:22:14.743015+00:00
2023-06-11T00:23:16.801533+00:00
494
false
- when 2 robots `collide`, it `switches direction`. but for the purpose of finding the pair wisee distance, it is equivalent to `switching robots` and `keep the same direction`.\n- `sort` the final postion array\n- `prefix sum` to find the answer.\n```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, ...
1
0
['C++']
1
movement-of-robots
Java O(nlogn) + Sorting + Prefix Sum
java-onlogn-sorting-prefix-sum-by-skippe-vsxv
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
sKipper97
NORMAL
2023-06-10T19:26:39.273981+00:00
2023-06-10T19:26:39.274023+00:00
67
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(nlogn)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O...
1
0
['Java']
0
movement-of-robots
No change of directions required by robots. Sorting (O(n log n))
no-change-of-directions-required-by-robo-3m78
Intuition\n Describe your first thoughts on how to solve this problem. \nObservation - If two robots collide, direction changes but in actual - 1st robots becom
rkm_coder
NORMAL
2023-06-10T16:16:00.424584+00:00
2023-06-10T16:42:45.536427+00:00
391
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n**Observation** - If two robots collide, direction changes but in actual - 1st robots becomes 2nd robots. Thats it!\n\nSince `d` is order of 1e9 , we can\'t think of postion of robots after every second, rather calculate where robots will...
1
0
['C++']
2
movement-of-robots
Be Careful The Data Type Size
be-careful-the-data-type-size-by-linda20-6e0t
IntuitionApproachComplexity Time complexity: Space complexity: Code
linda2024
NORMAL
2025-03-21T22:04:27.948220+00:00
2025-03-21T22:04:27.948220+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
['C#']
0
movement-of-robots
Easy
easy-by-bhagya_patel_01-d1du
null
Bhagya_patel_01
NORMAL
2024-12-12T11:46:02.515162+00:00
2024-12-12T11:46:02.515162+00:00
19
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
movement-of-robots
python3 o(nlogn) maths
python3-onlogn-maths-by-0icy-f5xp
\n# Code\npython3 []\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n for i in range(len(nums)):\n if s[
0icy
NORMAL
2024-12-05T13:43:40.648098+00:00
2024-12-05T13:45:31.982347+00:00
9
false
\n# Code\n```python3 []\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n for i in range(len(nums)):\n if s[i] == \'R\':\n nums[i]+=d\n else:\n nums[i]-=d\n nums.sort()\n temp = sum([x-nums[0] for x in nums[1:]...
0
0
['Python3']
0
movement-of-robots
Python Simple
python-simple-by-snipingwiz4rd-l823
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
Snipingwiz4rd
NORMAL
2024-10-29T13:34:09.348409+00:00
2024-10-29T13:34:09.348462+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
['Python3']
0
movement-of-robots
50ms beats 100% solve by sorting, prefix and suffix
50ms-beats-100-solve-by-sorting-prefix-a-18z9
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
albert0909
NORMAL
2024-09-22T13:17:11.843343+00:00
2024-09-22T13:17:11.843378+00:00
25
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(nlgn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity h...
0
0
['Array', 'Brainteaser', 'Suffix Array', 'Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
nlog(n) time, 0 space, python solution
nlogn-time-0-space-python-solution-by-el-mbz4
Intuition\n Describe your first thoughts on how to solve this problem. \nWe don\'t have to change the direction of the robots, the colliding robots are intercha
ElijahXiao
NORMAL
2024-08-29T03:27:49.818123+00:00
2024-08-29T03:30:07.791778+00:00
3
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe don\'t have to change the direction of the robots, the colliding robots are interchangeable in position.\n# Approach\n<!-- Describe your approach to solving the problem. -->\nTo calculate the distance, we cannot use bruteforce approach...
0
0
['Python3']
0
movement-of-robots
avoid collision || consider crossing || easy to understand || must see
avoid-collision-consider-crossing-easy-t-5b24
Code\n\nclass Solution {\npublic:\n const int mod = 1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<long long>result;\n
akshat0610
NORMAL
2024-07-14T12:31:45.872639+00:00
2024-07-14T12:31:45.872685+00:00
3
false
# Code\n```\nclass Solution {\npublic:\n const int mod = 1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<long long>result;\n for(int i = 0 ; i < nums.size() ; i++){\n long long int currPos = nums[i];\n char dir = s[i];\n \n ...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
【47ms Beat100%】I hope there is no modulo!
47ms-beat100-i-hope-there-is-no-modulo-b-hef5
Intuition\n\n\n\n# Code\n\nclass Solution {\npublic:\n int sumDistance(vector<int>& ss, string s, int d) {\n ios::sync_with_stdio(false);cin.tie(0);co
UArBtBLh5g
NORMAL
2024-07-02T01:12:16.177959+00:00
2024-07-02T01:12:16.177994+00:00
9
false
# Intuition\n![image.png](https://assets.leetcode.com/users/images/279e4a21-038b-422d-a606-585dcda4a668_1719882675.3985534.png)\n\n\n# Code\n```\nclass Solution {\npublic:\n int sumDistance(vector<int>& ss, string s, int d) {\n ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);\n const int n=s.size();...
0
0
['C++']
0
movement-of-robots
C# Solution that passes all the test cases
c-solution-that-passes-all-the-test-case-7bul
Complexity\n- Time complexity: O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:O(n)\n Add your space complexity here, e.g. O(n) \n\n#
Daniil-Kienko
NORMAL
2024-06-20T13:20:34.124990+00:00
2024-06-20T13:20:34.125021+00:00
6
false
# Complexity\n- Time complexity: $$O(nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\npublic class Solution {\n public int SumDistance(int[] nums, string s, int d) {\n var longNums = new long[...
0
0
['C#']
0
movement-of-robots
🐍Python solution✅ Beats 82.83%✨
python-solution-beats-8283-by-barakamon-4qa4
\n\n# Code\n\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n MOD = 10**9 + 7\n\n for i in range(len(nums)):
Barakamon
NORMAL
2024-05-18T09:58:48.999714+00:00
2024-05-18T09:58:48.999747+00:00
8
false
\n\n# Code\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n MOD = 10**9 + 7\n\n for i in range(len(nums)):\n if s[i] == "R":\n nums[i] += d\n else:\n nums[i] -= d\n\n nums.sort()\n\n result = 0\n ...
0
0
['Python3']
0
movement-of-robots
JavaScript Solution
javascript-solution-by-wisemilk-2u1q
Intuition\nWe can first simulate the movement of the robots according to the given directions. Then, we can calculate the distances between pairs of robots at e
wisemilk
NORMAL
2024-05-08T08:48:59.915086+00:00
2024-05-08T08:48:59.915118+00:00
20
false
# Intuition\nWe can first simulate the movement of the robots according to the given directions. Then, we can calculate the distances between pairs of robots at each time step and sum them up.\n\n# Approach\n1. Simulate the movement of the robots according to the given directions.\n2. For each time step, calculate the ...
0
0
['JavaScript']
0
movement-of-robots
cpp
cpp-by-pankajkumar101-8ofl
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
PankajKumar101
NORMAL
2024-05-07T03:19:04.028037+00:00
2024-05-07T03:19:04.028066+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\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
movement-of-robots
C++ Solution ,if you're stuck with modulo😂😒
c-solution-if-youre-stuck-with-modulo-by-g7pn
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
drekker007
NORMAL
2024-03-16T02:32:01.078851+00:00
2024-03-16T02:32:01.078875+00:00
10
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
JavaScript solution using array methods, for loop and prefix sum.
javascript-solution-using-array-methods-7sj1u
Intuition:\nSimple array map method followed by array sort then finding the summation using for loop and prefix sum. For summation, two nested for loops only ca
hashtaghosh
NORMAL
2024-03-01T17:19:40.556968+00:00
2024-03-01T17:19:40.556999+00:00
12
false
# Intuition:\nSimple array map method followed by array sort then finding the summation using for loop and prefix sum. For summation, two nested for loops only can be used but that will give time out error here in this website.\n\n# Approach:\nJust ignore the collisions as all the robots are identical. Only consider le...
0
0
['JavaScript']
0
movement-of-robots
Python Solution || Brainteaser? New LeetCode Tag?
python-solution-brainteaser-new-leetcode-xsd6
Approach\n\n\n\n# Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Solution:\n def sumDistance(self, nums: List[int],
SEAQEN_KANI
NORMAL
2024-02-21T04:43:51.772014+00:00
2024-02-21T05:03:30.345151+00:00
18
false
# Approach\n![Untitled board.png](https://assets.leetcode.com/users/images/6f5ce1a3-d22d-46d5-bdbf-50fdb1015052_1708490538.0293803.png)\n\n\n# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(1)$$\n\n# Code\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:...
0
0
['Brainteaser', 'Python3']
0
movement-of-robots
Last Test Cases..
last-test-cases-by-ankit1478-itrb
If we have the array [7, 5, 3, 1] and we want to calculate the sum of the distances, we do:\n\n(7-5) + (7-3) + (7-1) = 2 + 4 + 6 = 12\n(5-3) + (5-1) = 2 + 4 = 6
ankit1478
NORMAL
2024-01-24T11:31:30.797279+00:00
2024-01-24T11:31:30.797301+00:00
20
false
If we have the array [7, 5, 3, 1] and we want to calculate the sum of the distances, we do:\n\n(7-5) + (7-3) + (7-1) = 2 + 4 + 6 = 12\n(5-3) + (5-1) = 2 + 4 = 6\n(3-1) = 2\n12 + 6 + 2 = 20 (this is n^2, which isn\'t good enough)\nHowever, with some math manipulation (extract common factor), we can see that 1, 2, and 3 ...
0
0
['Java']
0
movement-of-robots
This is #1503 + #2615
this-is-1503-2615-by-vokasik-4ig7
This is combo of 2 problems: #1503 + #2615
vokasik
NORMAL
2024-01-19T04:26:47.625370+00:00
2024-01-19T04:26:47.625420+00:00
1
false
This is combo of 2 problems: #1503 + #2615
0
0
[]
0
movement-of-robots
C++ Solution
c-solution-by-md_aziz_ali-csto
Code\n\nclass Solution {\npublic:\n int sumDistance(vector<int>& arr, string s, int d) {\n int n = arr.size();\n vector<long long> nums(n,0);\n
Md_Aziz_Ali
NORMAL
2024-01-18T06:48:09.472493+00:00
2024-01-18T06:48:09.472526+00:00
1
false
# Code\n```\nclass Solution {\npublic:\n int sumDistance(vector<int>& arr, string s, int d) {\n int n = arr.size();\n vector<long long> nums(n,0);\n int mod = 1e9 + 7;\n for(int i = 0;i < nums.size();i++) {\n if(s[i] == \'L\')\n nums[i] = arr[i]*1LL - d;\n ...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum']
0
movement-of-robots
Solution - beats 100% runtime
solution-beats-100-runtime-by-fattie_fat-6g5v
Intuition\n- Follow the hints\n\n# Code\n\nclass Solution(object):\n def sumDistance(self, nums, s, d):\n """\n :type nums: List[int]\n
fattie_fat
NORMAL
2023-12-27T01:05:51.770296+00:00
2023-12-27T01:05:51.770314+00:00
12
false
# Intuition\n- Follow the hints\n\n# Code\n```\nclass Solution(object):\n def sumDistance(self, nums, s, d):\n """\n :type nums: List[int]\n :type s: str\n :type d: int\n :rtype: int\n """\n \n\n n = len(s)\n\n new = [0] * n\n\n for i in range(n):...
0
0
['Python']
0
movement-of-robots
stop the modulo
stop-the-modulo-by-user3043sb-7ety
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
user3043SB
NORMAL
2023-12-01T14:46:44.238496+00:00
2023-12-01T14:46:44.238542+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
['Java']
0
movement-of-robots
[Python3] 2 lines w/ notes and examples || T/M: 99% / 91%
python3-2-lines-w-notes-and-examples-tm-47dz6
Notes:\n\nThe problem could be rephrased as:\n\n"Each robot travels d units left or right based on whether its corresponding element in s is L or R, respectivel
salma2vec
NORMAL
2023-11-18T09:23:53.833738+00:00
2023-11-18T09:23:53.833760+00:00
29
false
# Notes:\n\nThe problem could be rephrased as:\n\n"Each robot travels `d` units left or right based on whether its corresponding element in `s` is `L` or `R`, respectively. Find the sum of the distances based on these final positions."\n\nThe expression `(ord(c) - 79) // 3 * d` maps \'L\' to `-d` and \'R\' to `d`.\n\nI...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'Python', 'C++', 'Java', 'Python3']
0
movement-of-robots
Java + No need to consider collision
java-no-need-to-consider-collision-by-la-q803
Intuition\nWhen two robots collide with each other, we can just swap them and then it seems that they just go through each other. So we don\'t need to consider
lacfo
NORMAL
2023-11-16T16:08:34.498272+00:00
2023-11-16T16:08:34.498304+00:00
20
false
# Intuition\nWhen two robots collide with each other, we can just swap them and then it seems that they just go through each other. So we don\'t need to consider collision.\n\n# Approach\n* Get the positions of robots without considering collisions after `d` seconds\n* Sort the positions array to make the sum of pairs ...
0
0
['Java']
0
movement-of-robots
Fully explained C++ code || Beats 90% solutions || Easy to understand
fully-explained-c-code-beats-90-solution-lbsn
Intuition\nThe main intuition is when 2 robots collide, it switches direction. but for the purpose of finding the pair wise distance, it is equivalent to not sw
Yash_Khetan
NORMAL
2023-11-04T17:55:30.920257+00:00
2023-11-04T17:55:30.920275+00:00
14
false
# Intuition\n**The main intuition is when 2 robots collide, it switches direction. but for the purpose of finding the pair wise distance, it is equivalent to not switching the robots\' position and keep the same direction.**\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nTo solve th...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
Beat 90% Time | Clean & Concise
beat-90-time-clean-concise-by-swapniltya-06nx
Code\n\nclass Solution {\npublic:\n int MOD = 1000000007;\n int sumDistance(vector<int>& num, string s, int d) {\n vector<long> nums;\n for(
swapniltyagi17
NORMAL
2023-11-04T14:00:49.183657+00:00
2023-11-04T14:00:49.183690+00:00
5
false
# Code\n```\nclass Solution {\npublic:\n int MOD = 1000000007;\n int sumDistance(vector<int>& num, string s, int d) {\n vector<long> nums;\n for(auto x: num) nums.push_back(x);\n\n for(int i=0; i<nums.size(); ++i){\n if(s[i]==\'R\') nums[i] += d;\n else nums[i] -= d;\n ...
0
0
['C++']
0
movement-of-robots
Beats the new test cases!!
beats-the-new-test-cases-by-divy_jindal-dsbf
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
Divy_Jindal
NORMAL
2023-11-04T12:53:34.731792+00:00
2023-11-04T12:53:34.731824+00:00
5
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\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
movement-of-robots
✅ Explained Solution - All testcases ✅ O(n log n)
explained-solution-all-testcases-on-log-6ig1j
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n In the first loop, we convert the integer positions \'nums[i]\' of the r
bhardwajshruti97
NORMAL
2023-11-04T08:20:27.147830+00:00
2023-11-04T08:22:37.753446+00:00
24
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n In the first loop, we **convert the integer positions \'nums[i]\' of the robots to \'long\'** for precision and add/subtract the \'d\' distance depending on their direction (\'R\' or \'L\').\n\n**Sorting:** Then, we sort th...
0
0
['Java']
0
movement-of-robots
Array Simulation + Sort + Suffix. Time: O(nlogn), Space: O(n)
array-simulation-sort-suffix-time-onlogn-2kr6
class Solution(object):\n def sumDistance(self, nums, s, d):\n """\n :type nums: List[int]\n :type s: str\n :type d: int\n
iitjsagar
NORMAL
2023-11-04T03:46:58.627802+00:00
2023-11-04T03:46:58.627827+00:00
4
false
class Solution(object):\n def sumDistance(self, nums, s, d):\n """\n :type nums: List[int]\n :type s: str\n :type d: int\n :rtype: int\n """\n \n \n pos = []\n \n n = len(nums)\n \n for i in range(n):\n if s[i] == \...
0
0
[]
0
movement-of-robots
JAVA Solution
java-solution-by-bhumika1997-41l3
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
bhumika1997
NORMAL
2023-10-30T07:51:40.316013+00:00
2023-10-30T07:51:40.316034+00:00
10
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
movement-of-robots
Simple beginner-level C solution || Beats 100% in Runtime and Memory || Sorting + Prefix Sum
simple-beginner-level-c-solution-beats-1-3l34
\n# Complexity\n- Time complexity: O(nlogn)\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# Code\ncpp\n// Runtime 111 ms Beats 100%
paulchen2713
NORMAL
2023-10-10T04:13:39.050650+00:00
2023-10-10T04:13:39.050676+00:00
18
false
\n# Complexity\n- Time complexity: ```O(nlogn)```\n- Space complexity: ```O(n)```\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp\n// Runtime 111 ms Beats 100% Memory 17.5 MB Beats 100%\nint ascend(const void* pa, const void* pb) {\n const int a = *(const int*)pa;\n const int b = *(cons...
0
0
['Array', 'C', 'Sorting', 'Prefix Sum']
0
movement-of-robots
C++ - Sort + prefix sum
c-sort-prefix-sum-by-mumrocks-gq3e
Intuition\nWhen robot collide, it changes direction. We do not need to worry about changing direction of the robot. Pleae see below example to understand it bet
MumRocks
NORMAL
2023-09-27T13:45:50.630740+00:00
2023-09-27T13:45:50.630762+00:00
11
false
# Intuition\nWhen robot collide, it changes direction. We do not need to worry about changing direction of the robot. Pleae see below example to understand it better. \nA (at 4 and traveling right ) and B(at 5 and traveling left). When they collide A and B changes direction so you can imaging A becomes robot B and B be...
0
0
['Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
C++||Easy || 100%faster
ceasy-100faster-by-taufika999-pbaa
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
taufika999
NORMAL
2023-09-07T18:22:25.062717+00:00
2023-09-07T18:22:25.062739+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\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
movement-of-robots
C++/Python, solution with explanation
cpython-solution-with-explanation-by-shu-xxdj
\n\ntc is O(nlogn), sc is O(1).\n### python\npython\nmod = int(1e9+7)\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n
shun6096tw
NORMAL
2023-08-24T06:50:47.212316+00:00
2023-08-24T07:09:21.106091+00:00
10
false
![image](https://assets.leetcode.com/users/images/489bd57d-9f2c-44df-8005-839d83eda1fc_1692859787.7895982.png)\n\ntc is O(nlogn), sc is O(1).\n### python\n```python\nmod = int(1e9+7)\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n for i, ch in enumerate(s):\n num...
0
0
['C', 'Sorting', 'Prefix Sum', 'Python']
0
movement-of-robots
C++ solution
c-solution-by-pejmantheory-t0iq
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
pejmantheory
NORMAL
2023-08-20T13:16:36.300632+00:00
2023-08-20T13:16:36.300665+00:00
6
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
movement-of-robots
Golang sorting solution
golang-sorting-solution-by-tjucoder-7y0p
Code\ngo\nfunc sumDistance(nums []int, s string, d int) int {\n\tfinalPositions := make([]int, 0, len(nums))\n\tfor i, v := range nums {\n\t\tswitch s[i] {\n\t\
tjucoder
NORMAL
2023-08-19T17:09:03.371722+00:00
2023-08-19T17:09:03.371749+00:00
9
false
# Code\n```go\nfunc sumDistance(nums []int, s string, d int) int {\n\tfinalPositions := make([]int, 0, len(nums))\n\tfor i, v := range nums {\n\t\tswitch s[i] {\n\t\tcase \'L\':\n\t\t\tv -= d\n\t\tcase \'R\':\n\t\t\tv += d\n\t\t}\n\t\tfinalPositions = append(finalPositions, v)\n\t}\n\tsort.Ints(finalPositions)\n\tresul...
0
0
['Sorting', 'Go']
0
movement-of-robots
I, Robot | O(N log(N)) Easy to understand | C++
i-robot-on-logn-easy-to-understand-c-by-oy1rj
Intuition\nThe most tricky part is to understand that bouncing robots are the same as non-bouncing robots.\n\nThe second part is to calculate the prefix sum to
urmichm
NORMAL
2023-07-13T14:45:30.355238+00:00
2023-07-13T14:45:30.355268+00:00
11
false
# Intuition\nThe most tricky part is to understand that bouncing robots are the same as non-bouncing robots.\n\nThe second part is to calculate the prefix sum to quickly calculate the distance sum.\n\n# Approach\nApply distances to each robot. Sort $$nums$$ as it does not matter which robot is where, we only need their...
0
0
['C++']
0
movement-of-robots
C++ || UNIQUE || COUNT REPETITION OF EDGES
c-unique-count-repetition-of-edges-by-ay-8fri
Intuition\nSo firstly I will talk about finding the point at which the robots will be after d second so for that don\'t confuse with collision part just add or
Ayush_codes26
NORMAL
2023-07-08T12:43:20.531076+00:00
2023-07-08T12:43:20.531106+00:00
33
false
# Intuition\nSo firstly I will talk about finding the point at which the robots will be after d second so for that don\'t confuse with collision part just add or subtract d based on \'L\' and \'R\' because the position only matter for calculating all pairs distances. And after that just calculate distance.\n\n\n# Compl...
0
0
['C++']
0
movement-of-robots
Rust/Python O(n log n) and constant space. With detailed explanation
rustpython-on-log-n-and-constant-space-w-ta60
Intuition\nThe key observation in this problem is how to find the final position of the robots. Lets assume that we have two robots going towards each other. Le
salvadordali
NORMAL
2023-07-06T20:58:42.700441+00:00
2023-07-06T20:58:42.700458+00:00
9
false
# Intuition\nThe key observation in this problem is how to find the final position of the robots. Lets assume that we have two robots going towards each other. Lets assume their positions are `[6, 24]`. At timestep 9 they will meet (at position 15) and change directions. At time 11, position of robot 1 will be at posit...
0
0
['Rust']
0
movement-of-robots
Use sum to find the differences
use-sum-to-find-the-differences-by-darv-cz0f
\nconst int MOD = 1000000007;\nclass Solution {\n int sumDistance(List<int> nums, String s, int d) {\n List<int> finals = [];\n for (int i = 0; i < nums.
darv
NORMAL
2023-07-01T06:08:09.359759+00:00
2023-07-01T06:08:09.359791+00:00
22
false
```\nconst int MOD = 1000000007;\nclass Solution {\n int sumDistance(List<int> nums, String s, int d) {\n List<int> finals = [];\n for (int i = 0; i < nums.length; i++)\n finals.add((s[i] == \'L\') ? nums[i] - d : nums[i] + d);\n finals.sort();\n\n int res = 0;\n\n int right_sum = finals.reduce((va...
0
0
['Dart']
0
movement-of-robots
[C++] Ignore Collisions and Get Cumulative Sum, ~100% (90ms), ~45% Space (45.2MB)
c-ignore-collisions-and-get-cumulative-s-fps5
So, for this problem the more crucial part was to figure out we can ignore each collision: similarly to a perfectly elastic linear system with two identical obj
Ajna2
NORMAL
2023-06-18T19:11:31.949546+00:00
2023-06-19T16:27:40.685340+00:00
42
false
So, for this problem the more crucial part was to figure out we can ignore each collision: similarly to a perfectly elastic linear system with two identical objects colliding with each other, each object will replace the other one, moving from the the collision spot in the opposite direction; this is basically a sophis...
0
0
['Array', 'Brainteaser', 'Sorting', 'Prefix Sum', 'C++']
0
movement-of-robots
Why to Sort before Prefix sum? Explained
why-to-sort-before-prefix-sum-explained-mfokz
Idea\n Describe your first thoughts on how to solve this problem. \n\n\n- if it\'s neg then -(d-b) lets take this as eg. like b > d.\n- then d-a + d-b + d-c = 3
bala_000
NORMAL
2023-06-17T12:34:44.245264+00:00
2023-06-22T21:12:09.073239+00:00
26
false
# Idea\n<!-- Describe your first thoughts on how to solve this problem. -->\n![CapturedImage-17-06-2023 18-01-11.png](https://assets.leetcode.com/users/images/133addb5-fb43-40d0-a877-6112eb9f78c4_1687005206.596571.png)\n\n- if it\'s neg then -(d-b) lets take this as eg. like b > d.\n- then d-a + d-b + d-c = 3d - (a+b+c...
0
0
['C++']
0
movement-of-robots
c++ | Ants on a Plank
c-ants-on-a-plank-by-srv-er-5i94
\nclass Solution {\npublic:\n int md=1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n for(int i=0;i<size(nums);++i){\n i
srv-er
NORMAL
2023-06-16T04:05:22.330718+00:00
2023-06-16T04:05:22.330745+00:00
30
false
```\nclass Solution {\npublic:\n int md=1e9+7;\n int sumDistance(vector<int>& nums, string s, int d) {\n for(int i=0;i<size(nums);++i){\n if(s[i]==\'R\')nums[i]+=d;\n else nums[i]-=d;\n }\n sort(begin(nums),end(nums));\n long pf=0,ans=0;\n for(int i=0;i<siz...
0
0
['C', 'Prefix Sum']
0
movement-of-robots
Collision means nothing
collision-means-nothing-by-piyush01123-gci7
This problem has a trick. I could not do it during contest but later realized the trick.\n\n- The fact that the robots change directions at collision means noth
piyush01123
NORMAL
2023-06-15T07:43:24.476737+00:00
2023-06-15T07:47:42.019795+00:00
63
false
This problem has a trick. I could not do it during contest but later realized the trick.\n\n- The fact that the robots change directions at collision means nothing. We can just consider they switched IDs because at the end we really only care about the positions of the robots as a whole. We do not really care about *wh...
0
0
['Math', 'Simulation', 'C++']
0
movement-of-robots
C++ Easy Solution
c-easy-solution-by-vibhu172000-31jt
\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<int>position(nums.size());\n int m =1e9+7;\n
vibhu172000
NORMAL
2023-06-14T13:16:12.598077+00:00
2023-06-14T13:16:12.598099+00:00
15
false
```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n vector<int>position(nums.size());\n int m =1e9+7;\n for(int i=0;i<nums.size();i++){\n if(s[i]==\'R\'){\n position[i]=d+nums[i];\n }\n else{\n po...
0
0
[]
0
movement-of-robots
c++ solution
c-solution-by-jerry_1-g99p
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
jerry_1
NORMAL
2023-06-14T12:44:10.999056+00:00
2023-06-14T12:44:10.999084+00:00
25
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:0(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: 0(n)\n<!-- Add your space complexity here, e.g...
0
0
['C++']
0
movement-of-robots
I-love-this-problem feel.
i-love-this-problem-feel-by-rhexaoc-tzu2
Intuition\n\nFirst time I was reading a part of the description about collisions, I thought to myself: "the collisions must be intuitive and there is no point i
RHEXAOC
NORMAL
2023-06-14T11:33:15.972990+00:00
2023-06-14T11:33:15.973010+00:00
10
false
# Intuition\n\nFirst time I was reading a part of the description about collisions, I thought to myself: "the collisions must be intuitive and there is no point in paying atention to them." \n\nInitially I thought that the right path is to notice, that before the collision there is one robot moving right and one robot ...
0
0
['C++']
0
movement-of-robots
C++ ignore collision
c-ignore-collision-by-sachin-vinod-vhqz
Observation\n- key point here is ignore collision and let all of them pass from each other \n\n# Complexity\n- Time complexity:O(NlogN)\n Add your time complexi
Sachin-Vinod
NORMAL
2023-06-14T09:31:37.282702+00:00
2023-06-14T09:31:37.282723+00:00
10
false
# Observation\n- key point here is ignore collision and let all of them pass from each other \n\n# Complexity\n- Time complexity:$$O(NlogN)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npu...
0
0
['C++']
0
movement-of-robots
C++ ignore collision
c-ignore-collision-by-sachin-vinod-z8jm
Observation\n- key point here is ignore collision and let all of them pass from each other \n\n# Complexity\n- Time complexity:O(NlogN)\n Add your time complexi
Sachin-Vinod
NORMAL
2023-06-14T09:31:27.744271+00:00
2023-06-14T09:31:27.744297+00:00
10
false
# Observation\n- key point here is ignore collision and let all of them pass from each other \n\n# Complexity\n- Time complexity:$$O(NlogN)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:$$O(N)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npu...
0
0
['C++']
0
movement-of-robots
BEST IMPLEMENTATION | EASY | C++ CODE | ANS REVIEW PLS
best-implementation-easy-c-code-ans-revi-3e1p
Intuition\n Describe your first thoughts on how to solve this problem. \n\n\n all the robots are of same characterstics ....\n so , after colliding they have ju
MihirKathpal
NORMAL
2023-06-13T14:25:47.827604+00:00
2023-06-13T14:25:47.827623+00:00
18
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n\n all the robots are of same characterstics ....\n* so , after colliding they have just effect of directions .. so we can think robots surpass each other instead of thinking they collided\n\n* after d seconds all the robots at there s...
0
0
['C++']
0
movement-of-robots
Javascript - Sort + PreSum + Math
javascript-sort-presum-math-by-faustaleo-opsm
Code\n\n/**\n * @param {number[]} nums\n * @param {string} s\n * @param {number} d\n * @return {number}\n */\nvar sumDistance = function (nums, s, d) {\n const
faustaleonardo
NORMAL
2023-06-13T00:35:43.573146+00:00
2023-06-13T01:19:49.095318+00:00
51
false
# Code\n```\n/**\n * @param {number[]} nums\n * @param {string} s\n * @param {number} d\n * @return {number}\n */\nvar sumDistance = function (nums, s, d) {\n const n = nums.length;\n const MOD = Math.pow(10, 9) + 7;\n for (let i = 0; i < n; i++) {\n nums[i] = s[i] === \'R\' ? nums[i] + d : nums[i] - d;\n }\n\n ...
0
0
['Math', 'Sorting', 'Prefix Sum', 'JavaScript']
0
movement-of-robots
Python: explained in pictures and math
python-explained-in-pictures-and-math-by-opie
Approach\nSince there is no chance to simulate actual robots movement considering the problem constraints, let\'s try to find another way.\n\nFirst thing which
olzh06
NORMAL
2023-06-12T20:16:36.646876+00:00
2023-06-12T20:18:22.790762+00:00
44
false
# Approach\nSince there is no chance to simulate actual robots movement considering the problem constraints, let\'s try to find another way.\n\nFirst thing which is crusial for solving this problem is to understand what will be the final position of robots. The situation when there are no other robots on the way is ill...
0
0
['Python3']
0
movement-of-robots
Trick question: let robots walk past each other.
trick-question-let-robots-walk-past-each-66ov
Computing final positions\n\n First note that the final solution is only a function of the final robot positions, and robot indices are not important\n When rob
erjoalgo
NORMAL
2023-06-12T19:54:48.997069+00:00
2023-06-19T05:01:19.845783+00:00
6
false
**Computing final positions**\n\n* First note that the final solution is only a function of the final robot positions, and robot indices are not important\n* When robots collide, they can "walk past each other" instead of colliding:\n * Collision type 1:\n * R | _ | L\n * _ | RL| _ = _ | LR | _\n * L | _ | R\n...
0
0
[]
0
movement-of-robots
c++ || easy || prefix sum
c-easy-prefix-sum-by-srajan12-8jx0
\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) { \n \n int n = nums.size(); \n v
srajan12
NORMAL
2023-06-12T12:52:18.630067+00:00
2023-06-12T12:52:18.630114+00:00
18
false
```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) { \n \n int n = nums.size(); \n vector <long long int> nums2(nums.begin(), nums.end());\n for(int i=0; i<n; i++)\n {\n if(s[i]==\'R\') \n n...
0
0
['Array', 'Math', 'C', 'Iterator', 'Prefix Sum']
0
movement-of-robots
Simple prefix sum : movement-of-robot
simple-prefix-sum-movement-of-robot-by-_-ugu0
Intuition\n Describe your first thoughts on how to solve this problem. \nThere is no difference if we do not perform collision condition as distance between rob
_aanjali
NORMAL
2023-06-12T12:20:49.984436+00:00
2023-06-12T17:14:30.134372+00:00
29
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThere is no difference if we do not perform collision condition as distance between robots remain same.\nincrement robot position by 1 if robot direction is RIGHT;\ndecrement robot position by 1 if robot direction is LEFT;\n\n![image.png]...
0
0
['Prefix Sum', 'C++']
0
movement-of-robots
c++ || iterative || for loop
c-iterative-for-loop-by-srajan12-13uc
\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) { \n int n = nums.size();\n \n vector <long lon
srajan12
NORMAL
2023-06-12T12:17:48.227978+00:00
2023-06-12T12:18:09.010507+00:00
4
false
```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) { \n int n = nums.size();\n \n vector <long long int> nums2(nums.begin(), nums.end());\n for(int i=0; i<n; i++)\n {\n if(s[i]==\'R\')\n {\n nums2[i]+=d;\...
0
0
['Array', 'Math', 'C', 'Iterator']
0
movement-of-robots
JAVA || Easy Explanation
java-easy-explanation-by-dhananjay2001-28m7
Intuition\nDon\'t think about directions.\n1. Just add d in nums[i] if R ,\n2. otherwise subtract d from nums[i]\n3. and add differenc of each.\n\nThis are simp
dhananjay2001
NORMAL
2023-06-12T05:56:39.298182+00:00
2023-06-12T05:57:11.264372+00:00
44
false
# Intuition\nDon\'t think about directions.\n1. Just add d in nums[i] if R ,\n2. otherwise subtract d from nums[i]\n3. and add differenc of each.\n\nThis are simple Steps but Calculation of difference sum is main part.\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nAfter moving all ...
0
0
['Java']
2
movement-of-robots
C++ | Tricky yet VV Easy question | O(nlogn)
c-tricky-yet-vv-easy-question-onlogn-by-wongw
Approach\n Describe your approach to solving the problem. \nWe see the robots coliding and moving to its own position again, yet we can observe even if the coli
leet_alok
NORMAL
2023-06-12T05:13:27.322715+00:00
2023-06-12T05:13:27.322762+00:00
24
false
# Approach\n<!-- Describe your approach to solving the problem. -->\nWe see the robots coliding and moving to its own position again, yet we can observe even if the colision never happened the robots would be found in those places anyhow. As we are not concerned about any specific robots we can consider all as one and ...
0
0
['C++']
0
movement-of-robots
C#
c-by-kpzeus-2xf9
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
kpzeus
NORMAL
2023-06-12T02:27:25.631143+00:00
2023-06-12T02:27:25.631171+00:00
21
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
movement-of-robots
[C]
c-by-zhang_jiabo-v2af
C []\r\n#define MODULO (1000000007)\r\n\r\nstatic int cmp_int_asc(const int * const p1, const int * const p2){\r\n\tif (*p1 < *p2){\r\n\t\treturn -1;\r\n\t}else
zhang_jiabo
NORMAL
2023-06-11T21:15:27.426268+00:00
2023-06-11T21:15:27.426312+00:00
19
false
```C []\r\n#define MODULO (1000000007)\r\n\r\nstatic int cmp_int_asc(const int * const p1, const int * const p2){\r\n\tif (*p1 < *p2){\r\n\t\treturn -1;\r\n\t}else if (*p1 > *p2){\r\n\t\treturn 1;\r\n\t}else {\r\n\t\treturn 0;\r\n\t}\r\n}\r\n\r\nint sumDistance(\r\n\tint * const nums,\r\n\tconst int numsLen,\r\n\tconst...
0
0
['C']
0
movement-of-robots
C++ | Math | Easy Solution
c-math-easy-solution-by-hulkioro-lilk
Please UpVote if it helps you\nApproach - don\'t think that robots are colliding each other, just add the d or subtract on ith robot\'s position if ith string i
Hulkioro
NORMAL
2023-06-11T18:49:51.178370+00:00
2023-06-11T18:49:51.178404+00:00
36
false
# Please UpVote if it helps you\nApproach - don\'t think that robots are colliding each other, just add the `d` or subtract on `ith` robot\'s position if `ith` string is `R` and `L` respectively.\n\n# Code\n```\nclass Solution {\npublic:\n int sumDistance(vector<int>& nums, string s, int d) {\n int n = nums.s...
0
0
['Math', 'Greedy', 'Brainteaser', 'Sorting', 'C++']
0
movement-of-robots
python solution
python-solution-by-choijong-o889
Code\n\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n \n mod = 1000000007\n ans = 0\n ln = l
choijong
NORMAL
2023-06-11T18:36:25.732480+00:00
2023-06-11T18:36:25.732508+00:00
18
false
# Code\n```\nclass Solution:\n def sumDistance(self, nums: List[int], s: str, d: int) -> int:\n \n mod = 1000000007\n ans = 0\n ln = len(nums)\n \n for i in range(ln):\n if s[i] == \'L\':\n nums[i] -= d\n else:\n nums[i] +=...
0
0
['Python3']
0
movement-of-robots
✅Fully Explained || Ant on Planks || Trilogy 2022 || C++
fully-explained-ant-on-planks-trilogy-20-dw3w
Intuition\n Describe your first thoughts on how to solve this problem. \nBefore solving this question, if you have solved the problem Ant on planks, it would he
intern_grind
NORMAL
2023-06-11T13:22:43.802563+00:00
2023-06-11T13:22:43.802596+00:00
36
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nBefore solving this question, if you have solved the problem Ant on planks, it would help you a lot to think the next step in this question.\n\nSo the intuition is to think that image robots to pass each other and just ignore about collis...
0
0
['Brainteaser', 'Prefix Sum', 'C++']
0
movement-of-robots
C++ Easy to understand, steps given, TC(nlogn), SC O(1), not prefixsum
c-easy-to-understand-steps-given-tcnlogn-4dtd
Steps\n- There won\'t be any effect of collision, you can see that by taking example and doing yourself\n- So, the main part was to find, Sum of absolute diffe
Adi_217
NORMAL
2023-06-11T13:07:15.916868+00:00
2023-06-11T13:07:15.916906+00:00
7
false
# Steps\n- There won\'t be any effect of collision, you can see that by taking example and doing yourself\n- So, the main part was to find, Sum of absolute differences of all pairs in modified vector of positions\n- For this refer to this gfg post https://www.geeksforgeeks.org/sum-absolute-differences-pairs-given-arra...
0
0
['Math', 'Sorting', 'C++']
0
movement-of-robots
Easy C++ Solution and easy to understand.
easy-c-solution-and-easy-to-understand-b-enq6
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
harshguptamanit2020
NORMAL
2023-06-11T11:24:02.297341+00:00
2023-06-11T11:24:02.297384+00:00
29
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:O(nlogn)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O...
0
0
['C++']
0
movement-of-robots
Kotlin O(nlogn) sort + prefix sum (with comment)
kotlin-onlogn-sort-prefix-sum-with-comme-4vbs
Code\n\nclass Solution {\n fun sumDistance(nums: IntArray, s: String, d: Int): Int {\n val mod = 1000000007\n\n /*\n * Ignore direction
aliam
NORMAL
2023-06-11T11:17:59.446617+00:00
2023-06-11T11:17:59.446665+00:00
14
false
# Code\n```\nclass Solution {\n fun sumDistance(nums: IntArray, s: String, d: Int): Int {\n val mod = 1000000007\n\n /*\n * Ignore direction changes, since we don\'t need to track robots, and if a robot x and\n * a robot y meet, and change directions we can look at it as if the two robo...
0
0
['Kotlin']
0