Leetcode problem 136 - Final Prices With a Special Discount in a Shop
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
Given the root of an n-ary tree, return the postorder traversal of its nodes’ values.
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
A string is a valid parentheses string (denoted VPS) if it meets one of the following:
A valid parentheses string is either empty “”, “(“ + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points...
You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and int...
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that c...
You are given a sorted unique integer array nums.
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a sin...
You are given an array nums consisting of positive integers.
You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. Mo...
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://lee...
There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] den...
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is...
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twi...
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
You are given an m x n matrix grid consisting of positive integers.
Given a square matrix mat, return the sum of the matrix diagonals.
You are given an n x n integer matrix grid.
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. ...
Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s.
You are given an array nums consisting of positive integers.
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
AGiven a string s consisting only of characters a, b and c.
A teacher is writing a test with n true/false questions, with ‘T’ denoting true and ‘F’ denoting false. He wants to confuse the students by maximizing the nu...
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.
A string is good if there are no repeated characters.
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of i...
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / ...
You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromi...
Write a function that reverses a string. The input string is given as an array of characters s.
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the othe...
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string “”.
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inc...
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j]...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n in...
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112...
There is a special typewriter with lowercase English letters ‘a’ to ‘z’ arranged in a circle with a pointer. A character can only be typed if the pointer is ...
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is m...
You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a charac...
You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your scor...
You are given a positive integer num consisting only of digits 6 and 9.
Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters.
You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leadi...
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher’s h-index.
You are given a 0-indexed array of integers nums of length n. You are initially positioned at nums[0].
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.
Given an array nums of size n, return the majority element.
Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative...
Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative orde...
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and ...
You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, t...
You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part.
You are given two 0-indexed integer permutations A and B of length n.
You are given the logs for users’ actions on LeetCode, and an integer k. The logs are represented by a 2D integer array logs where each logs[i] = [IDi, timei...
Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:
You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions:
There are n people that are split into some unknown number of groups. Each person is labeled with a unique ID from 0 to n - 1.
You are given a 0-indexed array words consisting of distinct strings.
There are n rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from 0 to 9.
You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear...
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows:
A pangram is a sentence where every letter of the English alphabet appears at least once.
You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff. A triplet (i, j, k) is an arithmetic triplet if the following ...
You are given the strings key and message, which represent a cipher key and a secret message, respectively. The steps to decode message are as follows:
There is a stream of n (idKey, value) pairs arriving in an arbitrary order, where idKey is an integer between 1 and n and value is a string. No two pairs hav...
A sentence is a list of words that are separated by a single space with no leading or trailing spaces. Each of the words consists of only uppercase and lower...
Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.
You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item. You are also given a rule rep...
You are given a string s and an integer array indices of the same length. The string s will be shuffled such that the character at the ith position moves to ...
Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters.
Given two arrays of integers nums and index. Your task is to create target array under the following rules:
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j]...
Given a positive integer n, return the smallest positive integer that is a multiple of both 2 and n.
You want to water n plants in your garden with a watering can. The plants are arranged in a row and are labeled from 0 to n - 1 from left to right where the ...
You are given an integer array prices where prices[i] is the price of a given stock on the ith day.
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were ...
You are given an integer array nums. You are initially positioned at the array’s first index, and each element in the array represents your maximum jump leng...
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
Given an integer number n, return the difference between the product of its digits and the sum of its digits.
Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it. That is, for each nums[i] you have to count the number of ...
Given a 0-indexed integer array nums, find a 0-indexed integer array answer where:
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
You own a Goal Parser that can interpret a string command. The command consists of an alphabet of “G”, “()” and/or “(al)” in some order. The Goal Parser will...
Table: DailySales
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. ...
There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer...
Given an array of integers nums, return the number of good pairs.
You’re given strings jewels representing the types of stones that are jewels, and stones representing the stones you have. Each character in stones is a type...
There is a programming language with only four operations and one variable X:
You are given two integers, num and t.
Given the array nums consisting of 2n elements in the form [x1,x2,…,xn,y1,y2,…,yn].
You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.
Given a valid (IPv4) IP address, return a defanged version of that IP address.
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n ...
Table: Products
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and r...
There are n employees in a company, numbered from 0 to n - 1. Each employee i has worked for hours[i] hours in the company.
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Given an integer x, return true if x is a palindrome, and false otherwise.
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the othe...
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements.
You have a long flowerbed in which some of the plots are planted, and some are not. However, flowers cannot be planted in adjacent plots.
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Given an array nums of size n, return the majority element.
You are climbing a staircase. It takes n steps to reach the top.
You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most ...
Given an integer array nums and an integer val, remove all occurrences of val in nums in-place. The order of the elements may be changed. Then return the num...
Given a function fn, an array or arguments args, and a timeout t in milliseconds, return a cancel function cancelFn.
Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds. It can resolve any value.
Given two promises promise1 and promise2, return a new promise. promise1 and promise2 will both resolve with a number. The returned promise should resolve wi...
Given a function fn, return a memoized version of that function.
Write a function argumentsLength that returns the count of arguments passed to it.
Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at most once.
Given an array of functions [f1, f2, f3, …, fn], return a new function fn that is the function composition of the array of functions.
Given an integer array nums, a reducer function fn, and an initial value init, return a reduced array.
Given an integer array arr and a filtering function fn, return a filtered array filteredArr.
Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each element.
Write a function createCounter. It should accept an initial integer init. It should return an object with three functions.
Write a function expect that helps developers test their code. It should take in any value val and return an object with the following two functions.
Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent tim...
Write a function createHelloWorld. It should return a new function that always returns “Hello World”.
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
Given the head of a singly linked list, return the middle node of the linked list.
Given an integer num, return the number of steps to reduce it to zero.
Fizz Buzz
Inventory Update
Longest Common Prefix
Counter
Valid Parentheses
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
A valid parentheses string is either empty “”, “(“ + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points...
You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and int...
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that c...
You are given a sorted unique integer array nums.
You are given an array nums consisting of positive integers.
A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. Mo...
There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] den...
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is...
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twi...
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
You are given an m x n matrix grid consisting of positive integers.
Given a square matrix mat, return the sum of the matrix diagonals.
You are given an n x n integer matrix grid.
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. ...
Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s.
You are given an array nums consisting of positive integers.
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.
You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string “”.
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j]...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is m...
You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.
You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your scor...
Array
A string is a valid parentheses string (denoted VPS) if it meets one of the following:
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a sin...
You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://lee...
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is...
AGiven a string s consisting only of characters a, b and c.
A teacher is writing a test with n true/false questions, with ‘T’ denoting true and ‘F’ denoting false. He wants to confuse the students by maximizing the nu...
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
A string is good if there are no repeated characters.
Write a function that reverses a string. The input string is given as an array of characters s.
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the othe...
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string “”.
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inc...
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n in...
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112...
There is a special typewriter with lowercase English letters ‘a’ to ‘z’ arranged in a circle with a pointer. A character can only be typed if the pointer is ...
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a charac...
Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters.
Linked List
Hash maps
Control flow
Given a function fn, an array or arguments args, and a timeout t in milliseconds, return a cancel function cancelFn.
Promise
Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds. It can resolve any value.
Array methods
Given two promises promise1 and promise2, return a new promise. promise1 and promise2 will both resolve with a number. The returned promise should resolve wi...
Given a function fn, return a memoized version of that function.
Write a function argumentsLength that returns the count of arguments passed to it.
Given a function fn, return a new function that is identical to the original function except that it ensures fn is called at most once.
Given an array of functions [f1, f2, f3, …, fn], return a new function fn that is the function composition of the array of functions.
Given an integer array nums, a reducer function fn, and an initial value init, return a reduced array.
Given an integer array arr and a filtering function fn, return a filtered array filteredArr.
Given an integer array arr and a mapping function fn, return a new array with a transformation applied to each element.
Write a function createCounter. It should accept an initial integer init. It should return an object with three functions.
Write a function expect that helps developers test their code. It should take in any value val and return an object with the following two functions.
Given an integer n, return a counter function. This counter function initially returns n and then returns 1 more than the previous value every subsequent tim...
Write a function createHelloWorld. It should return a new function that always returns “Hello World”.
TypeError: req.session.regenerate is not a function
JWT (Json Web Token)?
Create react app named client in the root project folder using create-react-app command
The project manager is for management of projects which user can add, view, edit and delete (CRUD functions) a project. This project is used React, bootstrap...
Make components folder underneath src. And then, make a file named counter.jsx
Composing components
Passing event arguments
Increment a number
This is from counter app. render() { let classes = "bg m-2 bg-"; classes += this.state.count === 0 ? "warning" : "primary"; return ( &...
How to render list of items in React
This posting will show you how to apply CSS in two ways, and this is what I learned applying CSS in react project so far. There are two ways more, but these ...
This posting is going to explain how to use components in React.
This is the project using react I want to learn. The purpose of the project is getting familiar with react and learning how to use react features on the proj...
I can use Bootstrap which allow front-end features easily while I’m building a react app. Open the terminal and type a below code. $ npm install bootstrap
Hello World
What is React? React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It lets you compose complex UIs from small...
A valid parentheses string is either empty “”, “(“ + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points...
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a sin...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n in...
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros. For example, 101 and 1100 are deci-binary, while 112...
There is a special typewriter with lowercase English letters ‘a’ to ‘z’ arranged in a circle with a pointer. A character can only be typed if the pointer is ...
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is m...
You are given an integer array nums (0-indexed). In one operation, you can choose an element of the array and increment it by 1.
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a charac...
You are given a 0-indexed integer array nums and an integer k. Your task is to perform the following operation exactly k times in order to maximize your scor...
You are given a positive integer num consisting only of digits 6 and 9.
Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters.
You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leadi...
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique. That is, no letter appears in a sin...
You are given an array nums consisting of positive integers.
You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. Mo...
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://lee...
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twi...
Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s.
You are given an array nums consisting of positive integers.
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
AGiven a string s consisting only of characters a, b and c.
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
A string is good if there are no repeated characters.
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] den...
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is...
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twi...
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
You are given an m x n matrix grid consisting of positive integers.
Given a square matrix mat, return the sum of the matrix diagonals.
You are given an n x n integer matrix grid.
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. ...
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism. You are given a 0-indexed n x n in...
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj]. Each list of i...
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / ...
You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromi...
Write a function that reverses a string. The input string is given as an array of characters s.
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1. If a string is longer than the othe...
Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string “”.
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inc...
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j]...
Given a binary array nums and an integer k, return the maximum number of consecutive 1’s in the array if you can flip at most k 0’s.
You are given an array nums consisting of positive integers.
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
AGiven a string s consisting only of characters a, b and c.
A teacher is writing a test with n true/false questions, with ‘T’ denoting true and ‘F’ denoting false. He wants to confuse the students by maximizing the nu...
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k.
A string is good if there are no repeated characters.
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
A valid parentheses string is either empty “”, “(“ + A + “)”, or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
There are some spherical balloons taped onto a flat wall that represents the XY-plane. The balloons are represented as a 2D integer array points where points...
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that c...
A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same. Mo...
There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row represents one student and score[i][j] den...
You are given an m x n matrix grid consisting of positive integers.
Given a 0-indexed integer array nums of length n and an integer target, return the number of pairs (i, j) where 0 <= i < j < n and nums[i] + nums[j]...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is m...
You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leadi...
You are given an array nums consisting of positive integers.
Anti-theft security devices are activated inside a bank. You are given a 0-indexed binary string array bank representing the floor plan of the bank, which is...
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2]. Each integer appears exactly once except a which appears twi...
Given an array of integers nums and an integer k. A continuous subarray is called nice if there are k odd numbers on it.
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions:
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromi...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
You are given a positive integer num consisting only of digits 6 and 9.
You are given a positive integer num consisting of exactly four digits. Split num into two new integers new1 and new2 by using the digits found in num. Leadi...
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
Given the root of an n-ary tree, return the postorder traversal of its nodes’ values.
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
A string is a valid parentheses string (denoted VPS) if it meets one of the following:
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / ...
TypeError: req.session.regenerate is not a function
JWT (Json Web Token)?
Create react app named client in the root project folder using create-react-app command
The project manager is for management of projects which user can add, view, edit and delete (CRUD functions) a project. This project is used React, bootstrap...
TypeError: req.session.regenerate is not a function
JWT (Json Web Token)?
Create react app named client in the root project folder using create-react-app command
The project manager is for management of projects which user can add, view, edit and delete (CRUD functions) a project. This project is used React, bootstrap...
TypeError: req.session.regenerate is not a function
JWT (Json Web Token)?
Create react app named client in the root project folder using create-react-app command
The project manager is for management of projects which user can add, view, edit and delete (CRUD functions) a project. This project is used React, bootstrap...
TypeError: req.session.regenerate is not a function
JWT (Json Web Token)?
Create react app named client in the root project folder using create-react-app command
The project manager is for management of projects which user can add, view, edit and delete (CRUD functions) a project. This project is used React, bootstrap...
Render provides free plan for PostgreSQL, but there is a time limit for free plan. I can use it only for 3 month which means I need to recreate every 3 month...
Datatype
What is PostgreSQL?
I’ve collected some useful commands for capitalizing on postgresql. It’s going to keep updating whenever I found a command I need.
You are given an m x n matrix grid consisting of positive integers.
You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
You are given a 0-indexed integer array nums and an integer pivot. Rearrange nums such that the following conditions are satisfied:
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
This posting is for getting used to HTML & HTML5.
Markup language Markup Language is a type of language that defines rules for indicating the format in which documents are displayed on the screen or speci...
You are given two strings of the same length s and t. In one step you can choose any character of t and replace it with another character.
A string is good if there are no repeated characters.
Balanced strings are those that have an equal quantity of ‘L’ and ‘R’ characters.
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Heading Heading1 Heading2 Heading3 Heading4 Heading5 Heading6
Markup language Markup Language is a type of language that defines rules for indicating the format in which documents are displayed on the screen or speci...
This page will be my journal learning bootstrap responsive CSS framework.
I can use Bootstrap which allow front-end features easily while I’m building a react app. Open the terminal and type a below code. $ npm install bootstrap
Property Values
This posting will show you how to apply CSS in two ways, and this is what I learned applying CSS in react project so far. There are two ways more, but these ...
The problem I had while developing - Cross Origin Resource Sharing (CORS)
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where:
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it. In one operation, you can replace a charac...
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
A teacher is writing a test with n true/false questions, with ‘T’ denoting true and ‘F’ denoting false. He wants to confuse the students by maximizing the nu...
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://lee...
Implement the class SubrectangleQueries which receives a rows x cols rectangle as a matrix of integers in the constructor and supports two methods:
Given the root of an n-ary tree, return the postorder traversal of its nodes’ values.
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
Given the root of an n-ary tree, return the postorder traversal of its nodes’ values.
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
Array
What is React? React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It lets you compose complex UIs from small...
What is React? React is a declarative, efficient, and flexible JavaScript library for building user interfaces. It lets you compose complex UIs from small...
Markup language Markup Language is a type of language that defines rules for indicating the format in which documents are displayed on the screen or speci...
Hello World
This is the project using react I want to learn. The purpose of the project is getting familiar with react and learning how to use react features on the proj...
This posting is going to explain how to use components in React.
How to render list of items in React
How to render list of items in React
This is from counter app. render() { let classes = "bg m-2 bg-"; classes += this.state.count === 0 ? "warning" : "primary"; return ( &...
Increment a number
Composing components
What is RDS?
What is RDS?
This posting is for getting used to HTML & HTML5.
Property Values
JWT (Json Web Token)?
TypeError: req.session.regenerate is not a function
I’m going to deploy my web application with Netlify and Heroku which provide free plan for an individual project. These can be alternative way to show my pro...
I’m going to deploy my web application with Netlify and Heroku which provide free plan for an individual project. These can be alternative way to show my pro...
I’m going to deploy my web application with Netlify and Heroku which provide free plan for an individual project. These can be alternative way to show my pro...
I’ve collected some useful commands for capitalizing on postgresql. It’s going to keep updating whenever I found a command I need.
Datatype
Render provides free plan for PostgreSQL, but there is a time limit for free plan. I can use it only for 3 month which means I need to recreate every 3 month...
Array methods
Promise
Python is dynamically typed, which means I don’t need to explicitly declare the data type of a variable. Python will infer the data type based on the assigne...
Web workers
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), …, (an, bn) such that the sum of min(ai, bi) for all i is m...
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows:
In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / ...
You are given a 0-indexed integer array nums. A pair of integers x and y is called a strong pair if it satisfies the condition:
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase. For example, “abABB” is nice because ‘A’...
A teacher is writing a test with n true/false questions, with ‘T’ denoting true and ‘F’ denoting false. He wants to confuse the students by maximizing the nu...
You are given an m x n matrix grid consisting of positive integers.
Note: This is a companion problem to the System Design problem: Design TinyURL. TinyURL is a URL shortening service where you enter a URL such as https://lee...
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
Given the root of a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now the root of the tree, and every node has ...
You are given an integer array prices where prices[i] is the price of the ith item in a shop.