Skip to main content

All Questions

Filter by
Sorted by
Tagged with
3 votes
1 answer
569 views

Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
Cory Harper's user avatar
9 votes
4 answers
3k views

"What is the maximum that Player 1 can win?"

This is a question that I encountered in one of the competitive coding tests. The question goes as follows: A 2-player game is being played. There is a single pile of stones. Every stone has an ...
User_Targaryen's user avatar
9 votes
1 answer
210 views

Tower of Hanoi with helper function

Here is my solution to the Tower of Hanoi problem using Python ...
MrJoe's user avatar
  • 2,143
3 votes
2 answers
593 views

Find the longest sub string of a word after concatenation of given words array

An Array of N words is given. Each word consists of small letters ('a'-'z'). Our goal is to concatenate the words in such a way as to obtain a single word with longest possible substring composed of ...
Ora2gaurav's user avatar
5 votes
2 answers
1k views

Finding all possible letter combinations from an inputted phone number

Prompt: 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 like on the telephone ...
springathing's user avatar
3 votes
3 answers
391 views

Find k-distinct partitions which contain at least two perfect squares

Problem Statement: A k-distinct-partition of a number \$n\$ is a set of \$k\$ distinct positive integers that add up to \$n\$. For example, the 3-distinct partitions of 10 are \$1+2+7\$ \$1+...
Phoenix's user avatar
  • 387
6 votes
2 answers
2k views

Find the second largest number in an array with at most n + log2 n - 2 comparisons

This exercise is from Roughgarden's (excellent) course on algorithms on Coursera: You are given as input an unsorted array of n distinct numbers, where n is a power of 2. Give an algorithm that ...
ajeje's user avatar
  • 161
6 votes
2 answers
5k views

Method to remove outliers from a set of values

I'm removing outliers from a set of data using the method described here. The method removes the outliers and returns the quartile values of the set after all outliers have been removed. (...
Valuator's user avatar
  • 189
6 votes
3 answers
751 views

Recursive function challenge

Problem statement Given a list of float numbers, and four operators +, -, *, / with flat preference, find the maximum value by inserting operator between each consecutive pair of numbers. For ...
Jianmin Chen's user avatar
  • 2,456
1 vote
1 answer
500 views

Reinterpreting a string, treating < as a backspace character

I've come up with a solution to this coding challenge using recursion. In summary, the input is a string where the < symbol represents a backspace (up to 1 ...
Archie Gertsman's user avatar
2 votes
3 answers
17k views

Generate all permutations of a list in Python

This is my solution to the "Permutations" problem from Leetcode: Given a collection of distinct numbers, return all possible permutations. I know this is a common routine that can be done much ...
grayQuant's user avatar
  • 222
1 vote
1 answer
850 views

Compute the number of ways a given amount (cents) can be changed

Given an infinite number of different coin types (such as pennies, nickels, dimes, quarters) find out how many ways n cents can be represented. My code appears to work (although I am curious to ...
Stack crashed's user avatar
10 votes
2 answers
4k views

Generate all valid combinations of n pair of parentheses

Implement an algorithm to print all valid (e.g. properly opened and closed) combinations of n pair of parentheses. Following is my implementation and I think it works. Is the algorithm efficient? Do ...
Stack crashed's user avatar
1 vote
1 answer
128 views

Count all possible attendance records with length n, which will be regarded as rewardable

Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, return it after \$\mod 10^9 + 7\$. ...
kumarmo2's user avatar
  • 261
1 vote
0 answers
899 views

Hackerrank > Woman's CodeSprint 2 > stone division, Revisited ( recursive function)

Problem statement You have a pile of n stones that you want to split into multiple piles, as well as a set, S, of ...
Jianmin Chen's user avatar
  • 2,456

15 30 50 per page