Prototype in JavaScript

1 What are prototypes in JavaScript? Whenever we create objects, functions, methods, arrays and variables in JavaScript, prototype is an object that gets attached to them. Prototype has some hidden properties which we can use with whatever prototype object is attached to. I have always wondered that where do all the methods comes from in … Read more

14. Longest Common Prefix Leetcode solution in JavaSctipt (js)

0 Problem Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string “”. Example 1: Input: strs = [“flower”,”flow”,”flight”] Output: “fl” Example 2: Input: strs = [“dog”,”racecar”,”car”] Output: “” Explanation: There is no common prefix among the input strings. Constraints: Solution … Read more

13. Roman to Integer Leetcode Solution in JavaScript (js)

0 Problem Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two ones added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. Roman … Read more

12. Integer to Roman Leetcode Solution in JavaScript (js)

0 Problem : Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, 2 is written as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II. … Read more

Hoisting in JavaScript

0 Introduction Hoisting is a behavior with which JavaScript, right before it start to execute the code, add all the variables, constants, functions and Classes declaration into memory. This gives a feeling that all the declarations are hoisted or already declared, specially “var” and “function”. Hoisting affects Classes, variables and functions differently. Hoisting variables and … Read more

11. Container With Most Water Leetcode JavaScript (JS) Solution

0 Problem You are given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]). Find two lines that together with the x-axis form a container, such that the container contains the most water. Return the maximum amount of water a container can store. Notice that you may not … Read more

10. Regular Expression Matching Leetcode solution in Javascript (JS)

0 Problem Given an input string s and a pattern p, implement regular expression matching with support for ‘.’ and ‘*’ where: The matching should cover the entire input string (not partial). Example 1: Input: s = “aa”, p = “a” Output: false Explanation: “a” does not match the entire string “aa”. Example 2: Input: s = “aa”, p = “a*” Output: true Explanation: … Read more

How to install SSL certificate on nginx with PFX file on linux?

0 Let’s extract CRT file using OpenSSL command as follows: Followed by extracting private key file using another OpenSSL command as follows: Sample Server block to map generate CRT and private key files: Aadi AhlawatA freelance web developer with a decade of experience in creating high-quality, scalable web solutions. His expertise spans PHP, WordPress, Node.js, … Read more

8. String to Integer (atoi) Leetcode Solution JavaScript (JS)

0 Problem Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++’s atoi function). The algorithm for myAtoi(string s) is as follows: Note: Example 1: Input: s = “42” Output: 42 Explanation: The underlined characters are what is read in, the caret is the current reader position. Step 1: “42” (no characters read because … Read more

7. Reverse Integer Leetcode Solution in JavaScript (JS)

0 Problem Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 – 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). Example 1: Input: x = 123 Output: 321 Example 2: Input: x = … Read more

Skip to content