Skip to main content

All Questions

4 votes
1 answer
1k views

Leetcode three sum in Javascript

I was doing 3sum question on leetcode Question Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum ...
iRohitBhatia's user avatar
5 votes
2 answers
520 views

Frequency Queries (Hackerrank)

This is the problem: You are given queries. Each query is of the form two integers described below: 1 x: Insert x in your data structure. 2 y: Delete one occurrence of y from your data ...
daksh bhardwaj's user avatar
5 votes
2 answers
2k views

Process strings of operations

This was the task (I don't know the exact wordings anymore): You get a string with operation as input: if it is a number push it to stack if it is "DUP", then duplicate the one one top and ...
thadeuszlay's user avatar
  • 3,981
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 ...
haxor's user avatar
  • 111
3 votes
1 answer
1k views

Shortest way to form a string out of a subsequence of a string

The task is taken from LeetCode (subscription required) - From any string, we can form a subsequence of that string by deleting some number of characters (possibly no deletions). Given two strings ...
thadeuszlay's user avatar
  • 3,981
6 votes
4 answers
3k views

Find all letter Combinations of a Phone Number

The task is taken from LeetCode Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters (just ...
thadeuszlay's user avatar
  • 3,981
2 votes
1 answer
758 views

Given time intervals determine if a person could attend all meetings

The task is taken from LeetCode Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] ...
thadeuszlay's user avatar
  • 3,981
5 votes
1 answer
8k views

Merge Two Sorted Lists in JavaScript

The task is taken from LeetCode Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Example 1: ...
thadeuszlay's user avatar
  • 3,981
8 votes
1 answer
2k views

Merge Intervals in JavaScript

This is a task taken from Leetcode - Given a collection of intervals, merge all overlapping intervals. Example 1: ...
thadeuszlay's user avatar
  • 3,981
1 vote
3 answers
545 views

Jewels and Stones

The task is taken from leetcode You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have....
thadeuszlay's user avatar
  • 3,981
5 votes
1 answer
323 views

Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up

The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
thadeuszlay's user avatar
  • 3,981
2 votes
1 answer
266 views

Number of Islands

The task is taken from leetcode Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands ...
thadeuszlay's user avatar
  • 3,981
2 votes
1 answer
477 views

Length of the longest consecutive run of 1s in its binary representation

The task Given an integer n, return the length of the longest consecutive run of 1s in its binary representation. For example, given 156, you should return 3 My function solution 1 Style 1 <...
thadeuszlay's user avatar
  • 3,981
3 votes
1 answer
633 views

Longest Consecutive Sequence

This task is taken from Leetcode - Given an unsorted array of integers, find the length of the longest consecutive elements sequence. Your algorithm should run in \$O(n)\$ complexity. ...
thadeuszlay's user avatar
  • 3,981
1 vote
1 answer
138 views

Daily Temperatures

The task is taken from leetcode Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer ...
thadeuszlay's user avatar
  • 3,981

15 30 50 per page
1
2 3 4 5