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
number-complement
Short & Fast Java Solution (w/ Explanation)
short-fast-java-solution-w-explanation-b-dx98
Algorithm:\n\npublic int findComplement(int num) {\n\tint mask = -1;\n\twhile ((num & mask) != 0) {\n\t\tmask <<= 1;\n\t}\n\treturn ~num & ~mask; // Also equal
sidlak
NORMAL
2021-09-23T18:21:24.143137+00:00
2021-09-25T19:37:42.296684+00:00
822
false
**Algorithm:**\n```\npublic int findComplement(int num) {\n\tint mask = -1;\n\twhile ((num & mask) != 0) {\n\t\tmask <<= 1;\n\t}\n\treturn ~num & ~mask; // Also equal to ~(num ^ mask)\n}\n```\n**Explanation:**\nLets take this step by step. For the sake of my sanity, lets assume that integers are only 8-bits long. In o...
9
0
['Bit Manipulation', 'Java']
1
number-complement
C++ Solution using XOR
c-solution-using-xor-by-nisargshah20-5t23
```\nclass Solution {\npublic:\n int findComplement(int num) {\n int count=0;\n int j=num;\n while(j!=0){\n j=j/2;\n
nisargshah20
NORMAL
2020-05-04T07:22:40.065490+00:00
2020-05-04T07:22:40.065541+00:00
1,182
false
```\nclass Solution {\npublic:\n int findComplement(int num) {\n int count=0;\n int j=num;\n while(j!=0){\n j=j/2;\n count++;\n }\n int ans = pow(2,count) - 1;\n return num ^ ans;\n }\n};\n
9
0
[]
1
number-complement
easy solution in java.
easy-solution-in-java-by-hilloni-tepy
public int findComplement(int num) {\n int x=1,i=1;\n while(x<=num && i<32)\n {\n num=num^x;\n x=x<<1;\n i+
hilloni
NORMAL
2018-08-15T13:07:00.802254+00:00
2018-08-22T22:38:54.392871+00:00
1,346
false
public int findComplement(int num) {\n int x=1,i=1;\n while(x<=num && i<32)\n {\n num=num^x;\n x=x<<1;\n i++;\n }\n \n return num;\n }
9
1
[]
1
number-complement
[C++] Brute-Force | 0ms | Worst Approach
c-brute-force-0ms-worst-approach-by-vaib-rqe9
\nclass Solution {\npublic:\n int findComplement(int num) {\n vector<int> val;\n while(num > 0){\n val.push_back(num % 2);\n
vaibhav4859
NORMAL
2021-12-27T12:34:21.045157+00:00
2021-12-27T12:34:21.045187+00:00
686
false
```\nclass Solution {\npublic:\n int findComplement(int num) {\n vector<int> val;\n while(num > 0){\n val.push_back(num % 2);\n num /= 2;\n }\n reverse(val.begin(), val.end());\n for(int i = 0; i < val.size(); i++)\n if(val[i] == 0) val[i] = 1;\n ...
8
0
['C', 'C++']
0
number-complement
✔️ [Python3] BITWISE OPERATORS •͡˘㇁•͡˘, Explained
python3-bitwise-operators-vv-explained-b-znjk
The idea is to shift all bits of the given integer to the right in the loop until it turns into 0. Every time we do a shift we use a mask to check what is in th
artod
NORMAL
2021-12-27T01:32:09.523438+00:00
2021-12-28T05:47:06.361854+00:00
1,205
false
The idea is to shift all bits of the given integer to the right in the loop until it turns into `0`. Every time we do a shift we use a mask to check what is in the right-most bit of the number. If bit is `0` we add `2**n` to the result where `n` is the current number of shifts. Example:\n```\nn=0, num=1010, bit=0 => re...
8
0
['Bit Manipulation', 'Python3']
1
number-complement
🔥%Multiple solutions 🎉||100%🔥Beats ✅
multiple-solutions-100beats-by-shivanshg-dxt4
Code\ncpp []\n\n// approch brute bruteeeeee forceeeee every student can doooo\nclass Solution {\npublic:\n string decimalTobinary(int n) {\n string s
ShivanshGoel1611
NORMAL
2024-08-22T11:24:35.895567+00:00
2024-08-22T11:24:35.895651+00:00
1,229
false
# Code\n```cpp []\n\n// approch brute bruteeeeee forceeeee every student can doooo\nclass Solution {\npublic:\n string decimalTobinary(int n) {\n string s = "";\n while (n) {\n s = s + to_string(n % 2);\n n = n / 2;\n }\n return s;\n }\n int binaryTodecimal(str...
7
0
['Array', 'Bit Manipulation', 'Bitmask', 'Python', 'C++', 'Java', 'JavaScript']
0
number-complement
✅ One Line Solution
one-line-solution-by-mikposp-gf0g
(Disclaimer: this is not an example to follow in a real project - it is written for fun and training mostly)\n\n# Code #1\nTime complexity: O(1). Space complexi
MikPosp
NORMAL
2024-08-22T09:30:20.825645+00:00
2024-08-22T19:39:22.136636+00:00
813
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\nTime complexity: $$O(1)$$. Space complexity: $$O(1)$$.\n```\nclass Solution:\n def findComplement(self, v: int) -> int:\n return v^2**v.bit_length()-1\n```\n\n# Code #2\nTime complexity: ...
7
0
['Bit Manipulation', 'Python', 'Python3']
0
number-complement
Swift | One-liner explained
swift-one-liner-explained-by-vladimirthe-ufx4
Approach\n~num inverts all bits in num\nFor example, 5 which is 00000000000000000000000000000|101 in binary, becomes 11111111111111111111111111111|010 \n\nTo ge
VladimirTheLeet
NORMAL
2024-08-22T00:55:57.931022+00:00
2024-08-22T01:30:58.218717+00:00
276
false
# Approach\n`~num` inverts all bits in `num`\nFor example, `5` which is `00000000000000000000000000000|101` in binary, becomes `11111111111111111111111111111|010` \n\nTo get rid of these leading `1`-s we first bitshift this number to the left by `num.leadingZeroBitCount` postions, getting `010|0000000000000000000000000...
7
0
['Bit Manipulation', 'Swift']
1
number-complement
Java | Beginner Friendly | Runtime: 1ms
java-beginner-friendly-runtime-1ms-by-sh-aq5q
\nclass Solution {\n public int findComplement(int num) {\n\t\tString binary = Integer.toBinaryString(num);\n\t\tString complement = "";\n\t\tfor(int i = 0;
shishir-kon
NORMAL
2021-12-27T03:50:07.145686+00:00
2021-12-27T06:00:21.173840+00:00
543
false
```\nclass Solution {\n public int findComplement(int num) {\n\t\tString binary = Integer.toBinaryString(num);\n\t\tString complement = "";\n\t\tfor(int i = 0; i < binary.length(); i++) {\n\t\t\tif(binary.charAt(i) == \'1\') {\n\t\t\t\tcomplement += \'0\';\n\t\t\t}\n\t\t\telse if(binary.charAt(i) == \'0\') {\n\t\t\t...
7
1
['Java']
0
number-complement
99.20% faster python MUCH easy solution.
9920-faster-python-much-easy-solution-by-roe5
\nclass Solution:\n def findComplement(self, num: int) -> int:\n complement=""\n for i in bin(num)[2:]:\n if i is "0":\n
jorjis
NORMAL
2021-05-11T20:22:55.619806+00:00
2021-05-11T20:22:55.619841+00:00
765
false
```\nclass Solution:\n def findComplement(self, num: int) -> int:\n complement=""\n for i in bin(num)[2:]:\n if i is "0":\n complement+="1"\n else:\n complement+="0"\n \n return int(complement,2)\n```
7
0
['Python', 'Python3']
2
number-complement
[C++, Python] 3 line with Explanation, Faster than 100%
c-python-3-line-with-explanation-faster-y6dc7
C++\n\nint findComplement(int num) {\n\tint k = int(log2(num));\n\tint mask = pow(2,k+1) - 1;\n\treturn num^mask;\n}\n\n#### Python3\n\ndef findComplement(self,
Vishruth_S
NORMAL
2021-01-16T14:22:16.008888+00:00
2021-01-17T05:13:16.007958+00:00
433
false
#### C++\n```\nint findComplement(int num) {\n\tint k = int(log2(num));\n\tint mask = pow(2,k+1) - 1;\n\treturn num^mask;\n}\n```\n#### Python3\n```\ndef findComplement(self, num: int) -> int:\n\tk = int(log2(num))\n\tmask = int(2**(k+1) - 1)\n\treturn num^mask;\n```\n#### Explanation\nWe want to flip every bit. One wa...
7
0
['Bit Manipulation', 'C']
1
number-complement
C++ Solution EXPLAINED FULLY
c-solution-explained-fully-by-wa_magnet-qd8a
Approach : \n1. First we will find the number of bits in the given integer \n2. Then we will find the maximum number having same number of bits.(call it x )\n3
wa_magnet
NORMAL
2020-05-04T07:08:16.535429+00:00
2020-05-04T07:25:03.709453+00:00
382
false
Approach : \n1. First we will find the number of bits in the given integer \n2. Then we will find the maximum number having same number of bits.(call it x )\n3. Then we will XOR the given integer with x\n\nFor example : If input is 5 ,Binary Rep = 101 the number of bits = 3\n\t\t\t\t\tMax number , x = pow(2,number of ...
7
1
[]
1
number-complement
Straightforward Python
straightforward-python-by-awice-8o7x
This is not the shortest solution, but I believe straightforward solutions are more instructive.\n\nConsider the binary representation of the number.\nEvery 0 a
awice
NORMAL
2017-01-08T19:50:01.956000+00:00
2017-01-08T19:50:01.956000+00:00
1,263
false
This is not the shortest solution, but I believe straightforward solutions are more instructive.\n\nConsider the binary representation of the number.\nEvery 0 at the ith position from the right. adds 2**i to the result.\n\n```\ndef findComplement(self, N):\n binary = bin(N)[2:]\n ans = 0\n for i, u in enumerat...
7
1
[]
0
number-complement
0 ms C++ code without xor or not.
0-ms-c-code-without-xor-or-not-by-bechon-qyta
Basic idea is to find the smallest power of 2 idx that is larger than the input number num, and output the difference between idx and num . For example, input 5
bechone
NORMAL
2017-03-31T00:34:54.327000+00:00
2017-03-31T00:34:54.327000+00:00
541
false
Basic idea is to find the smallest power of 2 `idx` that is larger than the input number `num`, and output the difference between `idx` and `num` . For example, input `5 (101)` , the smallest power of 2 (and larger than `5`) is `8 (1000)`, the output should be `8 - 5 - 1 = 2 (010)`. \n\n```\nclass Solution {\npublic:\n...
7
0
[]
0
number-complement
JavaScript solutions, bits and strings
javascript-solutions-bits-and-strings-by-9mfs
The bit version:\n\nvar findComplement = function(num) {\n let mask = 1;\n while (mask < num) mask = (mask << 1) | 1;\n return num ^ mask;\n};\n\nThe s
loctn
NORMAL
2017-05-06T18:23:52.227000+00:00
2017-05-06T18:23:52.227000+00:00
1,041
false
The bit version:\n```\nvar findComplement = function(num) {\n let mask = 1;\n while (mask < num) mask = (mask << 1) | 1;\n return num ^ mask;\n};\n```\nThe string version:\n```\nvar findComplement = function(num) {\n return parseInt(num.toString(2).split('').map(d => +!+d).join(''), 2);\n};\n```\nA combinat...
7
0
['JavaScript']
3
number-complement
Start Flipping From The First Set Bit From Left To Right Direction | Java | C++ | [Video Solution]
start-flipping-from-the-first-set-bit-fr-rhid
Intuition, approach, and complexity discussed in detail in video solution.\nhttps://youtu.be/qmC8KKKZGp0\n# Code\njava []\nclass Solution {\n public int find
Lazy_Potato_
NORMAL
2024-08-22T05:17:35.157886+00:00
2024-08-22T05:17:35.157914+00:00
2,103
false
# Intuition, approach, and complexity discussed in detail in video solution.\nhttps://youtu.be/qmC8KKKZGp0\n# Code\n```java []\nclass Solution {\n public int findComplement(int num) {\n boolean setBitFound = false;\n for(int bitPos = 30; bitPos > -1; bitPos--){\n int mask = (1 << bitPos);\n ...
6
0
['Bit Manipulation', 'C++', 'Java']
2
number-complement
.::kotlin::. Bit mask with xor
kotlin-bit-mask-with-xor-by-dzmtr-ir0j
\nclass Solution {\n fun findComplement(num: Int): Int {\n var i = 0\n var t = num\n while (t > 0) {\n t = t shr 1\n
dzmtr
NORMAL
2024-06-15T12:18:12.278558+00:00
2024-06-15T12:18:12.278593+00:00
23
false
```\nclass Solution {\n fun findComplement(num: Int): Int {\n var i = 0\n var t = num\n while (t > 0) {\n t = t shr 1\n i++\n }\n val mask = (1 shl i) - 1 // -1 is the trick to make mask 1000 -> 111\n return num xor mask\n }\n}\n```
6
0
['Kotlin']
0
number-complement
476: Solution with step by step explanation
476-solution-with-step-by-step-explanati-pi1r
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n1. Convert the given integer \'num\' to its binary string representation
Marlen09
NORMAL
2023-03-10T17:48:56.638241+00:00
2023-03-10T17:48:56.638280+00:00
2,423
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n1. Convert the given integer \'num\' to its binary string representation using the built-in \'bin()\' function in Python.\n2. Flip all bits in the binary string obtained in step 1 to obtain the binary string representation o...
6
0
['Bit Manipulation', 'Python', 'Python3']
0
number-complement
Java | easier bitmask solution
java-easier-bitmask-solution-by-prezes-8k4c
Upvote if you find this easier than the editorial.\n```\npublic int findComplement(int num) {\n\tint mask= 1;\n\twhile(num>mask) mask= (mask<<1) | 1;\n\treturn
prezes
NORMAL
2021-12-27T02:24:22.617408+00:00
2021-12-27T02:27:52.984100+00:00
442
false
Upvote if you find this easier than the editorial.\n```\npublic int findComplement(int num) {\n\tint mask= 1;\n\twhile(num>mask) mask= (mask<<1) | 1;\n\treturn num^mask;\n}
6
1
[]
1
number-complement
[C++] Simple Approaches (W/ Explanation) | Faster than 100%
c-simple-approaches-w-explanation-faster-nz9t
Brute Force Approach :\n\n The Brute force approach to solve the problem would be to first convert the given number into its binary representation and then flip
Mythri_Kaulwar
NORMAL
2021-12-27T01:58:23.613415+00:00
2021-12-27T02:03:28.044464+00:00
938
false
**Brute Force Approach :**\n\n* The Brute force approach to solve the problem would be to first convert the given number into its binary representation and then flip every bit in the binary representation. \n* After changing all 0\u2019s and 1\u2019s convert the binary representation to number.\n\nTime Complexity : O(...
6
1
['Bit Manipulation', 'C', 'C++']
0
number-complement
[Python] Fastest One Liner (timed)
python-fastest-one-liner-timed-by-jeffwe-hf8c
Fastest Method Code\n\nclass Solution:\n def findComplement(self, num: int) -> int: \n return ~num + (1<<len(bin(num))-2)\n\n\n# Analysis\nThis
jeffwei
NORMAL
2020-05-05T05:35:28.319429+00:00
2020-05-23T13:06:56.035333+00:00
549
false
# Fastest Method Code\n```\nclass Solution:\n def findComplement(self, num: int) -> int: \n return ~num + (1<<len(bin(num))-2)\n```\n\n# Analysis\nThis line adds the complement of num (```~num```) with 2^n, where n = the number of bits in the binary representation of num. Let\'s take a look at why this...
6
1
['Bit Manipulation', 'Python', 'Python3']
0
number-complement
Java | 100% Faster | With Comments
java-100-faster-with-comments-by-onefine-4pkw
```\nclass Solution {\n public int findComplement(int num) {\n int result = 0;\n //use set to set the value of result in each bit\n int
onefineday01
NORMAL
2020-05-04T07:40:10.633903+00:00
2020-05-04T07:40:25.379383+00:00
1,335
false
```\nclass Solution {\n public int findComplement(int num) {\n int result = 0;\n //use set to set the value of result in each bit\n int set = 1;\n while(num != 0) {\n //if last bit is 0 , set corresponding position of result to 1\n if((num&1)== 0) {\n ...
6
0
['Java']
0
number-complement
One-line JavaScript solution
one-line-javascript-solution-by-john015-naam
javascript\n// One-line solution\nvar findComplement = function(num) {\n return num ^ parseInt(\'1\'.repeat(num.toString(2).length), 2)\n};\n\n// Two-line so
john015
NORMAL
2019-08-15T12:35:30.357388+00:00
2019-08-15T12:37:17.809868+00:00
309
false
```javascript\n// One-line solution\nvar findComplement = function(num) {\n return num ^ parseInt(\'1\'.repeat(num.toString(2).length), 2)\n};\n\n// Two-line solution\nvar findComplement = function(num) {\n\tconst mask = \'1\'.repeat(num.toString(2).length)\n return num ^ parseInt(mask, 2)\n};\n```\n\n
6
0
['JavaScript']
0
number-complement
Layman's conversion method: Decimal to binary, complement and back to Decimal
laymans-conversion-method-decimal-to-bin-eqxh
Long approach.\nNot used any Math.func , XOR, Bit manipulation.\n1.Convert Decimal to binary.\n2.Take its compliment\n3.Convert back to equivalent Decimal.\n\n\
idkwho
NORMAL
2019-02-20T11:28:03.022182+00:00
2019-02-20T11:28:03.022225+00:00
5,374
false
Long approach.\nNot used any Math.func , XOR, Bit manipulation.\n1.Convert Decimal to binary.\n2.Take its compliment\n3.Convert back to equivalent Decimal.\n\n```\nclass Solution {\n public int findComplement(int num) {\n int sum=0;\n List<Integer> n = new ArrayList<Integer>();\n //Convert Decim...
6
0
[]
0
number-complement
Share my Java solution with explanation
share-my-java-solution-with-explanation-t8pji
\npublic int findComplement(int num) {\n // find highest one bit\n\tint id = 31, mask = 1<<id;\n\twhile ((num & mask)==0) mask = 1<<--id;\n\t\t\n\t// mak
shawnloatrchen
NORMAL
2017-01-10T16:16:08.071000+00:00
2017-01-10T16:16:08.071000+00:00
2,113
false
```\npublic int findComplement(int num) {\n // find highest one bit\n\tint id = 31, mask = 1<<id;\n\twhile ((num & mask)==0) mask = 1<<--id;\n\t\t\n\t// make mask\n\tmask = (mask<<1) - 1;\n\t\t\n\treturn (~num) & mask;\n}\n```
6
0
[]
0
number-complement
❤️‍🔥 Python3 💯 JavaScript 🔥 C++ Solution
python3-javascript-c-solution-by-zane361-g72c
Intuition\n Describe your first thoughts on how to solve this problem. \nFirstly, we need to convert decimal number to binary number. \nSecondly, we will change
shomalikdavlatov
NORMAL
2024-08-22T10:18:04.619684+00:00
2024-08-22T10:18:04.619712+00:00
317
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nFirstly, we need to convert decimal number to binary number. \nSecondly, we will change `0` to `1` and `1` to `0`.\nLastly, we will convert this number to decimal number and return it.\n\n# Approach\n<!-- Describe your approach to solving...
5
0
['C++', 'Python3', 'JavaScript']
1
number-complement
Easy C solution with explanation beats 100% user in speed||Number Complement
easy-c-solution-with-explanation-beats-1-f2c8
Intuition\n Describe your first thoughts on how to solve this problem. \nAs usual here\'s the proof of the speed: \n\nThe idea is to create a bit mask made of 1
Skollwarynz
NORMAL
2024-08-22T08:24:13.116868+00:00
2024-08-22T08:24:13.116909+00:00
169
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nAs usual here\'s the proof of the speed: \n![image.png](https://assets.leetcode.com/users/images/77f3c969-f0ff-4bec-88c5-76a98ca5e2f4_1724313803.656143.png)\nThe idea is to create a bit mask made of 1 long as the bit representation of num...
5
0
['Bit Manipulation', 'C']
0
number-complement
Simple and Easy C++ Code 💯☠️
simple-and-easy-c-code-by-shodhan_ak-25dj
\n\n# Code\ncpp []\nclass Solution {\npublic:\n int findComplement(int num) {\n bitset<32> binary(num);\n string ans = binary.to_string();\n
Shodhan_ak
NORMAL
2024-08-22T05:30:07.702346+00:00
2024-08-22T05:30:07.702376+00:00
642
false
\n\n# Code\n```cpp []\nclass Solution {\npublic:\n int findComplement(int num) {\n bitset<32> binary(num);\n string ans = binary.to_string();\n string res = "";\n bool f1 = false;\n for (int i = 0; i < ans.size(); ++i) {\n if (ans[i] == \'1\') {\n f1 = tru...
5
0
['C++']
0
number-complement
✅Easy C++ Solution with Video Explanation✅
easy-c-solution-with-video-explanation-b-q3d5
Video Explanation\nhttps://youtu.be/1X7p3EDVrks?si=X1WTUiktBZ3sARbO\n# Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requ
prajaktakap00r
NORMAL
2024-08-22T01:22:05.406401+00:00
2024-08-22T01:22:05.406450+00:00
2,793
false
# Video Explanation\nhttps://youtu.be/1X7p3EDVrks?si=X1WTUiktBZ3sARbO\n# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires finding the complement of a number in its binary form, which involves flipping all the bits (i.e., turning 0s into 1s and 1s into 0s). To achieve ...
5
1
['C++']
1
number-complement
100 % Faster Solution
100-faster-solution-by-2005115-0ygf
PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT\n# CONNECT WITH ME\n### https://www.linkedin.com/in/pratay-nandy-9ba57b229/\n#### https://www.instagram.com/pratay_nand
2005115
NORMAL
2023-10-13T05:43:43.779071+00:00
2023-10-13T05:43:43.779089+00:00
613
false
# **PLEASE UPVOTE MY SOLUTION IF YOU LIKE IT**\n# **CONNECT WITH ME**\n### **[https://www.linkedin.com/in/pratay-nandy-9ba57b229/]()**\n#### **[https://www.instagram.com/pratay_nandy/]()**\n\n# Approach\nHere\'s a step-by-step explanation of the approach used in this code:\n\n1. Initialize `m` to the value of `n`. `m` ...
5
0
['Bit Manipulation', 'C', 'C++']
0
number-complement
JAVA - 2 line with Explanation - Bit Manipulation - 0ms
java-2-line-with-explanation-bit-manipul-u0fx
Num + Complement = All 1\'s\nSo, Complement = All 1\'s - Num\n\nExample :\nnum = 5 = 101\ncomplement = 2 = 010\n\n101 + 010 = 111\n101 + complement = 111\nSo, c
Its_Smriti
NORMAL
2022-12-10T17:07:12.723889+00:00
2022-12-10T17:07:12.723924+00:00
1,137
false
Num + Complement = All 1\'s\nSo, Complement = All 1\'s - Num\n\n**Example :**\nnum = 5 = 101\ncomplement = 2 = 010\n\n101 + 010 = 111\n**101 + complement = 111\nSo, complement = 111 - 101\n = 010**\n\n# Code\n```\nclass Solution {\n public int findComplement(int num) {\n int n = 0;\n while (n...
5
0
['Bit Manipulation', 'Java']
1
number-complement
Python Simple Solution Faster Than 97.39%
python-simple-solution-faster-than-9739-kc0ny
\nclass Solution:\n def findComplement(self, num: int) -> int:\n s=bin(num).replace(\'0b\',\'\')\n t=\'\'\n for i in s:\n if
pulkit_uppal
NORMAL
2022-10-26T00:09:58.976542+00:00
2022-10-26T00:09:58.976576+00:00
633
false
```\nclass Solution:\n def findComplement(self, num: int) -> int:\n s=bin(num).replace(\'0b\',\'\')\n t=\'\'\n for i in s:\n if i==\'0\':\n t+=\'1\'\n else:\n t+=\'0\'\n return int(t,2)\n```
5
0
['Python']
0
number-complement
C++ XOR solution with detail explain
c-xor-solution-with-detail-explain-by-zh-obpx
Consider the 32-bit int number representing as follow:\n 0000 0000 0000 0000 0000 0000 0000 0101 ----> num\n 0111 1111 1111 1111 1111 1111 1111 1111 ----> mas
zhxilin
NORMAL
2021-03-28T08:24:32.475900+00:00
2021-03-28T08:24:54.472405+00:00
570
false
Consider the 32-bit int number representing as follow:\n* 0000 0000 0000 0000 0000 0000 0000 0101 **---->** **num**\n* 0111 1111 1111 1111 1111 1111 1111 1111 **---->** **mask** **---->** *key problem to calculate the mask*\n* 0111 1111 1111 1111 1111 1111 1111 1010 **---->** **complement = num XOR mask**\n\t\n```\n...
5
1
['Bit Manipulation', 'C', 'C++']
3
number-complement
JavaScript solution beats 100% using string
javascript-solution-beats-100-using-stri-pnux
\nvar findComplement = function(num) {\n var str = num.toString(2);\n var result = \'\';\n for (var i of str) {\n result += i === \'1\'? \'0\': \
ys2843
NORMAL
2018-06-04T17:38:43.647975+00:00
2018-06-04T17:38:43.647975+00:00
338
false
```\nvar findComplement = function(num) {\n var str = num.toString(2);\n var result = \'\';\n for (var i of str) {\n result += i === \'1\'? \'0\': \'1\';\n }\n return parseInt(result, 2);\n};\n```
5
0
[]
0
number-complement
C# - 3 lines - O(highest set bit)
c-3-lines-ohighest-set-bit-by-jdrogin-ul0d
\nthe complexity will be the number of digits up to the highest set bit.\n\n\n public int FindComplement(int num) \n {\n int mask = 1;\n whi
jdrogin
NORMAL
2017-01-12T21:01:29.762000+00:00
2017-01-12T21:01:29.762000+00:00
861
false
\nthe complexity will be the number of digits up to the highest set bit.\n\n```\n public int FindComplement(int num) \n {\n int mask = 1;\n while (mask < num) mask = (mask << 1) | 1;\n return ~num & mask;\n }\n```
5
0
[]
0
number-complement
Java, O(N) solution, easy to understand with detailed explanation and comments
java-on-solution-easy-to-understand-with-s1a8
idea is simple, check each bit from right to leftmost bit 1, if bit is 1, continue, if bit is 0, set result's corresponding bit to 1\n```\npublic class Solution
jim39
NORMAL
2017-01-18T20:28:48.469000+00:00
2017-01-18T20:28:48.469000+00:00
801
false
idea is simple, check each bit from right to leftmost bit 1, if bit is 1, continue, if bit is 0, set result's corresponding bit to 1\n```\npublic class Solution {\n public int findComplement(int num) {\n int result = 0;\n //use set to set the value of result in each bit\n int set = 1;\n w...
5
0
['Bit Manipulation', 'Java']
1
number-complement
easy to understand bitwise approach with explanation || c++ || JS || python || python3
easy-to-understand-bitwise-approach-with-qo0r
Intuition\nThe complement of a number in binary is obtained by flipping all bits (i.e., converting 0s to 1s and 1s to 0s). To efficiently compute the complement
aramvardanyan13
NORMAL
2024-08-22T10:36:43.083327+00:00
2024-09-03T14:49:58.082008+00:00
245
false
# Intuition\nThe complement of a number in binary is obtained by flipping all bits (i.e., converting `0`s to `1`s and `1`s to `0`s). To efficiently compute the complement of a number, we need to focus only on the bits that matter\u2014those that correspond to the binary representation of the number.\n\n# Approach\n1. *...
4
0
['Python', 'C++', 'Python3', 'JavaScript']
0
number-complement
Java Simple Brute Force Approach
java-simple-brute-force-approach-by-chai-040r
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem asks us to find the complement of a given integer. The complement of a bina
Chaitanya_91
NORMAL
2024-08-22T09:20:18.155380+00:00
2024-08-22T09:20:18.155411+00:00
50
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem asks us to find the complement of a given integer. The complement of a binary number is obtained by flipping all the bits (i.e., converting 0s to 1s and 1s to 0s). The basic idea is to convert the number into its binary form, ...
4
0
['Java']
0
number-complement
Kotlin. Beats 100% (112 ms). Calculate mask then xor.
kotlin-beats-100-112-ms-calculate-mask-t-kjr5
\n\n# Code\nkotlin []\nclass Solution {\n fun findComplement(num: Int): Int {\n var n = num\n var mask = 0\n while (n != 0) {\n
mobdev778
NORMAL
2024-08-22T08:18:04.742568+00:00
2024-08-22T09:10:54.756572+00:00
170
false
![image.png](https://assets.leetcode.com/users/images/88f7af03-8085-48b9-a76d-cace91b46c59_1724314389.2553186.png)\n\n# Code\n```kotlin []\nclass Solution {\n fun findComplement(num: Int): Int {\n var n = num\n var mask = 0\n while (n != 0) {\n n = n shr 1\n mask = mask shl...
4
0
['Kotlin']
1
number-complement
Python | Bit Manipulation
python-bit-manipulation-by-khosiyat-pa4j
see the Successfully Accepted Submission\n\n# Code\npython3 []\nclass Solution(object):\n def findComplement(self, num):\n \n compliment = 1\n
Khosiyat
NORMAL
2024-08-22T07:01:41.681453+00:00
2024-08-22T07:01:41.681487+00:00
733
false
[see the Successfully Accepted Submission](https://leetcode.com/problems/number-complement/submissions/943115373/?envType=daily-question&envId=2024-08-22)\n\n# Code\n```python3 []\nclass Solution(object):\n def findComplement(self, num):\n \n compliment = 1\n while compliment <= num:\n ...
4
1
['Python3']
0
number-complement
🌟 Efficient Solution for "Number Complement" | C++ | 0ms Beats 100.00% | O(log n)
efficient-solution-for-number-complement-pgpu
\n---\n# Intuition\n\nThe problem requires finding the complement of a given integer. The complement is obtained by flipping all bits in the binary representati
user4612MW
NORMAL
2024-08-22T04:08:51.835330+00:00
2024-08-22T04:08:51.835359+00:00
19
false
##\n---\n# Intuition\n\nThe problem requires finding the complement of a given integer. The complement is obtained by flipping all bits in the binary representation of the number.\n\n# **Approach**\n\nTo find the complement of an integer **num**, first determine the number of bits needed to represent **num** in binary....
4
0
['C++']
0
number-complement
C# Solution for Number Complement Problem
c-solution-for-number-complement-problem-xv39
Intuition\n Describe your first thoughts on how to solve this problem. \nThe goal is to flip all the bits in the binary representation of an integer, effectivel
Aman_Raj_Sinha
NORMAL
2024-08-22T03:07:21.448878+00:00
2024-08-22T03:07:21.448913+00:00
258
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe goal is to flip all the bits in the binary representation of an integer, effectively calculating its complement. The approach involves generating a bitmask that has the same number of bits as the input integer but with all bits set to...
4
0
['C#']
0
number-complement
Number Complement - Beats 100% - Unique and Easy solution 🌟🔜
number-complement-beats-100-unique-and-e-k356
Intuition\nIf we find remainder when divided the number by 2,it\'ll give the bit representation in reverse order.With that ,we\'ll calculate the complement of t
RAJESWARI_P
NORMAL
2024-08-22T00:54:40.772844+00:00
2024-08-22T00:54:40.772864+00:00
142
false
# Intuition\nIf we find remainder when divided the number by 2,it\'ll give the bit representation in reverse order.With that ,we\'ll calculate the complement of the number by converting that binary representation to integer by multiplying with powers of 2 if the remainder obtained is 0.\n<!-- Describe your first though...
4
0
['Bit Manipulation', 'Java']
0
number-complement
No Loop One Line Solution in C++ with 100% m/s
no-loop-one-line-solution-in-c-with-100-v31sb
Intuition\n Describe your first thoughts on how to solve this problem. \n No loop one line solution in c++ just bit manipulation.\n\n# Approach\n Describe yo
shanmukhtharun
NORMAL
2024-08-22T00:42:08.649245+00:00
2024-08-22T00:42:08.649296+00:00
24
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n No loop one line solution in c++ just bit manipulation.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\njust Using the basic bitwise operations to solve the question.\n\n# Complexity\n- Time complexity:\n<!-- A...
4
0
['C++']
0
number-complement
One line solutions
one-line-solutions-by-xxxxkav-7qsd
\nclass Solution:\n def findComplement(self, num: int) -> int:\n return num ^ ((1 << num.bit_length()) - 1)\n\n\nclass Solution:\n def findCompleme
xxxxkav
NORMAL
2024-08-22T00:11:07.228206+00:00
2024-08-22T16:37:13.565785+00:00
1,521
false
```\nclass Solution:\n def findComplement(self, num: int) -> int:\n return num ^ ((1 << num.bit_length()) - 1)\n```\n```\nclass Solution:\n def findComplement(self, num: int) -> int:\n return num ^ (2 ** num.bit_length() - 1)\n```\n```\nclass Solution:\n def findComplement(self, num: int) -> int:...
4
1
['Bit Manipulation', 'Bitmask', 'Python3']
2
number-complement
Easy Solution || C++
easy-solution-c-by-japneet001-s1lg
Intuition\nThe code aims to find the complement of a given integer num. The complement is obtained by flipping each bit of the binary representation of the numb
Japneet001
NORMAL
2024-01-31T15:12:16.849898+00:00
2024-01-31T15:12:16.849934+00:00
769
false
# Intuition\nThe code aims to find the complement of a given integer `num`. The complement is obtained by flipping each bit of the binary representation of the number.\n\n# Approach\nThe code iterates through the binary representation of the input `num` one bit at a time. For each bit, it calculates the complement by p...
4
0
['Bit Manipulation', 'C++']
0
number-complement
Easy JAVA solution || 3-Line Code || T.C. : O(1) || S.C. : O(1)
easy-java-solution-3-line-code-tc-o1-sc-mw8gl
Intuition\n We are tasked with finding the complement of the given integer \'num\' in binary representation.*\n# Approach\n 1. Convert the given integer \'num\'
Ankita_Chaturvedi
NORMAL
2023-08-12T16:16:45.869535+00:00
2023-08-12T16:17:07.900458+00:00
219
false
# Intuition\n We are tasked with finding the complement of the given integer \'num\' in binary representation.*\n# Approach\n 1. Convert the given integer \'num\' to its binary representation using Integer.toBinaryString(num).\n 2. Calculate the number of bits required to represent \'num\' using the length of its binar...
4
0
['Java']
1
number-complement
Java | Fastest and easiest ever | Linear T & S | Beats 100%
java-fastest-and-easiest-ever-linear-t-s-sir1
Intuition\n Describe your first thoughts on how to solve this problem. \nWe have to flip the bits, i.e. we have to find compliment, thus I think ~n is a really
suryanshhh28
NORMAL
2023-08-05T13:49:20.096881+00:00
2023-08-05T13:49:20.096899+00:00
515
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe have to flip the bits, i.e. we have to find compliment, thus I think ~n is a really good option, but we have a problem over here, it flips all the bits that is if an integer only takes 7 bits and rest in front are zeros, it will flip ...
4
0
['Math', 'Bit Manipulation', 'Java']
2
number-complement
Easy Solution using Bitwise Operators
easy-solution-using-bitwise-operators-by-7lwh
```\nclass Solution {\n public static int findComplement(int num) {\n //Q476\n //Ex for 5\n //Using XOR operator - 0-->1 and 1-->0 that
Abhinav_0561
NORMAL
2022-06-07T05:00:20.097376+00:00
2022-06-07T05:00:20.097420+00:00
641
false
```\nclass Solution {\n public static int findComplement(int num) {\n //Q476\n //Ex for 5\n //Using XOR operator - 0-->1 and 1-->0 that is what we need(Complement)\n //101 ^ 111 = 010 i.e., the ans. \n // 111 is the required mask in this case\n //For calculating mask, we tak...
4
0
['Java']
0
number-complement
Number Complement | 100% | Bit Manipulation Approach | Java
number-complement-100-bit-manipulation-a-8t0g
class Solution {\n\n public int findComplement(int n) {\n int number_of_bits = (int) (Math.floor(Math.log(n) / Math.log(2))) + 1;\n return ((1
abhishekjha786
NORMAL
2021-12-27T06:35:03.158502+00:00
2021-12-27T08:37:18.726343+00:00
87
false
class Solution {\n\n public int findComplement(int n) {\n int number_of_bits = (int) (Math.floor(Math.log(n) / Math.log(2))) + 1;\n return ((1 << number_of_bits) - 1) ^ n;\n }\n}\n\n**Please help to UPVOTE if this post is useful for you.\nIf you have any questions, feel free to comment below.\nHAPPY...
4
1
['Bit Manipulation']
1
number-complement
1-line Go Solution
1-line-go-solution-by-evleria-3ce9
\nfunc findComplement(num int) int {\n\treturn (1<<(bits.Len(uint(num))) - 1) ^ num\n}\n
evleria
NORMAL
2021-11-03T18:47:28.458504+00:00
2021-11-03T18:47:28.458541+00:00
323
false
```\nfunc findComplement(num int) int {\n\treturn (1<<(bits.Len(uint(num))) - 1) ^ num\n}\n```
4
0
['Go']
0
number-complement
simple C 100%
simple-c-100-by-linhbk93-y05t
\nint findComplement(int num){\n int temp = num, c = 0;\n while(temp>0)\n {\n c = (c<<1)|1;\n temp >>= 1;\n } \n return num ^ c;\n
linhbk93
NORMAL
2021-08-25T09:27:03.823737+00:00
2021-08-25T09:27:32.533505+00:00
410
false
```\nint findComplement(int num){\n int temp = num, c = 0;\n while(temp>0)\n {\n c = (c<<1)|1;\n temp >>= 1;\n } \n return num ^ c;\n}\n```
4
0
['C']
0
number-complement
Java Simple Solution 100%
java-simple-solution-100-by-kenzhekozy-6gh7
\nclass Solution {\n public int findComplement(int num) {\n int ans = 0;\n int p = 0;\n while(num!=0){\n if(num%2==0) ans +=
kenzhekozy
NORMAL
2021-03-12T15:31:10.688256+00:00
2021-03-26T10:07:52.953142+00:00
285
false
```\nclass Solution {\n public int findComplement(int num) {\n int ans = 0;\n int p = 0;\n while(num!=0){\n if(num%2==0) ans += Math.pow(2, p);\n p++;\n num /= 2;\n }\n \n return ans;\n }\n}\n\n```
4
0
['Java']
1
number-complement
C++ 100% bitset
c-100-bitset-by-eridanoy-ml5a
\nclass Solution {\npublic:\n int findComplement(int num) {\n bitset<32> b(num);\n int pos=32;\n while(!b[--pos]);\n while(pos>-1
eridanoy
NORMAL
2020-11-17T16:53:30.639945+00:00
2020-11-17T16:53:30.639991+00:00
386
false
```\nclass Solution {\npublic:\n int findComplement(int num) {\n bitset<32> b(num);\n int pos=32;\n while(!b[--pos]);\n while(pos>-1) b.flip(pos--);\n return b.to_ulong();\n }\n};\n```
4
0
['C']
1
number-complement
Easy Java StringBuilder Solution
easy-java-stringbuilder-solution-by-poor-eegk
class Solution {\n public int findComplement(int num) {\n String s=Integer.toBinaryString(num);\n StringBuilder sb=new StringBuilder();\n
poornimadave27
NORMAL
2020-09-18T11:13:45.111281+00:00
2020-09-18T11:13:45.111317+00:00
91
false
class Solution {\n public int findComplement(int num) {\n String s=Integer.toBinaryString(num);\n StringBuilder sb=new StringBuilder();\n for(int i=0;i<s.length();i++){\n if(s.charAt(i)==\'1\'){\n sb.append(\'0\');\n }\n else{\n sb.a...
4
0
[]
0
number-complement
C# simple solution without using Math functions
c-simple-solution-without-using-math-fun-i2pj
\npublic int FindComplement(int num) {\n int k = 1;\n for (int i = num; i > 0; i >>= 1)\n k <<= 1;\n return k - num - 1;\n}\n\n\nif num = 101\nk
alexidealex
NORMAL
2020-05-04T22:48:43.532595+00:00
2020-05-04T22:48:43.532648+00:00
109
false
```\npublic int FindComplement(int num) {\n int k = 1;\n for (int i = num; i > 0; i >>= 1)\n k <<= 1;\n return k - num - 1;\n}\n```\n\nif num = 101\nk will be 1000\nk - 1 = 111\nk - num - 1 = 010\n
4
0
[]
0
number-complement
[Python] Short Bit Solution - Clean & Concise
python-short-bit-solution-clean-concise-obqzk
python\nclass Solution:\n def findComplement(self, num: int) -> int:\n i = 0\n ans = 0\n while num > 0:\n if (num & 1) == 0:\
hiepit
NORMAL
2020-05-04T18:17:03.474147+00:00
2022-04-04T23:46:21.872365+00:00
500
false
```python\nclass Solution:\n def findComplement(self, num: int) -> int:\n i = 0\n ans = 0\n while num > 0:\n if (num & 1) == 0:\n ans |= 1 << i\n i += 1\n num >>= 1\n \n return ans\n```\n**Complexity**\n- Time: `O(logNum)`\n- Spac...
4
1
[]
0
number-complement
2 java simple solutions with comments | 100% runtime
2-java-simple-solutions-with-comments-10-nowh
\n1st solution:-\n\nclass Solution {\n public int findComplement(int num) {\n int i = 0, res = 0;\n while(num > 0){\n // if last bit
logan138
NORMAL
2020-05-04T07:34:40.873819+00:00
2020-05-04T09:50:59.053991+00:00
366
false
```\n1st solution:-\n\nclass Solution {\n public int findComplement(int num) {\n int i = 0, res = 0;\n while(num > 0){\n // if last bit of num is 0, then we need to take complement of it\n // so, add corresponding pow to res.\n if((1 & num) == 0) res += Math.pow(2, i);\...
4
1
[]
0
number-complement
C++ SIMPLE EASY NAIVE SOLUTION
c-simple-easy-naive-solution-by-chase_ma-m3js
\nclass Solution {\npublic:\n int findComplement(int num) {\n \n int x =0;\n int d=0;\n string s="";\n while(num){\n
chase_master_kohli
NORMAL
2019-12-01T21:51:24.336651+00:00
2019-12-01T21:51:24.336683+00:00
184
false
```\nclass Solution {\npublic:\n int findComplement(int num) {\n \n int x =0;\n int d=0;\n string s="";\n while(num){\n s=to_string(num&1) +s;\n num/=2;\n }\n int i = 0;\n while(i<s.length()){\n s[i]=s[i]==\'1\'?\'0\':\'1\';\n ...
4
0
[]
0
number-complement
Javascript
javascript-by-cuijingjing-pnu6
\nvar findComplement = function(num) {\n var number = num.toString(2);\n var str = \'\';\n for(let i of number) {\n str += +!(i-0);\n }\n
cuijingjing
NORMAL
2019-04-11T04:27:28.582821+00:00
2019-04-11T04:27:28.582850+00:00
278
false
```\nvar findComplement = function(num) {\n var number = num.toString(2);\n var str = \'\';\n for(let i of number) {\n str += +!(i-0);\n }\n return parseInt(str, 2)\n};\n```
4
0
[]
0
number-complement
Cpp O(lgN) solution
cpp-olgn-solution-by-calotte-1rf0
\nclass Solution {\npublic:\n int findComplement(int num) {\n long long t=1;\n while(t<=num)\n t=t<<1;\n return (t-1)^num;\n
calotte
NORMAL
2018-10-07T13:21:24.807657+00:00
2018-10-07T13:21:24.807696+00:00
290
false
```\nclass Solution {\npublic:\n int findComplement(int num) {\n long long t=1;\n while(t<=num)\n t=t<<1;\n return (t-1)^num;\n }\n};\n```
4
0
[]
3
number-complement
Trivial Ruby one-liner
trivial-ruby-one-liner-by-stefanpochmann-l7hv
\ndef find_complement(num)\n num.to_s(2).tr('01', '10').to_i(2)\nend\n
stefanpochmann
NORMAL
2017-01-08T11:56:55.365000+00:00
2017-01-08T11:56:55.365000+00:00
545
false
```\ndef find_complement(num)\n num.to_s(2).tr('01', '10').to_i(2)\nend\n```
4
0
[]
0
number-complement
JavaScript 1 line
javascript-1-line-by-samaritan89-32pl
\nvar findComplement = function(num) {\n return num ^ parseInt(num.toString(2).replace(/\\d/g, '1'), 2);\n};\n
samaritan89
NORMAL
2017-10-22T06:43:29.370000+00:00
2017-10-22T06:43:29.370000+00:00
494
false
```\nvar findComplement = function(num) {\n return num ^ parseInt(num.toString(2).replace(/\\d/g, '1'), 2);\n};\n```
4
1
['JavaScript']
0
the-number-of-full-rounds-you-have-played
C++ straightforward 3 lines
c-straightforward-3-lines-by-lzl124631x-6fea
See my latest update in repo LeetCode\n## Solution 1.\n\n1. Convert the startTime and finishTime into minutes.\n2. If startTime > finishTime, add 24 hours to fi
lzl124631x
NORMAL
2021-06-20T04:01:53.294063+00:00
2021-06-20T05:06:07.837552+00:00
5,348
false
See my latest update in repo [LeetCode](https://github.com/lzl124631x/LeetCode)\n## Solution 1.\n\n1. Convert the `startTime` and `finishTime` into minutes.\n2. If `startTime > finishTime`, add 24 hours to `finishTime` because we played overnight.\n3. Divide `startTime` and `finishTime` by 15, and round them UP and DOW...
130
20
[]
17
the-number-of-full-rounds-you-have-played
Clean Java, O(1)
clean-java-o1-by-mardlucca-clg3
Well, at least I claim this is clean/readable: :-)\n\n\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int star
mardlucca
NORMAL
2021-06-20T04:37:35.776861+00:00
2021-06-20T04:37:35.776891+00:00
2,635
false
Well, at least I claim this is clean/readable: :-)\n\n```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int start = toMinutes(startTime);\n int end = toMinutes(finishTime);\n \n int roundedStart = toNextQuarter(start);\n int roundedEnd = toP...
47
0
[]
4
the-number-of-full-rounds-you-have-played
[Python3] math-ish
python3-math-ish-by-ye15-gmgr
\n\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n hs, ms = (int(x) for x in startTime.split(":"))\n ts
ye15
NORMAL
2021-06-20T04:03:26.635656+00:00
2021-06-20T22:20:59.174635+00:00
2,371
false
\n```\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n hs, ms = (int(x) for x in startTime.split(":"))\n ts = 60 * hs + ms\n hf, mf = (int(x) for x in finishTime.split(":"))\n tf = 60 * hf + mf\n if 0 <= tf - ts < 15: return 0 # edge case \n ...
23
2
['Python3']
5
the-number-of-full-rounds-you-have-played
c++ easy with explained solution Passing all Edge CASES
c-easy-with-explained-solution-passing-a-gieu
1. To handle the case where our startTime is greater then endTime we add a period of 24 hrs ie 24*60.\n2. To handle the case were startTime must be in the range
super_cool123
NORMAL
2021-06-20T05:33:39.817645+00:00
2021-06-27T10:16:19.275040+00:00
1,414
false
**1. To handle the case where our startTime is greater then endTime we add a period of 24 hrs ie 24*60.\n2. To handle the case were startTime must be in the range of [15:30:45:60] we can add 14 to start time in that way we can skip [0 to 14] time interval\n3. To Handle the edge case we have to convert the time to minut...
16
4
['C']
4
the-number-of-full-rounds-you-have-played
Java O(1) 100% faster
java-o1-100-faster-by-akhil_t-6t5j
\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n Integer startHH = Integer.parseInt(startTime.substring(0,2));\
akhil_t
NORMAL
2021-06-20T05:23:23.167738+00:00
2021-06-20T05:23:23.167767+00:00
1,813
false
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n Integer startHH = Integer.parseInt(startTime.substring(0,2));\n Integer startMM = Integer.parseInt(startTime.substring(3));\n Integer finishHH = Integer.parseInt(finishTime.substring(0,2));\n Intege...
14
1
['Java']
7
the-number-of-full-rounds-you-have-played
Clean Python 3, straightforward
clean-python-3-straightforward-by-lenche-znah
Time: O(1)\nSpace: O(1)\n\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n if finishTime < startTime:\n
lenchen1112
NORMAL
2021-06-20T04:03:23.751976+00:00
2021-06-21T06:17:25.830323+00:00
1,101
false
Time: `O(1)`\nSpace: `O(1)`\n```\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n if finishTime < startTime:\n return self.numberOfRounds(startTime, \'24:00\') + self.numberOfRounds(\'00:00\', finishTime)\n sHH, sMM = map(int, startTime.split(\':\'))\n ...
12
0
[]
5
the-number-of-full-rounds-you-have-played
Very simple C++ solution
very-simple-c-solution-by-hc167-mq0o
Updated solution to preserve the original logic as much as possible,\n\n\nclass Solution {\npublic:\n int numberOfRounds(string startTime, string finishTime)
hc167
NORMAL
2021-06-20T04:01:13.223670+00:00
2021-06-27T14:23:27.634773+00:00
1,184
false
Updated solution to preserve the original logic as much as possible,\n\n```\nclass Solution {\npublic:\n int numberOfRounds(string startTime, string finishTime) {\n int a = stoi(startTime.substr(0, 2));\n int b = stoi(startTime.substr(3, 2));\n int c = stoi(finishTime.substr(0, 2));\n int...
11
4
[]
5
the-number-of-full-rounds-you-have-played
Java O(1)
java-o1-by-vikrant_pc-9ba1
\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int[] start = getTime(startTime), end = getTime(finishTime);\n
vikrant_pc
NORMAL
2021-06-20T04:00:43.429775+00:00
2021-06-20T04:00:43.429813+00:00
544
false
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int[] start = getTime(startTime), end = getTime(finishTime);\n if(end[0] < start[0] || end[0] == start[0] && end[1] < start[1]) end[0] += 24; // Midnight case\n return (end[0] * 4 + end[1]/15) - (start[0] ...
8
6
[]
3
the-number-of-full-rounds-you-have-played
Python: Brute-force: Constant Time and Space.
python-brute-force-constant-time-and-spa-geh1
Idea: Split the time into hours and minutes.\n\nif start hour == end hour, and start min < end min, this simply means start time is less than end time.\nso, get
meaditya70
NORMAL
2021-06-20T04:23:40.144856+00:00
2021-06-20T04:25:41.471679+00:00
604
false
Idea: Split the time into hours and minutes.\n\nif start hour == end hour, and start min < end min, this simply means start time is less than end time.\nso, get the difference between the number of games he/she can play witin that time. \nNote: if start min = 1 and end min = 46, then our games played will be only 2 fr...
6
2
['Python']
2
the-number-of-full-rounds-you-have-played
JS Solution, Date function
js-solution-date-function-by-chejianchao-paad
\nuse ceil to get the valid start time.\n\nvar numberOfRounds = function(startTime, finishTime) {\n var s = new Date(`2020-01-01T${startTime}:00Z`);\n var
chejianchao
NORMAL
2021-06-20T04:01:50.027843+00:00
2021-06-20T04:01:50.027877+00:00
473
false
\nuse ceil to get the valid start time.\n```\nvar numberOfRounds = function(startTime, finishTime) {\n var s = new Date(`2020-01-01T${startTime}:00Z`);\n var e;\n if(finishTime < startTime)\n e = new Date(`2020-01-02T${finishTime}:00Z`);\n else\n e = new Date(`2020-01-01T${finishTime}:00Z`);\n...
6
0
[]
2
the-number-of-full-rounds-you-have-played
Java Super simple sol
java-super-simple-sol-by-sting__112-ow9p
\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int start = timeInMinute(startTime); //convert start time to m
sting__112
NORMAL
2021-06-20T05:22:11.700949+00:00
2021-06-20T05:22:25.260507+00:00
651
false
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int start = timeInMinute(startTime); //convert start time to minutes\n int end = timeInMinute(finishTime); //Convert end time to minutes\n \n if(end < start)\n end += 24*60;\n \n ...
5
0
['Java']
0
the-number-of-full-rounds-you-have-played
Java O(1) solution with comments in the code for better understanding
java-o1-solution-with-comments-in-the-co-vgv5
Here we\'re basically converting the startTime and endTime to minutes and then calculating then result.\n\nclass Solution {\n public int numberOfRounds(Strin
fresh_avocado
NORMAL
2021-06-20T05:09:28.433482+00:00
2021-06-20T05:09:28.433514+00:00
422
false
Here we\'re basically converting the startTime and endTime to minutes and then calculating then result.\n```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n \n int finMin = Integer.parseInt(finishTime.substring(3, 5));\n int startMin = Integer.parseInt(star...
5
0
['Java']
1
the-number-of-full-rounds-you-have-played
[Python] play with Numbers
python-play-with-numbers-by-vegishanmukh-blda
The main idea behind this solution was :\n1.Convert times to numbers\n2.Find the first time where a play can start\n3.If the end time is less than start, go on
vegishanmukh7
NORMAL
2021-06-20T04:40:37.167311+00:00
2021-06-20T04:40:37.167341+00:00
604
false
The main idea behind this solution was :\n1.Convert times to numbers\n2.Find the first time where a play can start\n3.If the end time is less than start, go on untill 2400 and make start-index to 0\n3.Go on untill we reach the end time\n\nThe main point to be remembered here is 10:60 is treated same as 11:00.\n~~~\ncla...
5
1
[]
0
the-number-of-full-rounds-you-have-played
Easy O(1) C++ solution with explanation.
easy-o1-c-solution-with-explanation-by-r-490l
Consider the testcase startTime = \'12:01\' and finishTIme = \'13:44\'\n\n\n ceil floor \n |-> <-|\n\t|---|---|--
r-aravind
NORMAL
2021-06-21T04:28:06.110106+00:00
2021-06-21T04:28:40.969841+00:00
346
false
Consider the testcase `startTime = \'12:01\'` and `finishTIme = \'13:44\'`\n\n```\n ceil floor \n |-> <-|\n\t|---|---|---|---|---|---|---|---|\n\t| | |\n\t12:00 13:00 14:00\n```\n\n\n\nSolution:\n- Convert `startTime` and `fi...
4
0
[]
0
the-number-of-full-rounds-you-have-played
[C++] | With comments & Examples | O(1) | 100% Faster
c-with-comments-examples-o1-100-faster-b-dfn8
Handling just 2 cases takes care of every corner case. And by seeing some common parts in code and, you can make code shorter ,but I think its easy to understan
7ravip
NORMAL
2021-06-20T04:24:38.851670+00:00
2021-06-23T02:40:36.115817+00:00
340
false
#### Handling just 2 cases takes care of every corner case. And by seeing some common parts in code and, you can make code shorter ,but I think its easy to understand this way\n```\nclass Solution {\npublic:\n int numberOfRounds(string s, string f) {\n\t\t//Just Some preprocessing :-/\n int sh = (s[0]-\'0\')*...
4
1
[]
0
the-number-of-full-rounds-you-have-played
C++ no bullshit
c-no-bullshit-by-rajat2105-nde8
JUST CHECK IF FINISH TIME IS MULTIPLE OF 15.TAKES CARE OF ALL CASES\n```\nclass Solution {\npublic:\n int numberOfRounds(string st, string ft) {\n int
rajat2105
NORMAL
2021-06-20T04:11:09.696701+00:00
2021-07-29T17:41:53.453747+00:00
282
false
JUST CHECK IF FINISH TIME IS MULTIPLE OF 15.TAKES CARE OF ALL CASES\n```\nclass Solution {\npublic:\n int numberOfRounds(string st, string ft) {\n int s=0;\n s=(st[0]-\'0\')*1000+(st[1]-\'0\')*100+(st[3]-\'0\')*10+st[4]-\'0\';\n int f=0;\n f=(ft[0]-\'0\')*1000+(ft[1]-\'0\')*100+(ft[3]-\'0...
4
0
[]
0
the-number-of-full-rounds-you-have-played
[C++] Simple C++ Code || O(1) time
c-simple-c-code-o1-time-by-prosenjitkund-sczp
\n# If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\npubli
_pros_
NORMAL
2022-09-02T15:49:31.934256+00:00
2022-09-02T15:49:31.934352+00:00
369
false
\n# **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\npublic:\n int numberOfRounds(string loginTime, string logoutTime) {\n int INtime = ((loginTime[0]-\'0\')*10+loginTime[1]-\'0\')*60 + (loginTime[3]-\...
3
0
['Math', 'C', 'C++']
0
the-number-of-full-rounds-you-have-played
Java | Simple | Easy to understand
java-simple-easy-to-understand-by-phani_-0j5v
```\nclass Solution {\n public int numberOfRounds(String loginTime, String logoutTime) {\n String[] arr1 = loginTime.split(":");\n String[] arr
phani_java
NORMAL
2022-03-25T07:01:28.296387+00:00
2022-03-25T07:01:28.296425+00:00
497
false
```\nclass Solution {\n public int numberOfRounds(String loginTime, String logoutTime) {\n String[] arr1 = loginTime.split(":");\n String[] arr2 = logoutTime.split(":"); \n \n int time1 = Integer.parseInt(arr1[0])*60 + Integer.parseInt(arr1[1]);\n int time2 = Integer.parseInt(arr2...
3
0
['Java']
0
the-number-of-full-rounds-you-have-played
[Python] 7 lines (simple!)
python-7-lines-simple-by-m-just-bu9v
python\ndef numberOfRounds(self, startTime: str, finishTime: str) -> int:\n s = int(startTime[:2]) * 60 + int(startTime[-2:])\n t = int(finishTime[:2]) *
m-just
NORMAL
2021-06-22T14:20:49.362783+00:00
2021-06-22T14:22:48.265225+00:00
448
false
```python\ndef numberOfRounds(self, startTime: str, finishTime: str) -> int:\n s = int(startTime[:2]) * 60 + int(startTime[-2:])\n t = int(finishTime[:2]) * 60 + int(finishTime[-2:])\n if s > t:\n t += 24 * 60\n q, r = divmod(s, 15)\n s, t = q + int(r > 0), t // 15\n return max(0, t - s)\n```\n...
3
1
['Python']
2
the-number-of-full-rounds-you-have-played
JAVA solution with visual explanation
java-solution-with-visual-explanation-by-vqxx
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n // think of a day as units of time, each unit consists 15 m
thaliah
NORMAL
2021-06-20T17:15:36.367752+00:00
2021-06-20T17:25:09.346050+00:00
135
false
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n // think of a day as units of time, each unit consists 15 minutes \n // so within a day, there will be 24 * 4 = 96 units (4 15-min units per hour)\n\n // 0----15min----1----15min----2----15min----3----15mi...
3
1
['Java']
0
the-number-of-full-rounds-you-have-played
Very easy method C++
very-easy-method-c-by-kaspil-2fh3
class Solution {\npublic:\n \n int numberOfRounds(string s, string f) {\n int h1,h2,m1,m2;\n h1=(s[0]-\'0\')10+(s[1]-\'0\');\n m1=(s[3]
kaspil
NORMAL
2021-06-20T08:20:33.399065+00:00
2021-06-20T08:20:33.399108+00:00
229
false
class Solution {\npublic:\n \n int numberOfRounds(string s, string f) {\n int h1,h2,m1,m2;\n h1=(s[0]-\'0\')*10+(s[1]-\'0\');\n m1=(s[3]-\'0\')*10+(s[4]-\'0\');\n h2=(f[0]-\'0\')*10+(f[1]-\'0\');\n m2=(f[3]-\'0\')*10+(f[4]-\'0\');\n int cnt=0,cnt1=0,hh=0;\n if(h2>=h1...
3
0
[]
2
the-number-of-full-rounds-you-have-played
O(1) time complexity, easy to understand, 2 solutions
o1-time-complexity-easy-to-understand-2-n7rrl
O(1) time complexity and O(1) space complexity\ncode is self explanatory. Kindly go through it. Incase of any doubts, feel free to comment.\n\n\nclass Solution:
code-fanatic
NORMAL
2021-06-20T04:22:26.781947+00:00
2021-06-20T06:46:01.035902+00:00
361
false
O(1) time complexity and O(1) space complexity\ncode is self explanatory. Kindly go through it. Incase of any doubts, feel free to comment.\n\n```\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n\n start=startTime.split(":")\n startHour,startMin=int(start[0]),int(s...
3
1
['Math', 'Python', 'Python3']
1
the-number-of-full-rounds-you-have-played
Two Tricks
two-tricks-by-votrubac-5nr7
Check if the end time is tomorrow.\n2. Round the start time up to 15-minute mark, and round the end time down.\n\nC++\ncpp\nint numberOfRounds(string a, string
votrubac
NORMAL
2021-06-20T04:03:30.792323+00:00
2021-06-22T17:17:37.354515+00:00
381
false
1. Check if the end time is tomorrow.\n2. Round the start time up to 15-minute mark, and round the end time down.\n\n**C++**\n```cpp\nint numberOfRounds(string a, string b) {\n auto nn = [](const string &s, int i){ \n return (s[i] - \'0\') * 10 + s[i + 1] - \'0\'; };\n int m1 = nn(a, 0) * 60 + nn(a, 3), m2...
3
1
['C']
0
the-number-of-full-rounds-you-have-played
[Python + Java] (Convert to minutes)
python-java-convert-to-minutes-by-m0u1ea-m267
Python\npython\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n def convert(s):\n return int(s[:2])*6
M0u1ea5
NORMAL
2021-06-20T04:02:42.801207+00:00
2021-06-22T15:22:21.714217+00:00
219
false
**Python**\n```python\nclass Solution:\n def numberOfRounds(self, startTime: str, finishTime: str) -> int:\n def convert(s):\n return int(s[:2])*60+int(s[3:])\n \n st = convert(startTime)\n ft = convert(finishTime)\n \n if ft < st:\n ft += 1440\n ...
3
0
[]
1
the-number-of-full-rounds-you-have-played
C# simple solution
c-simple-solution-by-bykarelin-x8q5
Complexity\n- Time complexity:\no(1)\n\n- Space complexity:\no(1)\n\n# Code\n\npublic class Solution {\n public int NumberOfRounds(string loginTime, string l
bykarelin
NORMAL
2022-11-21T18:41:25.145514+00:00
2022-11-21T18:41:25.145545+00:00
91
false
# Complexity\n- Time complexity:\n$$o(1)$$\n\n- Space complexity:\n$$o(1)$$\n\n# Code\n```\npublic class Solution {\n public int NumberOfRounds(string loginTime, string logoutTime) {\n var t1 = ToInt(loginTime);\n var t2 = ToInt(logoutTime);\n if (t2 < t1)\n t2 += 60*24;\n if (...
2
0
['C#']
0
the-number-of-full-rounds-you-have-played
c++ | easy | short
c-easy-short-by-venomhighs7-2n7y
\n\n# Code\n\nclass Solution {\npublic:\n int numberOfRounds(string loginTime, string logoutTime) {\n int INtime = ((loginTime[0]-\'0\')*10+loginTime[
venomhighs7
NORMAL
2022-11-03T03:52:10.948931+00:00
2022-11-03T03:52:10.948977+00:00
409
false
\n\n# Code\n```\nclass Solution {\npublic:\n int numberOfRounds(string loginTime, string logoutTime) {\n int INtime = ((loginTime[0]-\'0\')*10+loginTime[1]-\'0\')*60 + (loginTime[3]-\'0\')*10+loginTime[4]-\'0\';\n int OUTtime = ((logoutTime[0]-\'0\')*10+logoutTime[1]-\'0\')*60 + (logoutTime[3]-\'0\')*1...
2
0
['C++']
0
the-number-of-full-rounds-you-have-played
c++ | taking care for first and last hour , remaining hours contribute 4
c-taking-care-for-first-and-last-hour-re-t1pv
\nclass Solution {\npublic:\n int first(int m){\n if(m>45)return 0;\n if(m>30)return 1;\n if(m>15)return 2;\n if(m>0)return 3;\n
vishwasgajawada
NORMAL
2021-06-20T04:56:12.771246+00:00
2021-06-25T11:07:56.161605+00:00
103
false
```\nclass Solution {\npublic:\n int first(int m){\n if(m>45)return 0;\n if(m>30)return 1;\n if(m>15)return 2;\n if(m>0)return 3;\n return 4;\n }\n int last(int m){\n if(m<15)return 0;\n if(m<30)return 1;\n if(m<45)return 2;\n if(m<60)return 3;\n ...
2
2
['C', 'C++']
1
the-number-of-full-rounds-you-have-played
c++ Intuitive Solution
c-intuitive-solution-by-yam_malla-n17m
\n```\nclass Solution {\npublic:\n int numberOfRounds(string startTime, string finishTime) {\n int res = 0;\n int h1, m1, h2, m2;\n h1 =
yam_malla
NORMAL
2021-06-20T04:36:27.020860+00:00
2021-06-20T04:36:48.698424+00:00
79
false
\n```\nclass Solution {\npublic:\n int numberOfRounds(string startTime, string finishTime) {\n int res = 0;\n int h1, m1, h2, m2;\n h1 = stoi(startTime.substr(0,2));\n m1 = stoi(startTime.substr(3));\n \n h2 = stoi(finishTime.substr(0,2));\n m2 = stoi(finishTime.subst...
2
1
[]
0
the-number-of-full-rounds-you-have-played
4 Lines Javascript Solution
4-lines-javascript-solution-by-ashish132-49f2
\nJavaScript 0(1) Solution\n\n\n\n\n\nvar numberOfRounds = function(startTime, finishTime) {\n var start=60*parseInt(startTime.slice(0,2))+parseInt(startTime
Ashish1323
NORMAL
2021-06-20T04:20:40.585661+00:00
2021-06-20T04:20:40.585687+00:00
250
false
\n**JavaScript 0(1) Solution**\n\n\n![image](https://assets.leetcode.com/users/images/64b3fd37-bc2b-43cc-a0bf-b63ee7f31876_1624162827.384518.png)\n\n```\nvar numberOfRounds = function(startTime, finishTime) {\n var start=60*parseInt(startTime.slice(0,2))+parseInt(startTime.slice(3))\n var end=60*parseInt(finishTi...
2
1
['Math', 'JavaScript']
3
the-number-of-full-rounds-you-have-played
Meaningful variable names | Easy to understand | straightforward and clean | Java
meaningful-variable-names-easy-to-unders-f5nj
\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int startHour = Integer.parseInt(startTime.substring(0, 2));\n
cool_leetcoder
NORMAL
2021-06-20T04:12:35.622574+00:00
2021-06-20T04:13:42.900552+00:00
82
false
```\nclass Solution {\n public int numberOfRounds(String startTime, String finishTime) {\n int startHour = Integer.parseInt(startTime.substring(0, 2));\n int startMinute = Integer.parseInt(startTime.substring(3, 5));\n\n\n int finishHour = Integer.parseInt(finishTime.substring(0, 2));\n i...
2
1
[]
1
the-number-of-full-rounds-you-have-played
Simple math solution
simple-math-solution-by-rohity821-imyo
Code
rohity821
NORMAL
2025-01-08T05:07:52.971804+00:00
2025-01-08T05:07:52.971804+00:00
29
false
# Code ```swift [] class Solution { func convertTimeStringToMinutes(_ timeString: String) -> Int { let split = timeString.split(separator: ":") return (Int(split[0]) ?? 0) * 60 + (Int(split[1]) ?? 0) } func numberOfRounds(_ loginTime: String, _ logoutTime: String) -> Int { var star...
1
0
['Math', 'String', 'Swift']
0
the-number-of-full-rounds-you-have-played
Easy solution to understand
easy-solution-to-understand-by-shahchaya-wd6u
Code\n\nclass Solution {\npublic:\n int numberOfRounds(string s, string f) {\n stringstream geek(s.substr(0,2));\n int x = 0;\n geek>>x;
shahchayan9
NORMAL
2024-06-22T09:32:56.660333+00:00
2024-06-22T09:32:56.660379+00:00
130
false
# Code\n```\nclass Solution {\npublic:\n int numberOfRounds(string s, string f) {\n stringstream geek(s.substr(0,2));\n int x = 0;\n geek>>x;\n stringstream geek1(f.substr(0,2));\n int y = 0;\n geek1>>y;\n stringstream geek2(s.substr(3,2));\n int x1 = 0;\n ...
1
0
['C++']
0
the-number-of-full-rounds-you-have-played
100% fast | Simple short code with easy explanation
100-fast-simple-short-code-with-easy-exp-ze72
Intuition\n Describe your first thoughts on how to solve this problem. \nThink of playing chess rounds like taking steps. Every 15 minutes, a new round starts.
volcanicjava
NORMAL
2023-08-13T13:28:05.280396+00:00
2023-08-13T13:28:05.280432+00:00
184
false
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThink of playing chess rounds like taking steps. Every 15 minutes, a new round starts. The code takes your start and end times, and it figures out how many steps you took in terms of these 15-minute rounds:\n-> It checks when you started ...
1
0
['Math', 'C++']
0
the-number-of-full-rounds-you-have-played
Java straightforward bruteforce 33 lines
java-straightforward-bruteforce-33-lines-fm06
java\npublic class Solution {\n public int numberOfRounds(String loginTime, String logoutTime) {\n int start = convert(loginTime);\n int end =
ablaze6334
NORMAL
2023-07-19T16:33:00.752502+00:00
2023-07-19T16:33:00.752530+00:00
171
false
```java\npublic class Solution {\n public int numberOfRounds(String loginTime, String logoutTime) {\n int start = convert(loginTime);\n int end = convert(logoutTime);\n \n if (start > end) {\n return numberOfRounds(loginTime, "24:00") + numberOfRounds("00:00", logoutTime);\n ...
1
0
['Java']
1
the-number-of-full-rounds-you-have-played
python3
python3-by-excellentprogrammer-cla4
\nclass Solution:\n def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:\n a=int(loginTime[0]+loginTime[1])*60+int(loginTime[3]+loginTime
ExcellentProgrammer
NORMAL
2022-08-22T09:55:10.595535+00:00
2022-08-22T09:55:10.595601+00:00
178
false
```\nclass Solution:\n def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:\n a=int(loginTime[0]+loginTime[1])*60+int(loginTime[3]+loginTime[4])\n b=int(logoutTime[0]+logoutTime[1])*60+int(logoutTime[3]+logoutTime[4])\n if (a>b):b+=24*60\n q, r = divmod(a, 15)\n a, b =...
1
0
[]
0
the-number-of-full-rounds-you-have-played
c++||easy solution ||comments
ceasy-solution-comments-by-gauravkumart-j1fd
```\n int n1=l1.length();\n int n2=l2.length();\n string s1=l1.substr(0,2);\n string s2=l2.substr(0,2);\n string t1=l1.substr(3,n1);
gauravkumart
NORMAL
2022-07-18T08:31:05.468070+00:00
2022-07-18T08:31:05.468104+00:00
112
false
```\n int n1=l1.length();\n int n2=l2.length();\n string s1=l1.substr(0,2);\n string s2=l2.substr(0,2);\n string t1=l1.substr(3,n1);\n string t2=l2.substr(3,n2);\n int res1=stoi(s1);\n int res2=stoi(s2);\n int tt1=stoi(t1);\n int tt2=stoi(t2);\n int ...
1
0
[]
0
the-number-of-full-rounds-you-have-played
[Python] straightforward, parse string
python-straightforward-parse-string-by-o-1mbh
\nclass Solution:\n def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:\n login = self.to_min(loginTime)\n logout = self.to_min(l
opeth
NORMAL
2022-06-25T16:40:08.495299+00:00
2022-06-25T16:40:08.495325+00:00
272
false
```\nclass Solution:\n def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:\n login = self.to_min(loginTime)\n logout = self.to_min(logoutTime)\n \n if logout < login: # new day after midnight\n logout = logout + 24 * 60\n \n if logout - login < ...
1
0
['Python', 'Python3']
0