All Questions
125 questions
3
votes
2
answers
95
views
Optimizing a Function to Check Pronic Numbers in JavaScript
I've written a function in JavaScript to check whether a given number is a Pronic number. A Pronic number, also known as an oblong number, rectangular number, or ...
28
votes
7
answers
8k
views
Trapping Rain Water
This task is taken from Leetcode:
Given n non-negative integers representing an elevation map where the
width of each bar is 1, ...
1
vote
2
answers
1k
views
Leetcode 55. Jump Game solution
I was working on Jump Game problem on leetcode
Question
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 ...
4
votes
2
answers
2k
views
Given a pivot x, and a list lst, partition the list into three parts
The task:
Given a pivot x, and a list lst, partition the list into three parts.
The first part contains all elements in lst that are less than x.
The second part contains all elements in lst that are ...
3
votes
1
answer
341
views
Algorithm Challenge: Fuzzy Search
I recently took part in an algorithm challenge to create a Fuzzy search with the following criteria:
Given a set array, create a function that receives one argument and returns a new array containing ...
2
votes
3
answers
1k
views
Find the 'n' most frequent words in a text, aka word frequency
I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name.
The ...
5
votes
3
answers
3k
views
Reverse Integer
The task
is taken from leetcode
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
...
2
votes
0
answers
733
views
Determine whether there exists a one-to-one character mapping from one string to another
The task
Determine whether there exists a one-to-one character mapping from one
string s1 to another s2.
For example, given s1 = abc and s2 = bcd, return true since we can map
a to b, b to c, and c ...
5
votes
4
answers
1k
views
Confirm the ending of a string
Challenge:
Check if a string (first argument, str) ends with the given target
string (second argument, target).
This ...
11
votes
5
answers
1k
views
Easy to read palindrome checker
I made a palindrome checker that's supposed to be designed to be simple and easy to read. Please let me know what you think. I believe the time complexity is \$\mathcal{O}(n)\$ but I'm not too sure ...
8
votes
5
answers
1k
views
Expanding powers of expressions of the form ax+b
I solved the following problem:
Write a function expand that takes in an expression with a single, one character variable, and expands it. The expression is in the form ...
2
votes
1
answer
257
views
Leetcode problem: minimum removal to make valid parentheses
I was working on this problem on leetcode
Question
Your task is to remove the minimum number of parentheses ( '(' or
')', in any positions ) so that the resulting parentheses string is
valid and ...
7
votes
2
answers
3k
views
Deepest pit of an array
Following is based on a problem description from a Codility test, as a task in an interview.
DeepestPit - problem description
A non-empty zero-indexed array B ...
2
votes
3
answers
415
views
Leetcode First Unique Character in a String code optimisation
I was working on First Unique Character in a String
Question
Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1.
Example 1:
...
3
votes
2
answers
7k
views
Given time intervals, find the minimum number of conference rooms required
The task is taken from LeetCode
Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), find the minimum number of
conference rooms required.
...