Hello everyone!
It’s been a long time I didn’t do any problem-solving. I looked through some websites to find new problems to solve. I have signed up in Coderbyte and solved my first problem there in JS.
I have learned endsWith() method.
And I learned about regular expression pattern and it’s test method to check whether string only contain letters, numbers, and the underscore character.
It’s been a long time I didn’t do any problem-solving. I looked through some websites to find new problems to solve. I have signed up in Coderbyte and solved my first problem there in JS.
I have learned endsWith() method.
The endsWith() method returns true if a string ends with a specified string.
And I learned about regular expression pattern and it’s test method to check whether string only contain letters, numbers, and the underscore character.
Forwarded from Poll Creator
Try to guess the answer before seeing the answer.
The output will be "122" because JavaScript treats the first "1" as a string, causing concatenation instead of addition.
I have started “30 days of JavaScript“ study plan in Leetcode. Solved four problems and finished first section. First and second problems were quite easy. I will share my solution for remaining two problems.
Let’s make 10 day challenge to solve at least one problem a day. You also can start the challenge! Let’s rock this challenge!t
Let’s make 10 day challenge to solve at least one problem a day. You also can start the challenge! Let’s rock this challenge!t
2665. Counter II
Fourth photo: Another solution I liked in Solutions section.
Fourth photo: Another solution I liked in Solutions section.
Programming notes
I have started “30 days of JavaScript“ study plan in Leetcode. Solved four problems and finished first section. First and second problems were quite easy. I will share my solution for remaining two problems. Let’s make 10 day challenge to solve at least…
LeetCode
30 Days of JavaScript - Study Plan - LeetCode
Learn JS Basics with 30 Qs
💾 Memory: 48.79 MB. Beats 59.75%
▶️ Pre-allocate Memory: By creating a new array with new Array(arr.length), we allocate the required memory upfront, which can be more efficient for large arrays.
const newArray = new Array(arr.length);
▶️ Direct Assignment: Assigning the transformed value directly to the array index avoids the overhead of the push operation.
newArray[i] = fn(arr[i], i);
Will wait for reactions
@leetcode_javascript
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
💾 Memory: 48.67 MB. Beats 81.42%
🔗 Link: https://leetcode.com/problems/filter-elements-from-array/description/?envType=study-plan-v2&envId=30-days-of-javascript
@leetcode_javascript
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Precompute length
Storing nums.length in a variable avoids recomputing the length of the array on every iteration.
This reduced runtime from 53 ms to 42 ms.
@leetcode_javascript
Storing nums.length in a variable avoids recomputing the length of the array on every iteration.
This reduced runtime from 53 ms to 42 ms.
@leetcode_javascript