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
count-number-of-maximum-bitwise-or-subsets
Easy python solution using recursion and backtracking
easy-python-solution-using-recursion-and-o700
Code\n\nclass Solution:\n def countMaxOrSubsets(self, nums: List[int]) -> int:\n def subs(idx,nums,N,lst,l):\n if idx>=N:\n
Lalithkiran
NORMAL
2023-04-20T15:43:03.403273+00:00
2023-04-20T15:43:03.403351+00:00
530
false
# Code\n```\nclass Solution:\n def countMaxOrSubsets(self, nums: List[int]) -> int:\n def subs(idx,nums,N,lst,l):\n if idx>=N:\n val=0\n for i in lst:\n val |= i\n l.append(val)\n return\n lst.append(nums[idx]...
2
0
['Backtracking', 'Bit Manipulation', 'Recursion', 'Python3']
0
count-number-of-maximum-bitwise-or-subsets
EASY||Bit Manipulation||C++
easybit-manipulationc-by-rohit_18kumar-onop
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
rohit_18kumar
NORMAL
2023-03-31T14:27:37.073801+00:00
2023-03-31T14:27:37.073850+00:00
125
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
count-number-of-maximum-bitwise-or-subsets
Javascript backtracking solution 81 ms, faster than 100.00%,43.1 MB, less than 11.11%!!
javascript-backtracking-solution-81-ms-f-snxd
```\n/*\n * @param {number[]} nums\n * @return {number}\n /\nvar countMaxOrSubsets = function(nums) {\n let res = 0;\n let max = 0;\n function backtrac
HabibovUlugbek
NORMAL
2023-03-31T11:24:40.342274+00:00
2023-03-31T11:24:40.342316+00:00
50
false
```\n/**\n * @param {number[]} nums\n * @return {number}\n */\nvar countMaxOrSubsets = function(nums) {\n let res = 0;\n let max = 0;\n function backtrack(nums,start, val){ \n if(val === max)res++\n \n for(let i = start;i<nums.length; i++){\n backtrack(nums,i+1,val|nums[i])\n ...
2
0
['Backtracking', 'Bit Manipulation', 'JavaScript']
0
count-number-of-maximum-bitwise-or-subsets
C++ | DP
c-dp-by-pikachuu-jz5q
Code\n\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int maxVal = 0;\n for(int num: nums) {\n maxVal = m
pikachuu
NORMAL
2023-01-15T18:06:55.635218+00:00
2023-01-15T18:06:55.635251+00:00
76
false
# Code\n```\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int maxVal = 0;\n for(int num: nums) {\n maxVal = maxVal | num;\n }\n vector<int> DP(maxVal + 1, 0);\n DP[nums[0]] = 1;\n for(int i = 1; i < nums.size(); i++) {\n for(...
2
0
['Array', 'Dynamic Programming', 'Bit Manipulation', 'C++']
0
count-number-of-maximum-bitwise-or-subsets
C++||Backtracking||Recursion||Easy to Understand
cbacktrackingrecursioneasy-to-understand-otcj
```\nclass Solution {\npublic:\n int ans=0;\n void backtrack(vector &nums,int target,int idx,int curr_xor)\n {\n if(idx>=nums.size())\n {
return_7
NORMAL
2022-07-12T05:27:39.668444+00:00
2022-07-12T05:27:39.668496+00:00
219
false
```\nclass Solution {\npublic:\n int ans=0;\n void backtrack(vector<int> &nums,int target,int idx,int curr_xor)\n {\n if(idx>=nums.size())\n {\n if(curr_xor==target)\n {\n ans++;\n }\n return ;\n }\n \n backtrack(nums...
2
0
['Backtracking', 'Recursion', 'C']
0
count-number-of-maximum-bitwise-or-subsets
C++ | Subsets Approach
c-subsets-approach-by-ama29n-fum5
\nint countMaxOrSubsets(vector<int>& nums) {\n int ans = 0, maxOr = INT_MIN;\n int limit = pow(2, nums.size());\n for(int i = 0; i < limit;
ama29n
NORMAL
2022-01-08T19:37:54.229435+00:00
2022-01-08T19:38:38.992259+00:00
182
false
```\nint countMaxOrSubsets(vector<int>& nums) {\n int ans = 0, maxOr = INT_MIN;\n int limit = pow(2, nums.size());\n for(int i = 0; i < limit; i++) {\n int Or = 0;\n for(int j = 0; j < nums.size(); j++) { \n\t\t\t\tif((i & (1 << j)) == 0) Or |= nums[j];\n\t\t\t}\n i...
2
0
[]
0
count-number-of-maximum-bitwise-or-subsets
python 100% faster
python-100-faster-by-saurabht462-o60j
```\ndef countMaxOrSubsets(self, nums: List[int]) -> int:\n target=0\n for n in nums:\n target|=n\n self.ans=set()\n def
saurabht462
NORMAL
2021-10-17T10:43:19.473625+00:00
2021-10-17T10:49:00.230201+00:00
133
false
```\ndef countMaxOrSubsets(self, nums: List[int]) -> int:\n target=0\n for n in nums:\n target|=n\n self.ans=set()\n def helper(i,curr,arr):\n if curr==target:\n self.ans.add(tuple(arr.copy()))\n if i==len(nums):\n return\n ...
2
1
[]
0
count-number-of-maximum-bitwise-or-subsets
Easy C++ solution | O(2^n * n )
easy-c-solution-o2n-n-by-rac101ran-jvwh
\nclass Solution {\npublic:\n int cnt[300005];\n int countMaxOrSubsets(vector<int>& nums) {\n int len=(1<<(int)nums.size());\n int ans=0;\n
rac101ran
NORMAL
2021-10-17T08:55:50.097697+00:00
2021-10-17T08:56:26.651267+00:00
281
false
```\nclass Solution {\npublic:\n int cnt[300005];\n int countMaxOrSubsets(vector<int>& nums) {\n int len=(1<<(int)nums.size());\n int ans=0;\n for(int i=0; i<len; i++) {\n int z=i,pos=0,orr=0;\n while(z) {\n if((z&1)==1) {\n orr|=nums[...
2
0
['Math', 'C', 'Bitmask']
0
count-number-of-maximum-bitwise-or-subsets
[Python3] Beats 100% Solution | Easy to understand
python3-beats-100-solution-easy-to-under-rgnk
python\nclass Solution:\n def countMaxOrSubsets(self, nums: List[int]) -> int:\n ans = {}\n subSet = [[]]\n max_or = 0\n for i in
leefycode
NORMAL
2021-10-17T05:11:40.516874+00:00
2021-10-17T05:11:40.516927+00:00
233
false
```python\nclass Solution:\n def countMaxOrSubsets(self, nums: List[int]) -> int:\n ans = {}\n subSet = [[]]\n max_or = 0\n for i in range(len(nums)):\n for j in range(len(subSet)):\n new = [nums[i]] + subSet[j]\n # print(new)\n x = ...
2
1
['Python3']
1
count-number-of-maximum-bitwise-or-subsets
100% fast | easy python solution using Combinations from Itertools
100-fast-easy-python-solution-using-comb-9jv5
Combination returns tuples as output thats why make sure to convert it to list before append in a array because tuples does not supports OR Operation.\n```\ncla
shivamsingh99
NORMAL
2021-10-17T04:31:19.017033+00:00
2021-10-17T04:31:19.017067+00:00
345
false
Combination returns tuples as output thats why make sure to convert it to list before append in a array because tuples does not supports OR Operation.\n```\nclass Solution:\n from itertools import combinations \n def countMaxOrSubsets(self, nums: List[int]) -> int:\n d = {}\n o = 0\n arr = []...
2
0
['Python']
1
count-number-of-maximum-bitwise-or-subsets
(C++) 2044. Count Number of Maximum Bitwise-OR Subsets
c-2044-count-number-of-maximum-bitwise-o-iu10
\n\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int target = 0, n = nums.size(); \n for (auto& x : nums) target |=
qeetcode
NORMAL
2021-10-17T04:06:37.158905+00:00
2021-10-18T04:07:13.240055+00:00
242
false
\n```\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int target = 0, n = nums.size(); \n for (auto& x : nums) target |= x; \n \n map<pair<int, int>, int> memo; \n function<int(int, int)> fn = [&](int i, int mask) -> int {\n if (mask == target) ...
2
0
['C']
0
count-number-of-maximum-bitwise-or-subsets
java | recursion | backtracking
java-recursion-backtracking-by-qin10-1yij
```\nclass Solution {\n int count = 0;\n public int countMaxOrSubsets(int[] nums) {\n int maxOr = 0;\n for (int num : nums)\n max
qin10
NORMAL
2021-10-17T04:03:26.398118+00:00
2021-11-05T16:16:48.142688+00:00
118
false
```\nclass Solution {\n int count = 0;\n public int countMaxOrSubsets(int[] nums) {\n int maxOr = 0;\n for (int num : nums)\n maxOr |= num;\n \n getMaxSub(nums, 0, 0, maxOr);\n return count;\n }\n \n private void getMaxSub(int[] arr, int i, int curOr, int max...
2
2
[]
1
count-number-of-maximum-bitwise-or-subsets
C++ dp bitwise O(2^n)
c-dp-bitwise-o2n-by-colinyoyo26-bdnu
\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int n = nums.size(), mx = 0, ans = 0;\n int dp[1 << 17]{};\n
colinyoyo26
NORMAL
2021-10-17T04:00:39.371089+00:00
2021-11-14T16:22:18.187198+00:00
200
false
```\nclass Solution {\npublic:\n int countMaxOrSubsets(vector<int>& nums) {\n int n = nums.size(), mx = 0, ans = 0;\n int dp[1 << 17]{};\n for (auto t : nums) mx |= t;\n for (int i = 1, j = 1; i < (1 << n); i++) {\n j += (i == (1 << j));\n dp[i] = dp[i ^ (1 << (j - 1...
2
0
[]
1
count-number-of-maximum-bitwise-or-subsets
Dynamic Programming | Iterative | Short & Readable
dynamic-programming-iterative-short-read-o9ca
IntuitionWe need to find the number of subsets that achieve the maximum possible bitwise OR. By iterating through nums, we maintain a frequency map of OR result
amanabiy
NORMAL
2025-03-31T22:29:15.240454+00:00
2025-03-31T22:29:15.240454+00:00
17
false
# Intuition We need to find the number of subsets that achieve the maximum possible bitwise OR. By iterating through nums, we maintain a frequency map of OR results and their counts. ## Code ```python3 [] class Solution: def countMaxOrSubsets(self, nums: List[int]) -> int: count = defaultdict(lambda: 0) ...
1
0
['Hash Table', 'Dynamic Programming', 'Python3', 'Rust']
0
count-number-of-maximum-bitwise-or-subsets
Counting Subsets with Maximum Bitwise OR Using Recursion and Backtracking
counting-subsets-with-maximum-bitwise-or-w6jj
IntuitionThe problem requires finding the number of different non-empty subsets of an array that have the maximum possible bitwise OR. My first thought was to g
x7Fg9_K2pLm4nQwR8sT3vYz5bDcE6h
NORMAL
2025-03-19T13:42:33.469630+00:00
2025-03-19T13:42:33.469630+00:00
17
false
# Intuition The problem requires finding the number of different non-empty subsets of an array that have the maximum possible bitwise OR. My first thought was to generate all possible subsets of the array, compute the bitwise OR for each subset, and then count how many subsets achieve the maximum OR value. # Approach ...
1
0
['C++']
0
count-number-of-maximum-bitwise-or-subsets
beats 100% easy backtracking solution
beats-100-easy-backtracking-solution-by-c0mqi
Complexity Time complexity:O(2^n) Space complexity:O(1) Code
s_malay
NORMAL
2025-03-15T07:13:44.679449+00:00
2025-03-15T07:13:44.679449+00:00
26
false
# Complexity - Time complexity:O(2^n) <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity:O(1) <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code ```cpp [] class Solution { public: int helper(int i,vector<int>&nums,int maxor,int orr) { if(i==nums.size()) { if(orr==maxo...
1
0
['Array', 'Backtracking', 'Bit Manipulation', 'Enumeration', 'C++']
0
count-number-of-maximum-bitwise-or-subsets
C#
c-by-adchoudhary-9x68
Code
adchoudhary
NORMAL
2025-03-06T03:24:57.750379+00:00
2025-03-06T03:24:57.750379+00:00
6
false
# Code ```csharp [] public class Solution { public int CountMaxOrSubsets(int[] nums) { int maxOr = 0; int n = nums.Length; foreach (int num in nums) { maxOr |= num; } int count = 0; int totalSubsets = 1 << n; for (int mask = 1; mask < totalSubsets; mask++) { int currentOr = 0; for ...
1
0
['C#']
0
count-number-of-maximum-bitwise-or-subsets
THE BEST CODE TO BEAT 95+% OF ALL SOLUTIONS ON LEETCODE. Good luck to everyone!!!! 💻🚀🔥💡
the-best-code-to-beat-95-of-all-solution-v10p
IntuitionApproachComplexity Time complexity: Space complexity: Code
nilfhunter
NORMAL
2025-01-11T15:11:45.300073+00:00
2025-01-11T15:11:45.300073+00:00
21
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['Python3']
0
count-number-of-maximum-bitwise-or-subsets
THE BEST CODE TO BEAT 95+% OF ALL SOLUTIONS ON LEETCODE. Good luck to everyone!!!! 💻🚀🔥💡
the-best-code-to-beat-95-of-all-solution-ctz4
IntuitionApproachComplexity Time complexity: Space complexity: Code
nilfhunter
NORMAL
2025-01-11T15:11:40.649865+00:00
2025-01-11T15:11:40.649865+00:00
21
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['Python3']
0
count-number-of-maximum-bitwise-or-subsets
✔✔Easy, backtracking, Bit Manipulation 😃🙌
easy-backtracking-bit-manipulation-by-pm-zeig
Intuition We are given an integer array nums and we need to calculate the maximum number of possible sets with maximum possible bitwise OR of a subset of nums.
PM_25
NORMAL
2025-01-07T06:01:48.062050+00:00
2025-01-07T06:01:48.062050+00:00
22
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> - We are given an integer array `nums` and we need to calculate the maximum number of possible sets with **maximum possible bitwise OR of a subset of `nums`**. ## Approach <!-- Describe your approach to solving the problem. --> - **Step-1**...
1
0
['Array', 'Backtracking', 'Bit Manipulation', 'C++']
0
count-number-of-maximum-bitwise-or-subsets
Simple solution
simple-solution-by-shreyas_kumar_m-s1le
Code
Shreyas_kumar_m
NORMAL
2024-12-28T17:00:51.872722+00:00
2024-12-28T17:00:51.872722+00:00
21
false
# Code ```javascript [] /** * @param {number[]} nums * @return {number} */ var countMaxOrSubsets = function(nums) { let maxOr = 0; let count =0; for(let i=0;i<nums.length;i++){ maxOr |=nums[i]; } for(let i=1;i<(1<<nums.length);i++){ let curr = 0; for(let j=0;j<nums.length...
1
0
['JavaScript']
0
count-number-of-maximum-bitwise-or-subsets
Solution with hashmap beats 99.80%. Detailed explanation
solution-with-hashmap-beats-9980-detaile-iovz
Intuition\n Describe your first thoughts on how to solve this problem. \nWe will use dynamic programming approach with hashmaps to solve the problem.\n\nFirst s
MaxEtzo
NORMAL
2024-10-20T16:29:38.245588+00:00
2024-10-20T16:31:15.479011+00:00
9
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe will use dynamic programming approach with hashmaps to solve the problem.\n\nFirst sub-problem is to generate all subsets. To do that we start with an empty subset. Then we iterate through ```nums``` and generate new subsets with any g...
1
0
['Hash Table', 'Dynamic Programming', 'Python3']
0
count-number-of-maximum-bitwise-or-subsets
Using Recursion.
using-recursion-by-sa_hilll94-wemy
\n# Approach\n Describe your approach to solving the problem. \n1. Find the maxOR by performing OR operation over all the elements of nums[i]\n2. Use recursion
sa_hilll94
NORMAL
2024-10-19T19:24:08.136944+00:00
2024-10-19T19:39:25.581165+00:00
11
false
\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Find the `maxOR` by performing OR operation over all the elements of `nums[i]`\n2. Use recursion to find the subsets and then perform OR with the element.\n3. At base case, compare it with maxOR.\n\n# Complexity\n- Time complexity:$$O(2^n)$$ \n`a...
1
0
['Recursion', 'C++']
0
count-number-of-maximum-bitwise-or-subsets
Solution (5ms)
solution-5ms-by-phantom2097-w8rv
\n\n\n# Complexity\n- Time complexity:\nO(2^n)\n\n- Space complexity:\nO(n)\n\n# Code\nkotlin []\nclass Solution {\n fun countMaxOrSubsets(nums: IntArray): I
Phantom2097
NORMAL
2024-10-19T10:45:04.185353+00:00
2024-10-19T10:45:04.185378+00:00
5
false
![\u0421\u043D\u0438\u043C\u043E\u043A \u044D\u043A\u0440\u0430\u043D\u0430 2024-10-19 134318.png](https://assets.leetcode.com/users/images/b368b1a0-4b05-4b21-9417-2404a353fcbf_1729334622.9553323.png)\n\n\n# Complexity\n- Time complexity:\n$$O(2^n)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```kotlin []\nclass Solut...
1
0
['Kotlin']
0
robot-collisions
✅💯🔥Explanations No One Will Give You🎓🧠Very Detailed Approach🎯🔥Extremely Simple And Effective🔥
explanations-no-one-will-give-youvery-de-kmf1
\n \n \n You\u2019ve got to get up every morning with determination if you\u2019re going to go to bed with satisfaction.\n
heir-of-god
NORMAL
2024-07-13T05:24:40.769111+00:00
2024-07-13T05:52:35.596152+00:00
27,138
false
<blockquote>\n <p>\n <b>\n You\u2019ve got to get up every morning with determination if you\u2019re going to go to bed with satisfaction.\n </b> \n </p>\n <p>\n --- George Lorimer ---\n </p>\n</blockquote>\n\n# \uD83D\uDC51Problem Expla...
221
5
['Array', 'Stack', 'C', 'Sorting', 'Simulation', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']
16
robot-collisions
✅Beats 100% -Explained with [ Video ] -C++/Java/Python/JS - Sorting - O( n log n) - Explained
beats-100-explained-with-video-cjavapyth-cky0
\n\n\n\n# YouTube Video Explanation:\n\n### To watch the video please click on "Watch On Youtube" option available the left bottom corner of the thumbnail.\n\n
lancertech6
NORMAL
2024-07-13T03:39:17.270441+00:00
2024-07-13T06:44:23.666841+00:00
14,073
false
![Screenshot 2024-07-13 090031.png](https://assets.leetcode.com/users/images/d3206d04-1bc9-4527-8bd0-a51cbc712938_1720841908.0593297.png)\n\n\n\n# YouTube Video Explanation:\n\n### To watch the video please click on "Watch On Youtube" option available the left bottom corner of the thumbnail.\n\n<!-- **If you want a vi...
96
5
['Array', 'Stack', 'Sorting', 'Simulation', 'Python', 'C++', 'Java', 'JavaScript']
10
robot-collisions
[Java/C++/Python] Stack Soluton
javacpython-stack-soluton-by-lee215-984k
Explanation\nNeed to sort all robots index ind (from 0 to n - 1),\nsort them by their positions first.\n\nUse a stack to keep all the robot moving to right.\nNo
lee215
NORMAL
2023-06-25T04:02:51.136884+00:00
2023-06-25T04:02:51.136920+00:00
5,639
false
# **Explanation**\nNeed to sort all robots index `ind` (from `0` to `n - 1`),\nsort them by their `positions` first.\n\nUse a `stack` to keep all the robot moving to right.\nNow we iterate robots one by one,\n\nIf it\'s moving to right,\nwon\'t collide with robots in the `stack`.\n\nIf it\'s moving to left,\ncompare it...
78
0
['C', 'Python', 'Java']
11
robot-collisions
C++ Detailed Approach Using Stack || Sorting
c-detailed-approach-using-stack-sorting-f1lxt
\n# Approach\n\nInside the function, a struct named Robot is defined, which has four members: position, health, direction, and index. This struct represents the
Aditya00
NORMAL
2023-06-25T04:45:01.152987+00:00
2023-07-03T12:34:53.664993+00:00
6,872
false
\n# Approach\n\nInside the function, a struct named Robot is defined, which has four members: position, health, direction, and index. This struct represents the properties of a robot.\n\nThe function begins by initializing a vector of Robot structs called vals. Each struct is created using the corresponding elements fr...
70
1
['Stack', 'Sorting', 'Python', 'C++']
6
robot-collisions
💯✅🔥Detailed Easy Java ,Python3 ,C++ Solution|| 42 ms ||≧◠‿◠≦✌
detailed-easy-java-python3-c-solution-42-yy8w
Approach\n\nThe approach used in the provided code is as follows:\n\n1. Create a Robot struct/class to store the robot\'s position, health, direction, and index
suyalneeraj09
NORMAL
2024-07-13T02:06:56.028752+00:00
2024-07-13T02:09:36.224831+00:00
5,863
false
## Approach\n\nThe approach used in the provided code is as follows:\n\n1. Create a `Robot` struct/class to store the robot\'s position, health, direction, and index.\n2. Create a vector/list of `Robot` objects and populate it with the given positions, healths, and directions.\n3. Sort the `Robot` vector/list based on ...
43
3
['Array', 'Stack', 'C++', 'Java', 'Python3']
14
robot-collisions
Beats 97% users.... Trust this editorial solution....
beats-97-users-trust-this-editorial-solu-y12g
\n\n# Code\n\nclass Solution:\n\n def survivedRobotsHealths(\n\n self, positions: List[int], healths: List[int], directions: str\n\n ) -> List[int]
Aim_High_212
NORMAL
2024-07-13T03:31:21.774230+00:00
2024-07-13T03:31:21.774257+00:00
170
false
\n\n# Code\n```\nclass Solution:\n\n def survivedRobotsHealths(\n\n self, positions: List[int], healths: List[int], directions: str\n\n ) -> List[int]:\n\n n = len(positions)\n\n indices = list(range(n))\n\n result = []\n\n stack = deque()\n\n # Sort indices based on thei...
29
0
['Array', 'Stack', 'C', 'Sorting', 'Simulation', 'C++', 'Java', 'Python3', 'JavaScript']
1
robot-collisions
CPP | Sorting | Stack
cpp-sorting-stack-by-amirkpatna-3272
Intuition\n Describe your first thoughts on how to solve this problem. \nInitially I did not thought that positions are not sorted hence got 1 wa.\nThen sorted
amirkpatna
NORMAL
2023-06-25T04:01:14.289254+00:00
2023-06-25T04:03:00.482671+00:00
3,478
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nInitially I did not thought that positions are not sorted hence got 1 wa.\nThen sorted according to postions and used stack to solve this problem.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- If a robot is goi...
25
1
['Stack', 'Sorting', 'C++']
5
robot-collisions
Sort (position, index) &Use vector as stack|96ms Beats 100%
sort-position-index-use-vector-as-stack9-3igc
Intuition\n Describe your first thoughts on how to solve this problem. \nVery similar to the problem Leetcode 735. Asteroid Collision\n# Approach\n Describe you
anwendeng
NORMAL
2024-07-13T01:39:23.050145+00:00
2024-07-13T10:17:11.614358+00:00
3,376
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nVery similar to the problem [Leetcode 735. Asteroid Collision](https://leetcode.com/problems/asteroid-collision/solutions/3789944/c-stack-vs-vector-python-list/)\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Bui...
21
0
['Array', 'Stack', 'Sorting', 'Simulation', 'C++']
11
robot-collisions
Solution using stack in C++, Java & Python
solution-using-stack-in-c-java-python-by-bk1b
Intuition\nSort the robot by positions. Scan all robots from left to right. The key point is that all robots are moving with the same speed, so if they move to
cpcs
NORMAL
2023-06-25T12:55:12.089745+00:00
2023-07-08T18:03:07.155443+00:00
1,934
false
# Intuition\nSort the robot by positions. Scan all robots from left to right. The key point is that all robots are moving with the same speed, so if they move to the same direction they will never collide. And if they move to the different position, say a robot is moving to the left, then it collide with the ones movin...
20
0
['Python', 'C++', 'Java', 'Python3']
4
robot-collisions
✅🚀 🔥 || Beats 100% || || Java, Python, C++, JS, Go || Beginner Friendly🔥✨🌟
beats-100-java-python-c-js-go-beginner-f-tpym
\n\n# Intuition\n\n\nThe problem involves simulating collisions between robots moving on a line. The key insights are:\n\n1. Collisions only occur between robot
kartikdevsharma_
NORMAL
2024-07-13T04:16:36.274814+00:00
2024-08-24T04:42:41.614600+00:00
300
false
\n\n# Intuition\n\n\nThe problem involves simulating collisions between robots moving on a line. The key insights are:\n\n1. Collisions only occur between robots moving towards each other (one moving left, one moving right).\n2. The order of collisions matters, so we need to process them in the correct sequence.\n3. We...
13
0
['Array', 'Stack', 'Sorting', 'Simulation', 'C++', 'Java', 'Go', 'Python3', 'JavaScript']
2
robot-collisions
[C++, Java, Python] With Visuals | Stack | Sorting | Asteroid Collision
c-java-python-with-visuals-stack-sorting-vh3t
This problem has been asked in Atlassian OA for Intern 2023.\nVery similar to 735. Asteroid Collision\n\n\n# Intuition\nAssume we sort robots by their initial p
shivamaggarwal513
NORMAL
2023-06-25T04:03:45.455325+00:00
2023-06-26T10:47:13.920714+00:00
1,983
false
This problem has been asked in Atlassian OA for Intern 2023.\nVery similar to [735. Asteroid Collision\n](https://leetcode.com/problems/asteroid-collision/)\n\n# Intuition\nAssume we sort robots by their initial positions. Then, we traverse robots from left to right positions.\n\nLet\'s try few cases\n- First robot goe...
13
0
['Stack', 'Sorting', 'C++', 'Java', 'Python3']
4
robot-collisions
Stack
stack-by-votrubac-o2i4
We process robots left-to-right, so we sort them first.\n\nIf a robot goes right, we add it to the stack.\n \nIf a robot goes left, we colide it with the rob
votrubac
NORMAL
2023-06-25T04:02:55.873243+00:00
2023-06-25T05:43:45.178756+00:00
1,463
false
We process robots left-to-right, so we sort them first.\n\nIf a robot goes right, we add it to the stack.\n \nIf a robot goes left, we colide it with the robot on top of the stack:\n- If the health of the robot on top of the stack is lower:\n\t- We set its health to zero.\n\t- We remove it from the stack and decreme...
12
0
[]
3
robot-collisions
Collapse a linked list | Simple simulation approach with explanation ✅
collapse-a-linked-list-simple-simulation-bumv
Intuition\nThe first thing that comes to mind is that if we could run a simulation of the scenario, it would be easy to get the survivors. In an analog setup, s
reas0ner
NORMAL
2024-07-13T12:23:45.337329+00:00
2024-07-13T13:42:02.910923+00:00
368
false
# Intuition\nThe first thing that comes to mind is that if we could run a simulation of the scenario, it would be easy to get the survivors. In an analog setup, simulating this kind of scenario is often easy, but programmatically this might need a lot of updates to each robot in a loop, like a game loop. So, a pure sim...
11
1
['Linked List', 'Stack', 'Greedy', 'Python3']
0
robot-collisions
Stack implementation based on the index of the Robot.
stack-implementation-based-on-the-index-irco1
Intuition\nTo solve this problem, we need to simulate the movement and interactions of robots based on their positions, healths, and directions. We can use a st
TACK_05
NORMAL
2024-07-13T09:07:55.730318+00:00
2024-07-13T09:07:55.730349+00:00
1,097
false
# Intuition\nTo solve this problem, we need to simulate the movement and interactions of robots based on their positions, healths, and directions. We can use a stack to keep track of robots that are moving right (\'R\') and handle collisions with robots moving left (\'L\') as we iterate through the sorted list of posit...
11
0
['C++']
8
robot-collisions
Stack Implementation | Easy to understand
stack-implementation-easy-to-understand-tt41b
Intuition\nStart iteration from the leftmost position and encounter what\'s next.\n\n# Approach\n--> Create a vector of tuple to club the positions, healths and
Sparker_7242
NORMAL
2024-07-13T18:12:56.734041+00:00
2024-07-13T18:12:56.734063+00:00
96
false
# Intuition\nStart iteration from the leftmost position and encounter what\'s next.\n\n# Approach\n--> Create a vector of tuple to club the positions, healths and directions.\n--> Sort the vector to get the robots in order (left to right).\n\n--> Initialise a stack to keep the track of **health and positions** of the l...
9
0
['Stack', 'C++']
3
robot-collisions
Python | Simulation with Stack
python-simulation-with-stack-by-khosiyat-idd4
see the Successfully Accepted Submission\n\n# Code\n\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions:
Khosiyat
NORMAL
2024-07-13T07:38:52.791142+00:00
2024-07-13T07:38:52.791164+00:00
407
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/robot-collisions/submissions/1319423677/?envType=daily-question&envId=2024-07-13)\n\n# Code\n```\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n # Combine posi...
7
0
['Python3']
2
robot-collisions
Python 3 || 15 lines, duples, no zip ||
python-3-15-lines-duples-no-zip-by-spaul-l8bs
This code is pretty much the standard stack solution used by most on this problem, with the addition of two variations.\n\n1. We code the direction intohealths;
Spaulding_
NORMAL
2023-06-26T17:21:21.553249+00:00
2024-07-13T06:52:26.559218+00:00
341
false
This code is pretty much the standard stack solution used by most on this problem, with the addition of two variations.\n\n1. We code the direction into`healths`; `\'L\'`-> change to negative, `\'R\'`-> leave as positive.\n\n1. We use`positions`as the sort key.\n\nAs a result, we only need`idx`and`hth` as a two-tuple (...
7
1
['Python3']
1
robot-collisions
[Java/Python 3] Check 'RL' after sorting by positions, w/ brief explanation and analysis.
javapython-3-check-rl-after-sorting-by-p-rima
Sort the indices of healths by positions;\n2. Traverse the sorted indices and check if the index on the top of the stack (survivors) corresponds to the directio
rock
NORMAL
2023-06-25T04:01:57.659455+00:00
2023-06-25T18:53:37.378783+00:00
1,162
false
1. Sort the indices of `healths` by `positions`;\n2. Traverse the sorted indices and check if the index on the top of the stack (`survivors`) corresponds to the direction `R` and current direction is `L`, then process according to the problem definition;\n3. return the health value still in the stack (`survivors`) sort...
7
0
['Stack', 'Sorting', 'Java', 'Python3']
6
robot-collisions
Clean solution ✅|| Vector pair and stack implementation🔥^_^ || ©️cpp ✅
clean-solution-vector-pair-and-stack-imp-yw5w
Intuition\n Describe your first thoughts on how to solve this problem. \nThe only thought that came to my mind on seeing this problem is that i need to compare
parijatb_03
NORMAL
2024-07-13T12:39:09.520393+00:00
2024-07-13T12:39:09.520425+00:00
268
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n*The only thought that came to my mind on seeing this problem is that i need to compare the healths of only those conditions where the event of collision arises else we dont need to think of doing anything except for keep on storing the n...
6
0
['C++']
2
robot-collisions
💯✅🔥🤐NO STACK && bruteforce has time complexity O(nlogn) and space complexity O(n)
no-stack-bruteforce-has-time-complexity-d56ha
Intuition\n Describe your first thoughts on how to solve this problem. \n\nNote:position value is not significant but positional order is significant for this q
sameonall
NORMAL
2024-07-13T06:56:59.241616+00:00
2024-07-13T20:40:59.671998+00:00
503
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n**Note**:position value is not significant but positional order is significant for this question as speed is same.Suggestion-Try to think urself!!\n**Note**:Concept of collision-segments when speed is same.\n**Collision-segments**-> mea...
6
0
['Array', 'Hash Table', 'Stack', 'C', 'Sorting', 'Simulation', 'Python', 'C++', 'Ruby', 'JavaScript']
3
robot-collisions
Stack. Simple and clear solution
stack-simple-and-clear-solution-by-xxxxk-b37u
\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n stack = []\n for
xxxxkav
NORMAL
2024-07-13T01:04:20.668883+00:00
2024-07-13T01:05:39.350046+00:00
772
false
```\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n stack = []\n for i in sorted(range(len(positions)), key = lambda i: positions[i]):\n if directions[i] == \'R\':\n stack.append(i)\n else...
6
0
['Stack', 'Python3']
4
robot-collisions
✅Easy Solution ✅ Using Sorting & Stack ✅ C++ ✅Beginner Friendly🔥🔥🔥
easy-solution-using-sorting-stack-c-begi-mvvv
Approach:\n\n If a robot is moving to the left and the stack is empty, it means there is no robot to stop the current robot. Therefore, the current robot surviv
anti_quark
NORMAL
2023-06-25T05:04:22.005304+00:00
2023-06-25T05:27:41.337970+00:00
325
false
**Approach:**\n\n* If a robot is moving to the left and the stack is empty, it means there is no robot to stop the current robot. Therefore, the current robot survives.\n* If a robot is moving to the right, simply push it into the stack.\n* If a robot is moving to the left and the stack is not empty:\n* Compare the hea...
6
0
['Stack', 'Sorting', 'C++']
1
robot-collisions
Java Clean Solution | Daily Challenges
java-clean-solution-daily-challenges-by-ddc6y
Complexity\n- Time complexity:O(n*K)\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# Co
Shree_Govind_Jee
NORMAL
2024-07-13T04:29:52.525436+00:00
2024-07-13T04:29:52.525458+00:00
786
false
# Complexity\n- Time complexity:$$O(n*K)$$\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 public List<Integer> survivedRobotsHealths(int[] positions,\n int[] healths, String di...
5
0
['Array', 'Stack', 'Sorting', 'Simulation', 'Combinatorics', 'Java']
1
robot-collisions
Sorting + stack | very straight forward approach | With vid explantion
sorting-stack-very-straight-forward-appr-reuy
Watch in 2x to save your time\nhttps://youtu.be/htvW2qSuwVI\n\n# Intuition\n Describe your first thoughts on how to solve this problem. \n- We need to simulate
Atharav_s
NORMAL
2024-07-13T02:55:41.062572+00:00
2024-07-13T02:55:41.062603+00:00
1,120
false
Watch in 2x to save your time\nhttps://youtu.be/htvW2qSuwVI\n\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- We need to simulate the movement and collisions of robots.\n- Sorting the robots by their positions can help efficiently handle collisions.\n- Using a stack to keep track of...
5
0
['C++']
4
robot-collisions
stack || Brute force sol with comments
stack-brute-force-sol-with-comments-by-h-mi5s
Intuition\n##### Check the condition of collide , if there is collision remove robot with min health \n\n\n---\n\n\n\n# Approach\n\n###### First we arrange the
harsh_0412
NORMAL
2023-06-25T04:02:08.880463+00:00
2023-06-25T05:00:16.829599+00:00
1,728
false
# Intuition\n##### Check the condition of collide , if there is collision remove robot with min health \n\n\n---\n\n\n\n# Approach\n\n###### First we arrange the robots in ascending order of their pos , after that we start from left side and check the direction of cur robot , now check the condition of collision , i...
5
0
['Array', 'Stack', 'Sorting', 'C++']
2
robot-collisions
✅C++ | For Beginners | Sorting | STACK | Brute Force
c-for-beginners-sorting-stack-brute-forc-sqqu
\n# Code\n\nclass Solution {\npublic:\n struct robot{\n int pos, heal, idx;\n char dir;\n };\n \n static bool mySort(robot r1, robot r
pkacb
NORMAL
2023-06-25T04:01:44.355251+00:00
2023-06-25T04:11:10.251889+00:00
182
false
\n# Code\n```\nclass Solution {\npublic:\n struct robot{\n int pos, heal, idx;\n char dir;\n };\n \n static bool mySort(robot r1, robot r2){\n return r1.pos < r2.pos;\n }\n static bool myComp(robot r1, robot r2){\n return r1.idx < r2.idx;\n }\n\n \n vector<int> sur...
5
0
['Stack', 'Sorting', 'C++']
1
robot-collisions
Optimized Collision Handling for Neighbouring Robots, 100% beats Simple Solution
optimized-collision-handling-for-neighbo-niiy
Beats\n\n\n# Intuition\nTwo neighbour robots will always collide if their directions are different, We can see a pattern here that we have to start with left mo
sxnchayyyy
NORMAL
2024-07-13T07:24:36.694229+00:00
2024-07-13T07:24:36.694251+00:00
226
false
# Beats\n![Screenshot 2024-07-13 123523.png](https://assets.leetcode.com/users/images/e017a382-691e-442a-87ee-4654bcbc05b9_1720855160.837885.png)\n\n# Intuition\nTwo neighbour robots will always collide if their directions are different, We can see a pattern here that we have to start with left most position in sorted ...
4
0
['C++']
4
robot-collisions
Beats 98% , pehle istemal kare fir vishwash kare 👌
beats-98-pehle-istemal-kare-fir-vishwash-kgn8
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
adarshydv
NORMAL
2024-07-13T04:03:53.475746+00:00
2024-07-13T04:03:53.475775+00:00
557
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)$$ --...
4
1
['C++']
6
robot-collisions
NO stack; Is this CLEAN code?
no-stack-is-this-clean-code-by-navid-jtm9
Describe your first thoughts on how to solve this problem. \n\n# Intuition\n\nWe put all robots in their positions. Then start from the left (lowest position).
navid
NORMAL
2023-06-25T08:53:09.686338+00:00
2023-06-25T09:30:38.882976+00:00
657
false
![robo-fight.jpg](https://assets.leetcode.com/users/images/9e66d9c9-0625-4cdf-b957-8d1561a26b34_1687681164.2591827.jpeg)<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Intuition\n\nWe put all robots in their positions. Then start from the left (lowest position). We keep moving forward (to the r...
4
0
['Tree', 'Binary Search Tree', 'Sorting', 'Java']
1
robot-collisions
C++ || sorting || stack || simple solution
c-sorting-stack-simple-solution-by-its_n-vp1z
\n\n# Code\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& pos, vector<int>& h, string d) {\n \n \n vecto
its_navneet
NORMAL
2023-06-25T04:04:57.145218+00:00
2023-06-25T08:11:33.338473+00:00
1,197
false
\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& pos, vector<int>& h, string d) {\n \n \n vector<pair<int,int>>vp ;\n int n=pos.size() ;\n for(int i=0;i<n;i++) {\n \n vp.push_back({pos[i],i}) ;\n }\n ...
4
0
['C++']
2
robot-collisions
🔥LITTLE BIT COMPLEX CODE in C++🔥||🔥stack🔥
little-bit-complex-code-in-cstack-by-gan-2ldt
if this code helps you, please upvote that\'s helps to me.\n# Code\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, v
ganeshkumawat8740
NORMAL
2023-06-25T04:03:18.567461+00:00
2023-06-25T04:15:06.437183+00:00
377
false
# if this code helps you, please upvote that\'s helps to me.\n# Code\n```\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<vector<int>> tmp;\n for(int i = 0; i < positions.size(); i++){\n tmp.push_back(...
4
1
['Array', 'Stack', 'C++']
1
robot-collisions
Simple Java Code ☠️
simple-java-code-by-abhinandannaik1717-qblj
\n\n# Code\n\nclass Solution {\n public List<Integer> survivedRobotsHealths(int[] positions, int[] healths, String directions) {\n int n = positions.l
abhinandannaik1717
NORMAL
2024-07-13T14:04:20.587356+00:00
2024-07-13T14:04:20.587390+00:00
178
false
\n\n# Code\n```\nclass Solution {\n public List<Integer> survivedRobotsHealths(int[] positions, int[] healths, String directions) {\n int n = positions.length;\n int l=0,r=0;\n ArrayList<Integer> ans = new ArrayList<Integer>();\n for(int i=0;i<n;i++){\n if(directions.charAt(i)=...
3
0
['Array', 'Sorting', 'Simulation', 'Java']
0
robot-collisions
Hassle-free method..
hassle-free-method-by-nehasinghal032415-0t5s
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
NehaSinghal032415
NORMAL
2024-07-13T12:26:41.417521+00:00
2024-07-13T12:26:41.417553+00:00
87
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(2N) --->Where N is total number of robots....\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(2N) --...
3
0
['Array', 'String', 'Stack', 'Sorting', 'Java']
1
robot-collisions
Using stack
using-stack-by-akshita_12-2oda
Intuition\n Describe your first thoughts on how to solve this problem. \nTo solve this problem, we need to simulate the collisions between robots moving in oppo
akshita_12
NORMAL
2024-07-13T10:57:34.289486+00:00
2024-07-13T10:57:34.289530+00:00
30
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nTo solve this problem, we need to simulate the collisions between robots moving in opposite directions. By sorting the robots based on their positions, we can manage their interactions using a stack to keep track of robots moving to the r...
3
0
['C++']
0
robot-collisions
Easiest explanation on leetcode(completely brute force && Totally explained)
easiest-explanation-on-leetcodecompletel-2n4y
Intuition\n1.so the question robots collide when the faces of robot are toward each other means (-> <-) \n2.so we have to keep track of theh faces and keep note
Ajay-Adhikari
NORMAL
2024-07-13T04:59:21.765028+00:00
2024-07-13T04:59:21.765063+00:00
375
false
# Intuition\n1.so the question robots collide when the faces of robot are toward each other means (-> <-) \n2.so we have to keep track of theh faces and keep note that we have to return our result as in the order of input is given \n3. we have to take care when robot is left facing then chechk the previous robot face ....
3
0
['C++']
6
robot-collisions
🌟💫Best Easy understandable Python3 solution 🌟🌟❤️‍🔥❤️‍🔥🔥🔥Explained by line...!!
best-easy-understandable-python3-solutio-1b5r
Intuition\n Describe your first thoughts on how to solve this problem. \nThe main idea is to simulate the robot collisions based on their positions and directio
A206k
NORMAL
2024-07-13T04:11:09.070246+00:00
2024-07-13T04:11:09.070267+00:00
204
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe main idea is to simulate the robot collisions based on their positions and directions. By using a stack, we can efficiently handle the robots moving to the right and the left, and resolve their interactions accordingly.\n\n# Approach\...
3
0
['Stack', 'Sorting', 'Simulation', 'Python3']
1
robot-collisions
Swift | Stack and Simulation
swift-stack-and-simulation-by-pagafan7as-j12a
Code\n\nclass Solution {\n func survivedRobotsHealths(_ positions: [Int], _ healths: [Int], _ directions: String) -> [Int] {\n var stack = [Int]()\n
pagafan7as
NORMAL
2024-07-13T01:38:44.428807+00:00
2024-07-13T05:07:42.618142+00:00
52
false
# Code\n```\nclass Solution {\n func survivedRobotsHealths(_ positions: [Int], _ healths: [Int], _ directions: String) -> [Int] {\n var stack = [Int]()\n let directions = Array(directions)\n var healths = healths\n\n // Sort robots by increasing position.\n var robots = positions.i...
3
0
['Swift']
2
robot-collisions
[Go] Stack
go-stack-by-joeblack5451-p8qn
Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n\nfunc survivedRobotsHealths(positions []int, healths []int, directions string)
joeblack5451
NORMAL
2024-07-13T00:54:50.943436+00:00
2024-07-13T00:54:50.943468+00:00
184
false
# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nfunc survivedRobotsHealths(positions []int, healths []int, directions string) []int {\n robots := make(map[int][]int)\n for i, position := range positions {\n direction := 1\n if directions[i] == \'L\' { ...
3
0
['Stack', 'Go']
0
robot-collisions
Intuitive Solution, Faster than 100%
intuitive-solution-faster-than-100-by-ni-w5i8
Intuition\n Describe your first thoughts on how to solve this problem. \nAfter reading the problem, I thought it was very similar to the Aestroid Collision Prob
nikhilpujar23
NORMAL
2023-06-25T04:34:46.606637+00:00
2023-06-25T04:34:46.606662+00:00
331
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAfter reading the problem, I thought it was very similar to the Aestroid Collision Problem.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n**Steps:**\n1. Convert the question into Aestroid Collision. In that questio...
3
0
['Stack', 'Greedy', 'Monotonic Stack', 'C++']
1
robot-collisions
java solution using stack and sorting
java-solution-using-stack-and-sorting-by-uu1w
\nclass Solution {\n class Pair{\n int p;\n int h;\n char d;\n int idx;\n Pair(int p,int h,char d,int i){\n thi
akash0228
NORMAL
2023-06-25T04:07:42.879792+00:00
2023-06-25T04:07:42.879814+00:00
346
false
```\nclass Solution {\n class Pair{\n int p;\n int h;\n char d;\n int idx;\n Pair(int p,int h,char d,int i){\n this.p=p;\n this.h=h;\n this.d=d;\n this.idx=i;\n }\n }\n public List<Integer> survivedRobotsHealths(int[] positio...
3
0
['Stack', 'Sorting', 'Java']
1
robot-collisions
Easy C++ solution || Stack
easy-c-solution-stack-by-ankitkr23-7cox
\n\n# Code\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vecto
ankitkr23
NORMAL
2023-06-25T04:03:26.342828+00:00
2023-06-25T04:06:36.042680+00:00
207
false
\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n vector<pair<int, int>>v;\n int n=positions.size();\n for(int i=0; i<n; i++){\n v.push_back({positions[i], i});\n }\n sort(v...
3
0
['C++']
1
robot-collisions
Java (nlogn) Solution using Deque
java-nlogn-solution-using-deque-by-shash-d96c
Approach:\n- Create an 2d list with all valued combined and also maintain the index in original array\n- Sort the list based on position\n- Start from index 0,
shashankbhat
NORMAL
2023-06-25T04:02:48.303378+00:00
2023-06-25T04:08:29.734968+00:00
167
false
# Approach:\n- Create an 2d list with all valued combined and also maintain the index in original array\n- Sort the list based on position\n- Start from index 0, and check for each robot.\n - For first robot, insert into deque\n - For other robots, if direction is left, check in loop for last elements in deque for an...
3
0
['Array', 'Java']
1
robot-collisions
Priority Queue || Intuitive Soln || Easy Explanation || C++
priority-queue-intuitive-soln-easy-expla-98jz
Intuition\nWe divide all the robots into two types namely -\n\n1. Robots Going Left (save them all in a set)\n2. Robots going right( put them all in a priority
prasoonrajpoot
NORMAL
2023-06-25T04:01:36.978202+00:00
2023-06-25T04:11:24.526705+00:00
331
false
# Intuition\nWe divide all the robots into two types namely -\n\n1. Robots Going Left (save them all in a set)\n2. Robots going right( put them all in a priority queue)\n\n# Approach\nAs we can see both of them as ordered containers means sorted in some manner\n\nnow when comparing these two structure simultaneously we...
3
0
['C++']
1
robot-collisions
🔥Stack-Based Solution: Sort, keeping track of index (C++). Beats: 70% ✅ Runtime 60% ✅ memory🔥
stack-based-solution-sort-keeping-track-hu75f
\n\n# Intuition\nThe problem requires finding the remaining robot healts after collitions. The main key here is that a collision can occur only if right followe
Sithaarth_Maheshwaran
NORMAL
2024-07-14T14:09:10.878200+00:00
2024-07-14T15:28:18.967186+00:00
8
false
![Screenshot 2024-07-14 192732.png](https://assets.leetcode.com/users/images/b8e6986e-679a-4d2a-9278-74fb318bb34e_1720966804.1031845.png)\n\n# Intuition\nThe problem requires finding the remaining robot healts after collitions. The main key here is that a collision can occur only if right followed by left moving robots...
2
0
['Stack', 'Sorting', 'C++']
1
robot-collisions
SUPER EASY 💪🔥✨
super-easy-by-codewithsparsh-68l8
Intuition\nTo solve this problem, we need to simulate the movements and collisions of robots on a line. The key is to handle the collisions efficiently, ensurin
CodeWithSparsh
NORMAL
2024-07-14T05:08:28.309623+00:00
2024-07-14T05:08:28.309651+00:00
8
false
# Intuition\nTo solve this problem, we need to simulate the movements and collisions of robots on a line. The key is to handle the collisions efficiently, ensuring that we update the health of robots correctly and determine the survivors after all possible collisions have occurred.\n\n# Approach\n1. **Representation**:...
2
1
['Dart']
0
robot-collisions
Python Solution Beats 28% 🥶🥶🥶🔥🔥
python-solution-beats-28-by-snah0902-aewq
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
snah0902
NORMAL
2024-07-14T01:23:06.451858+00:00
2024-07-14T01:23:06.451886+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)$$ --...
2
0
['Python3']
1
robot-collisions
Python3 || 2 class solution || O(n log n)
python3-2-class-solution-on-log-n-by-fol-0mku
Approach\nCreate class Robot for storing robots with their characteristics. Use array robots_init to store initial positions of robots for answer. Use stack: if
followvinya
NORMAL
2024-07-13T20:28:27.827723+00:00
2024-07-13T20:29:58.336759+00:00
15
false
# Approach\nCreate class Robot for storing robots with their characteristics. Use array robots_init to store initial positions of robots for answer. Use stack: if current element is bigger than previous -> pop previous and continue checking in while cycle until previous element will be of same direction or stack ends; ...
2
0
['Python3']
0
robot-collisions
🔥🔥Beats 95.80% 🔥🔥| Easy to understand C++ solution ✅✅ | Stack + Simulation ✅✅
beats-9580-easy-to-understand-c-solution-z7gj
\n\n---\n\n# Intuition\nThe problem requires simulating the movement and collision of robots moving in opposite directions on a line. The key insight is to effi
its_kartike
NORMAL
2024-07-13T19:44:56.163656+00:00
2024-07-13T19:44:56.163680+00:00
5
false
![image.png](https://assets.leetcode.com/users/images/89269bee-5130-4b5c-a50d-4cc4213133bb_1720898892.6253111.png)\n\n---\n\n# Intuition\nThe problem requires simulating the movement and collision of robots moving in opposite directions on a line. The key insight is to efficiently handle the collision of robots and det...
2
0
['Array', 'Stack', 'Sorting', 'Simulation', 'C++']
0
robot-collisions
Easy to understand || C++ || O(n log n) || Stack, Vector, Map
easy-to-understand-c-on-log-n-stack-vect-w7ig
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
Manral_0203
NORMAL
2024-07-13T19:11:18.681460+00:00
2024-07-13T19:11:18.681482+00:00
11
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\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', 'Stack', 'Sorting', 'C++']
0
robot-collisions
A C Solution
a-c-solution-by-well_seasoned_vegetable-01re
Code\n\nstruct data {\n int position;\n int health;\n char direction;\n int idx;\n};\n\nint cmp(const void* a, const void* b) {\n return ((struct
well_seasoned_vegetable
NORMAL
2024-07-13T15:40:30.816911+00:00
2024-07-14T12:22:04.530312+00:00
28
false
# Code\n```\nstruct data {\n int position;\n int health;\n char direction;\n int idx;\n};\n\nint cmp(const void* a, const void* b) {\n return ((struct data*)a)->position - ((struct data*)b)->position;\n}\n\nint* survivedRobotsHealths(int* positions, int positionsSize, int* healths, int healthsSize, char ...
2
0
['C']
0
robot-collisions
IN DEPTH SOUTION || JAVA || Stack.
in-depth-soution-java-stack-by-abhishekk-ap37
Thanks @mikey.\n# Guys UPVOTE IF U LIKED THE EXPLANATION.\n\n# Breakdown:\n\n1. Input and Initialization:\n - positions: An integer array storing the initial
Abhishekkant135
NORMAL
2024-07-13T15:03:17.423331+00:00
2024-07-13T15:03:17.423370+00:00
82
false
Thanks @mikey.\n# Guys UPVOTE IF U LIKED THE EXPLANATION.\n\n# **Breakdown:**\n\n1. **Input and Initialization:**\n - `positions`: An integer array storing the initial positions of the robots (circular arena).\n - `healths`: An integer array storing the initial health of each robot.\n - `directions`: A String rep...
2
0
['Array', 'Stack', 'Java']
0
robot-collisions
Solution using Stack
solution-using-stack-by-salman_md-2m1m
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
salman_md_
NORMAL
2024-07-13T11:24:01.232186+00:00
2024-07-13T11:24:01.232217+00:00
128
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....
2
0
['C++']
1
robot-collisions
[✅🧠 FULLY EASY EXPLAINED STACK O(N log N) Approach C++]
fully-easy-explained-stack-on-log-n-appr-p97u
This question is all about just observation. Observation: The only possible collision is when there is a sequence of directions as: "RL" as the first robot is m
o1154
NORMAL
2024-07-13T09:42:34.134302+00:00
2024-07-13T09:42:34.134343+00:00
90
false
This question is all about just observation. Observation: The only possible collision is when there is a sequence of directions as: "RL" as the first robot is moving towards right and second is moving towards left **(GIVEN THAT THEY ARE SORTED ACCORDING TO THEIR POSITIONS LIKE FOR THE \'R\' IF THE POSITION IS SOME X TH...
2
0
['Stack', 'Greedy', 'C', 'Sorting', 'JavaScript']
2
robot-collisions
Easiest Stack Solution -- SORT -- Commented
easiest-stack-solution-sort-commented-by-n6uq
Intuition\n Describe your first thoughts on how to solve this problem. \nStep 1 : Sort according to positions in asceding irder\nStep 2 : Use stack to store sta
Skaezr73
NORMAL
2024-07-13T08:37:51.369845+00:00
2024-07-13T09:33:23.241389+00:00
119
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n<b>Step 1 :</b> Sort according to positions in asceding irder\n<b>Step 2 :</b> Use stack to store state of each robot\n<b>Step 3 :</b> If ***current*** robot has direction to **"RIGHT"** just push it \n<b>Step 4 :</b> Else use the follow...
2
0
['C++']
0
robot-collisions
Python Solution
python-solution-by-mouad_haikal-adab
\n\n# Code\n\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n robots = so
Mouad_Haikal
NORMAL
2024-07-13T08:26:09.973940+00:00
2024-07-13T08:26:09.973993+00:00
137
false
\n\n# Code\n```\nclass Solution:\n def survivedRobotsHealths(self, positions: List[int], healths: List[int], directions: str) -> List[int]:\n robots = sorted(list(zip(positions, directions, healths)))\n stack = []\n\n for bot in robots:\n c = False\n pos, dire, hp = bot\n ...
2
0
['Stack', 'Sorting', 'Simulation', 'Python', 'Python3']
1
robot-collisions
[C++] --> Stack | Explained | Kind of easy understand!
c-stack-explained-kind-of-easy-understan-iymi
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. O(n) \n\n# Co
zhanghx04
NORMAL
2024-07-13T07:25:20.232787+00:00
2024-07-13T07:25:20.232841+00:00
18
false
# 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. $$O(n)$$ -->\n\n# Code\n```\n#define L 1\n#define R 0\n\nclass Solution {\npublic:\n struct Robot {\n int health;\n int pos;\n ...
2
0
['Stack', 'C++']
0
robot-collisions
Easy Solution Using stack and sorting in c++
easy-solution-using-stack-and-sorting-in-fbrh
\n# Code\n\nclass Solution\n{\npublic:\n vector<int> survivedRobotsHealths(vector<int> &positions, vector<int> &health, string directions)\n {\n in
rohit_1610
NORMAL
2024-07-13T04:38:44.399366+00:00
2024-07-13T04:38:44.399403+00:00
18
false
\n# Code\n```\nclass Solution\n{\npublic:\n vector<int> survivedRobotsHealths(vector<int> &positions, vector<int> &health, string directions)\n {\n int n = directions.size();\n vector<int> ans;\n vector<pair<int, int>> vp;\n for (int i = 0; i < n; i++)\n {\n int x = p...
2
0
['C++']
0
robot-collisions
Simple Stack Approach and Simulation. Beats All
simple-stack-approach-and-simulation-bea-g6e9
Intuition\n Describe your first thoughts on how to solve this problem. \nThe key insight is that robots moving in the same direction will never collide. Therefo
officialank671
NORMAL
2024-07-13T04:32:41.086335+00:00
2024-07-13T04:32:41.086364+00:00
331
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n*The key insight is that robots moving in the same direction will never collide. Therefore, we only need to worry about collisions between robots moving in opposite directions. We can use a stack to efficiently track robots moving right (...
2
0
['Array', 'Stack', 'Sorting', 'Simulation', 'C++']
3
robot-collisions
Kotlin simulation (Sort + Stack)
kotlin-simulation-sort-stack-by-james438-jb1n
\ndata class Robot (var position: Int, var health: Int, var direction: Char, val index: Int) {}\n\nenum class DIRECTION(val value: Char) {\n LEFT(\'L\'),\n
james4388
NORMAL
2024-07-13T04:14:33.003437+00:00
2024-07-13T04:14:33.003472+00:00
53
false
```\ndata class Robot (var position: Int, var health: Int, var direction: Char, val index: Int) {}\n\nenum class DIRECTION(val value: Char) {\n LEFT(\'L\'),\n RIGHT(\'R\')\n}\n\nclass Solution {\n fun survivedRobotsHealths(positions: IntArray, healths: IntArray, directions: String): List<Int> {\n var ro...
2
0
['Stack', 'Sorting', 'Simulation', 'Kotlin']
0
robot-collisions
Java | Detailed approach using Stack and Sorting.
java-detailed-approach-using-stack-and-s-dmmr
Intuition\nA collision can occur between any two consecutive robots only and out of which the one with less health gets removed or both gets removed if their he
mr_pawan
NORMAL
2024-07-13T03:02:05.280145+00:00
2024-07-13T11:56:24.200064+00:00
114
false
# Intuition\nA collision can occur between any two consecutive robots only and out of which the one with less health gets removed or both gets removed if their health is the same.\nIt immediately makes me think of a **Stack** as we just need to check with the previous robot and if it\'s moving in the opposite direction...
2
0
['Stack', 'Sorting', 'Java']
1
robot-collisions
Simulation using gnu pbds ordered statistics tree (ordered set)
simulation-using-gnu-pbds-ordered-statis-xoxw
Intuition\nWe can use simulation to solve this problem since there can be no more than $2n$ collisions. How do we know which two robots will collide? Let\'s cat
envyaims
NORMAL
2024-07-13T02:05:20.065607+00:00
2024-07-13T02:05:20.065625+00:00
76
false
# Intuition\nWe can use simulation to solve this problem since there can be no more than $2n$ collisions. How do we know which two robots will collide? Let\'s categorize each robot as moving left and moving right and sort by position. Consider robot $i$ moving right. Then, there is a possibility of colliding with robot...
2
0
['Simulation', 'Ordered Set', 'C++']
0
robot-collisions
"Robot Battle Simulation: Calculating Remaining Health" 100% 100% PHP
robot-battle-simulation-calculating-rema-nj9u
Intuition\nSimulate the robot battles while tracking their positions and health.\n\n# Approach\nSort the robot indices by position, process them in order while
jeniapppqqq
NORMAL
2023-10-06T11:54:51.048435+00:00
2023-10-06T11:54:51.048462+00:00
47
false
# Intuition\nSimulate the robot battles while tracking their positions and health.\n\n# Approach\nSort the robot indices by position, process them in order while simulating battles between left-moving and right-moving robots, and return the remaining health.\n\n# Complexity\n- Time complexity: O(n*log(n))\n\n- Space co...
2
0
['Array', 'Stack', 'Greedy', 'PHP', 'Sorting', 'Simulation']
0
robot-collisions
Easy Code || Stack + Sorting Based Approach || Easy to Understand
easy-code-stack-sorting-based-approach-e-2r9t
Complexity\n- Time complexity:\nO(nlogn)\n\n- Space complexity:\nO(n)\n\n# Code\n\nclass Solution {\n static bool cmp(pair<int,int> &p1 , pair<int,int> &p2){
krishna_6431
NORMAL
2023-06-26T19:47:08.412505+00:00
2023-06-26T19:47:08.412525+00:00
108
false
# Complexity\n- Time complexity:\n$$O(nlogn)$$\n\n- Space complexity:\n$$O(n)$$\n\n# Code\n```\nclass Solution {\n static bool cmp(pair<int,int> &p1 , pair<int,int> &p2){\n return p1.second < p2.second;\n }\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string...
2
0
['Stack', 'Sorting', 'C++']
0
robot-collisions
Cleanest Implementation [C++]
cleanest-implementation-c-by-jaintle-xugj
\n\n# Code\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n prior
jaintle
NORMAL
2023-06-25T21:12:45.253367+00:00
2023-06-25T22:10:51.819770+00:00
193
false
\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> ans;\n vector<int> sol;\n vector<pair<pair<int,int>,char>> v;\n un...
2
0
['Hash Table', 'Stack', 'Heap (Priority Queue)', 'C++']
2
robot-collisions
Done using Stack + Sort in C++
done-using-stack-sort-in-c-by-srijan1543-x6wz
Intuition\nSince the problem requires us to keep track of all of the collisions so that we can get the final health array, we have to sort the positions of the
Srijan1543
NORMAL
2023-06-25T13:17:25.148338+00:00
2023-06-25T13:17:25.148368+00:00
59
false
# Intuition\nSince the problem requires us to keep track of all of the collisions so that we can get the final health array, we have to sort the positions of the robot and add the robot to a stack either by scanning from left to right (or) from right to left. Just before adding the robot in the stack , check for colli...
2
0
['C++']
2
robot-collisions
🏆 Easiest & Simplest C++ 🔥Stack Only ✅ NO CLASS ❌
easiest-simplest-c-stack-only-no-class-b-ozym
ATLASSIAN 2023 INTERN Question\n# Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\nSimple Just keep adding all robots goin
ayyusharma
NORMAL
2023-06-25T12:09:15.518793+00:00
2023-06-25T12:09:15.518817+00:00
226
false
**ATLASSIAN 2023 INTERN** Question\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\nSimple Just keep adding all robots going to R and when Robots goes to L, Just see if the health of robot at top having health less then equal to or higher then health at top. if equal simp...
2
0
['Stack', 'Sorting', 'C++']
2
robot-collisions
[Javascript] Stack
javascript-stack-by-anna-hcj-npjl
Solution: Stack\n\nNote: The positions don\'t affect which robots will collide with each other, this stays the same no matter what. Robots adjacent to each othe
anna-hcj
NORMAL
2023-06-25T09:56:56.737082+00:00
2023-06-25T09:56:56.737107+00:00
133
false
**Solution: Stack**\n\nNote: The positions don\'t affect which robots will collide with each other, this stays the same no matter what. Robots adjacent to each other going right and left will always collide.\nIn the stack, keep track of robots we have processed so far that have still survived.\n\nIf the current robot i...
2
0
['JavaScript']
0
robot-collisions
Beautifully Explained CPP code, [Stack, Sorting]
beautifully-explained-cpp-code-stack-sor-jos7
Intuition\n Describe your first thoughts on how to solve this problem. \nAs we can see the problem we can see that there are few things that need to be concerne
DeathRidr007
NORMAL
2023-06-25T06:26:37.513541+00:00
2023-06-25T06:26:37.513574+00:00
180
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAs we can see the problem we can see that there are few things that need to be concerned,\n1. The only way the robots will collide is robot from left side is moving towards right and the right side robot will move towrds left.\n2. If ther...
2
0
['Stack', 'Sorting', 'C++']
0
robot-collisions
[Java] Use Stack to Simulate, Clean Code
java-use-stack-to-simulate-clean-code-by-37fj
\nimport java.util.*;\n\nclass Solution {\n public List<Integer> survivedRobotsHealths(int[] positions, int[] healths, String directions) {\n int n =
xiangcan
NORMAL
2023-06-25T04:02:49.864671+00:00
2023-06-25T04:03:08.740283+00:00
590
false
```\nimport java.util.*;\n\nclass Solution {\n public List<Integer> survivedRobotsHealths(int[] positions, int[] healths, String directions) {\n int n = positions.length;\n int[] finalHealths = new int[n];\n Arrays.fill(finalHealths, -1);\n\n List<int[]> robots = new ArrayList<>();\n ...
2
0
['Simulation', 'Java']
1
robot-collisions
Easiest Code | Sorting and Stack | Just do a simulation | C++ | Short Code
easiest-code-sorting-and-stack-just-do-a-swgq
\n\n# Code\n\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n
anmolbtw
NORMAL
2023-06-25T04:02:12.660810+00:00
2023-06-25T04:02:12.660839+00:00
125
false
\n\n# Code\n```\nclass Solution {\npublic:\n vector<int> survivedRobotsHealths(vector<int>& positions, vector<int>& healths, string directions) {\n int n=positions.size();\n vector<pair<int,pair<int,pair<int,char>>>> nums(n); //pos,ind,heal,dir\n for(int i=0;i<n;i++){\n nums[i]={posit...
2
0
['C++']
0
robot-collisions
C#
c-by-adchoudhary-4fmq
Code
adchoudhary
NORMAL
2025-03-01T07:23:40.317225+00:00
2025-03-01T07:23:40.317225+00:00
3
false
# Code ```csharp [] public class Solution { public List<int> SurvivedRobotsHealths(int[] positions, int[] healths, string directions) { int n = positions.Length; List<int> result = new List<int>(); Stack<int> stack = new Stack<int>(); int[] indices = new int[n]; for (int index = 0; index ...
1
0
['C#']
0
robot-collisions
easy optimized code faster
easy-optimized-code-faster-by-srivarsha1-17ng
IntuitionApproachComplexity Time complexity: Space complexity: Code
Srivarsha1901
NORMAL
2024-12-31T09:55:01.972615+00:00
2024-12-31T09:55:01.972615+00:00
7
false
# Intuition <!-- Describe your first thoughts on how to solve this problem. --> # Approach <!-- Describe your approach to solving the problem. --> # Complexity - Time complexity: <!-- Add your time complexity here, e.g. $$O(n)$$ --> - Space complexity: <!-- Add your space complexity here, e.g. $$O(n)$$ --> # Code `...
1
0
['Python']
0
robot-collisions
python using stack and sort
python-using-stack-and-sort-by-tianwen08-ft8a
IntuitionTo solve this problem, I initially thought of simulating the movement of each robot based on their given direction while keeping track of their health.
tianwen0815
NORMAL
2024-12-28T23:55:27.609646+00:00
2024-12-28T23:55:27.609646+00:00
22
false
# Intuition To solve this problem, I initially thought of simulating the movement of each robot based on their given direction while keeping track of their health. It quickly becomes evident that robots moving towards each other can collide, and handling these collisions efficiently is crucial. # Approach - **Sort Rob...
1
0
['Python3']
0
robot-collisions
Beginner friendly ✅✅ Simple stack🔥Most simple solution🔥🔥
beginner-friendly-simple-stackmost-simpl-nk7r
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
gorilla_sriv
NORMAL
2024-10-17T19:22:42.408173+00:00
2024-10-17T19:22:42.408195+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)$$ --...
1
0
['C++']
0
robot-collisions
Solution for robot-collisions
solution-for-robot-collisions-by-daniel_-d19x
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
Daniel_Westheimer
NORMAL
2024-08-10T22:32:40.520986+00:00
2024-08-10T22:32:40.521012+00:00
1
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n * log n);\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(n);\n<!-- Add your space complexity her...
1
0
['C++']
0
robot-collisions
C++ friendly Detailed Explanation + Clean code with Explanatory Comments
c-friendly-detailed-explanation-clean-co-bo4k
Intuition\nDirections are given. So, the very first thought came to my mind was to use a simple stack, but then realized positions are not sorted so directions
ichetancoding
NORMAL
2024-07-23T10:08:05.625920+00:00
2024-07-23T10:29:03.771340+00:00
10
false
# Intuition\nDirections are given. So, the very first thought came to my mind was to use a simple stack, but then realized positions are not sorted so directions don\'t actually make any sense.\n\n# Approach\nIf something is important, it\'s the positions, but we can\'t just directly sort the positions because we have ...
1
0
['C++']
0