# Questions tagged [programming-challenge]

Programming challenges are off-site challenges meant to offer programmers educational experiences while testing their abilities.

2,651 questions
Filter by
Sorted by
Tagged with
1answer
38 views

### LeetCode: Group Anagrams C#

LeetCode: Group Anagrams C# Given an array of strings, group anagrams together. ...
1answer
50 views

### Forming words that start with consonants and vowels

I am just starting to learn programming. I had already coded some functions and stuff in other languages, and whilst trying to complete this Python challenge Kevin and Stuart want to play the 'The ...
7answers
3k views

### LeetCode: Pascal's Triangle C#

https://leetcode.com/explore/interview/card/top-interview-questions-easy/99/others/601/ In Pascal's triangle, each number is the sum of the two numbers directly above it. Example: ...
0answers
41 views

### Plus One LinkedList [on hold]

Given a non-negative number represented as a singly linked list of digits, plus one to the number. The digits are stored such that the most significant digit is at the head of the list. ...
0answers
68 views

### Custom Knight dialer solution's time and space complexity

I recently solved the Knight Dialer problem but I'm not quite sure if I got the time complexity right; hence I'm requesting the following: 1) Time and space complexity review and explanation on why ...
0answers
45 views

### Find minimum number of rooms required

Problem statement is as follows Given an array of time intervals (start, end) for classroom lectures (possibly overlapping), find the minimum number of rooms required. For example, given [(30, ...
3answers
66 views

### C++ For Euler Problem 3

Here's my solution for Euler Problem 3: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? I'm using the Euler problems to learn ...
4answers
357 views

### Rotate List by K places

I am trying to solve the question at :https://leetcode.com/problems/rotate-list/ Question: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1:...
1answer
62 views

### LeetCode #37: Sudoku as Exact Cover Problem solved using Dancing Links

Introduction I provide a regular 9x9 Sudoku solver, reducing the puzzle to an Exact Cover Problem. The algorithm used is Knuth'...
2answers
87 views

### Project Euler # 62 Cubic permutations in Python

The cube, 41063625 ($345^3$), can be permuted to produce two other cubes: 56623104 ($384^3$) and 66430125 ($405^3$). In fact, 41063625 is the smallest cube which has exactly three permutations ...
3answers
72 views

### Project Euler Problem #50 Consecutive Prime Sums

Problem: Which prime, below one-million, can be written as the sum of the most consecutive primes? At the moment my code runs for over 200 seconds and was wondering how I can find a way to bring that ...
3answers
106 views

### Find the first missing positive integer in an array of integers

The problem is the one explained in Given an unsorted integer array, find the first missing positive integer Given an unsorted integer array, find the first missing positive integer. For ...
0answers
36 views

### Requesting inputs on improving leetcode's hashset implementation [on hold]

Leetcode question details.Implented hashset as per leetcode. Looking for critical feedback, improvement suggestions and recommended refactoring. ...
2answers
73 views

### Banking application for Udemy Java course

I just "finished" a Udemy Java that involves building a banking application. Here is the problem definition: Scenario: You are a back-end developer and need to create an application to handle new ...
1answer
70 views

### How can I make my solution to “Climbing the Leaderboard” not time out?

I tried to solve the following challenge and optimize the solution but my code still times out. My code is below. Problem statement Climbing the Leaderbord Alice is playing an arcade game and ...
4answers
3k views

### Sum Square Difference, which way is more Pythonic?

I'm using python 3 and I am creating an algorithm to find the sum square difference for the first 100 (or 1 to x) natural numbers. This happens to be project euler problem 6 if anyone is wondering. I'...
1answer
58 views

### Project Euler #5 Optimized

I have seen multiple questions on this problem but none seem to answer my specific question. To start, the basic question is asking to find the smallest number that is divisible by numbers 1 to 20. ...
2answers
112 views

### LeetCode: Linked List Cycle

Challenge https://leetcode.com/explore/interview/card/top-interview-questions-easy/93/linked-list/773/ Given a linked list, determine if it has a cycle in it. To represent a cycle in the ...
2answers
137 views

### Code Challenge: basic arithmic operations using only incrementation operator

Challenge Write a function that takes 2 integer operands left and right (both >= 0) and evaluates one of the following ...
3answers
354 views

### Project Euler # 15 Lattice paths in Python

Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. How many such routes are there through a 20×20 ...
1answer
51 views

### Project Euler # 11 largest product in a grid in Python

In the 20×20 grid below, four numbers along a diagonal line have been marked in red. The product of these numbers is 26 × 63 × 78 × 14 = 1788696. What is the greatest product of four adjacent numbers ...
1answer
58 views

### Hex string to Base64 in Haskell

This is my take on the first challenge on the cryptopals crypto challenges list. I think that i made it quite simple but i feel like it is possible to optimize it further. Any suggestion? The code: ...
2answers
62 views

### Least Recently Used Cache Daily Coding Practice

I have the following challenge problem for which I was able to get a solution working, but not in $O(1)$ time as the problem asks for. Could someone point me in the right direction to optimize this?...
0answers
43 views

### Solution to 3Sum problem on Leetcode using HashTable

The problem of 3sum is described as: 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 of zero....
0answers
37 views

### Rosalind - Finding a Shared Motif

Here is my attempt to implement the Ukkonen algorithm for the Finding a Shared Motif problem on rosalind.info. The code works, it produces a correct answer. It does so in 11 seconds. I am hoping to ...
2answers
82 views

### Project Euler # 74 Digit factorial chains in Python

The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145: 1! + 4! + 5! = 1 + 24 + 120 = 145 Perhaps less ...
3answers
2k views

### HackerRank Implement Queue using two stacks Solution

Challenge Problem Statement - Implement a Queue using two Stacks I implemented dequeue() in $O(1)$ at the cost of enqueue() ...
1answer
56 views

### Project Euler - Problem No.5 - Smallest multiple

Here's the problem at hand: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly ...
0answers
504 views

### Function to sum values of most significant digit contained

ABOUT For each subsequence, look at its position in the original decimal representation of $x$. Let's say that the most significant digit it contained was the $e$-th digit, where $e=0$ ...
1answer
51 views

### Solution to LeetCode Next Greater Element Ⅰ in Python

This is my solution to LeetCode's "Next Greater Element Ⅰ": You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater ...
1answer
58 views

### Project Euler - Problem No.4 - Largest palindrome product

according to the problem: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made ...
1answer
2k views

### Raindrops in Python

There's this simple coding challenge that feels like a twist on FizzBuzz. Your task is to convert a number to a string, the contents of which depends on the number's factors. If the number has 3 ...
2answers
52 views

### Project Euler - Problem 3

The description of the problem is: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? Here is my solution: ...
1answer
104 views

### Python Implementation: Summer of 69

SUMMER OF '69: Return the sum of the numbers in the array, except ignore sections of numbers starting with a 6 and extending to the next 9 (every 6 will be followed by at least one 9). Return 0 ...
2answers
79 views

### Project Euler # 67 Maximum path sum II (Bottom up) in Python

This is Project Euler #67: Maximum path sum II: By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 ...
0answers
82 views

### Digit Sum find number of ways and max people

I applied for a job, and the prospective employer sent me the following HackerRank problem, which cannot be found in the public area. There is a lottery with n ...
1answer
49 views

### Project Euler # 55 Lychrel numbers in Python

If we take 47, reverse and add, 47 + 74 = 121, which is palindromic. Not all numbers produce palindromes so quickly. For example, 349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337 That is, ...
2answers
85 views

### Project Euler # 54 Poker hands in Python

In the card game poker, a hand consists of five cards and are ranked, from lowest to highest, in the following way: High Card: Highest value card. One Pair: Two cards of the same value. Two Pairs: ...
1answer
134 views

### CtCI 16.8: Integer to English phrase in C++

I'm a C++ beginner working through Cracking the Coding Interview. This is question 16.8: Given any integer, print an English phrase that describes the integer (e.g., "One Thou­sand, Two Hundred ...
2answers
56 views

### Project Euler # 56 Powerful digit sum in Python

A googol ($10^{100}$) is a massive number: one followed by one-hundred zeros; $100^{100}$ is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits ...
0answers
44 views

### Algorithm X implementation for Minimum Dominating Set

As as final project for a MOOC I wanted to write a program that finds the exact cover set/minimum dominating set from the given social network data. So I did end up with writing this. I kinda followed ...
3answers
366 views

### Print sums of all subsets

Print sums of all subsets of a given set Problem summary : Print all subset sums of a given set of integers My approach is to store previous results and use them to calculate new (similar idea as ...
1answer
49 views

### Project Euler # 53 Combinatoric selections in Python

There are exactly ten ways of selecting three from five, 12345: 123, 124, 125, 134, 135, 145, 234, 235, 245, and 345 In combinatorics, we use the notation, 5C3=10. In general, nCr = n! / r! (n−r)!, ...
1answer
58 views

### Challenge - Construct binary tree from array [closed]

A coding challenge to construct a binary tree from an array. ...
2answers
55 views

### Project Euler # 52 Permuted multiples in Python

It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, ...
2answers
113 views

### Challenge: phone keypad to letters - return all possible strings

The challenge: Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent. You can assume each valid number in the ...
3answers
615 views

### JavaScript Sort Stack Coding Challenge

A coding challenge to write a function sortStack that receives a stack of integers into ascending order (with largest integers on top) and returns another stack ...
1answer
96 views

### Project Euler # 50 Consecutive prime sum in Python

The prime 41, can be written as the sum of six consecutive primes: 41 = 2 + 3 + 5 + 7 + 11 + 13 This is the longest sum of consecutive primes that adds to a prime below one-hundred. The longest sum ...
1answer
223 views

### Project Euler # 49 Prime permutations in Python

The arithmetic sequence, 1487, 4817, 8147, in which each of the terms increases by 3330, is unusual in two ways: (i) each of the three terms are prime, and, (ii) each of the 4-digit numbers are ...
1answer
64 views

### Project Euler # 48 Self powers in Python

The series, $1^1 + 2^2 + 3^3 + \ldots + 10^{10} = 10405071317$. Find the last ten digits of the series, $1^1 + 2^2 + 3^3 + \ldots + 1000^{1000}$. ...