Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [programming-challenge]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
53 views

Function to take a positive integer and return the next bigger number formed by the same digits

I've written a solution to a Codewars challenge: You have to create a function that takes a positive integer number and returns the next bigger number formed by the same digits: 12 ==> 21; 513 ...
1
vote
1answer
56 views

LeetCode: Shortest Common Supersequence C#

https://leetcode.com/problems/shortest-common-supersequence/ Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences. If multiple answers exist, ...
6
votes
2answers
61 views

Atbash Cipher in Rust - Exercism exercise

So I'm working on an implementation of the Atbash Cipher for Rust - it is an exercise on exercism.io. I come from a little C experience and found my code to be rather round about and kind of tortured. ...
1
vote
0answers
42 views

LeetCode: Daily Temperatures C#

https://leetcode.com/problems/daily-temperatures/ 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 ...
-1
votes
2answers
57 views

Hackerearth challenge - Roy and Code Streak

Roy is working on HackerEarth Profile. Right now he is working on User Statistics. One of the statistics data (Code Streak) is as follows: Given the User Activity Data, find the maximum number ...
2
votes
1answer
69 views

LeetCode: Greatest Common Divisor of Strings C#

https://leetcode.com/problems/greatest-common-divisor-of-strings/ For strings S and T, we say "T divides S" if and only if S = T + ... + T (T concatenated with itself 1 or more times) ...
3
votes
2answers
145 views

LeetCode: Diameter of Binary Tree

https://leetcode.com/problems/diameter-of-binary-tree/ Given a binary tree, you need to compute the length of the diameter of the tree. The diameter of a binary tree is the length of the longest ...
1
vote
1answer
48 views

Add a value to each of the array element between two given indices successively

I am trying to solve the HackerRank: Array Manipulation problem using Java. The problem that I am facing is that the program is running for half of the test cases, while for the other half it is ...
2
votes
1answer
31 views

Merge adjacent occurrences of identical elements in data collection

There is a small programming exercise to merge adjacent identical elements in a collection. Here are two solutions (passing the tests from the exercise). I am asking for review of the first version ...
2
votes
0answers
57 views

WARNING - Codewars Kata - spoiler - getting to next level pythonic

The challenge: You managed to send your friend to queue for tickets in your stead, but there is a catch: he will get there only if you tell him how much that is going to take. And everybody can ...
2
votes
3answers
301 views

Perform a predetermined set of operations on a large sequence

This is a programming challenge. I have been given the following input: \$n\$ where n is size of sequence \$k\$ is an integer a sequence \$A_0, A_1, A_2, \ldots A_{n-1}\$ I need to ...
7
votes
2answers
162 views

LeetCode: Burst Balloons C#

https://leetcode.com/problems/burst-balloons/ Given n balloons, indexed from 0 to n-1, ...
2
votes
0answers
96 views

Split a string into valid words

I am trying to solve this LeetCode question: Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word ...
2
votes
1answer
38 views

Median-of-medians/quickselect filter in C

I wrote a quick-select filter in C on Wednesday. (The code is below.) It is a filter in the UNIX tradition: It reads from standard input k, the rank of the ...
1
vote
0answers
155 views

LeetCode: critical connections in a network C# (Tarjan's algorithm)

https://leetcode.com/problems/critical-connections-in-a-network/ Please review for memory and runtime performance. There are n servers numbered from 0 to n-1 connected by undirected server-to-...
1
vote
0answers
39 views

Codility's GenomicRangeQuery solution in C#

I've been learning C# for a few months now, and I've done some basic things in java last year. I made a solution for the problem the title states, this is the task description. Task description ...
3
votes
2answers
97 views

Q: Project Euler #1 - C#

Good day, it's my first time doing something like this so I wanted to solve some of the challenges on project Euler, however I reached a block on my code, even before I submitted I was aware that I ...
2
votes
1answer
105 views

LeetCode: Rotting Oranges in C#

https://leetcode.com/problems/rotting-oranges/ Please review for coding style in 40 minutes job interview. In a given grid, each cell can have one of three values: the value 0 representing an ...
1
vote
2answers
73 views

LeetCode: Spiral Matrix II C#

https://leetcode.com/problems/spiral-matrix-ii/ Please review for performance, how can this code run faster Given a positive integer n, generate a square matrix filled with elements from 1 to n^2 ...
7
votes
2answers
113 views

Letter Combinations of a phone number using a Dictionary

Problem statement (online source) Given a digit string, return all possible letter combinations that the number could represent. A mapping of digit to letters (just like on the telephone ...
-3
votes
0answers
44 views

A problem: HackerEarth says it is TIme limit exceeded

I have written a solution to Memorise me problem on Hacker Earth but it takes a lot of memory space and time limit exceeds in the last test case. The first line of input will contain N, an integer, ...
4
votes
2answers
88 views

Calculating the necessary contribution to attain a savings goal with compound interest

This is a problem set from the MIT online course : Suppose you want to set a particular goal, e.g. to be able to afford the down payment in three years. How much should you save each month to ...
2
votes
1answer
50 views

CCC '19 S5:Triangle: The Data Structure

This problem is from [CCC2019]: https://dmoj.ca/problem/ccc19s5/ (Canadian Computing Contest 2019) and I have implemented it in C++. I used sequence [A054237]: https://oeis.org/A054237/table to ...
1
vote
2answers
75 views

MIT Puzzle: The Best Time to Party

This problem is from MIT Course and I have implemented it in C++. Please review and suggest improvements. There is a party to celebrate celebrities that you get to attend because you won a ticket ...
10
votes
5answers
556 views

Minimum perfect squares needed to sum up to a target

I'm trying to solve this problem Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. I've come up with a solution that ...
2
votes
2answers
99 views

Finding the nth ugly number

I'm trying to optimize my solution to this LeetCode problem: Write a program to find the nth super ugly number. Super ugly numbers are positive numbers whose all prime factors are in the ...
3
votes
2answers
66 views

MIT Puzzle: You Will All Conform

This problem is from MIT Course and I have implemented it in C++. Review this code and how can I improve it complexity-wise and with better features available in C++. Let’s say we have a whole ...
2
votes
1answer
56 views

Codility's count passing cars in opposite directions in C#

I programmed a few things in java and now I'm learning C#. I've been doing exercises from Codility. The first 3 or 4 were very difficult to me but now I guess I've got the hang of it. This site ...
1
vote
1answer
54 views

Finding Minimum and Maximum Value

I'm doing a code-challenge problem: Captain Kaban: National Treasure is a popular football simulation game which can be played on most smartphones. In this game, you put up a team of 11 players and ...
4
votes
2answers
71 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 ...
5
votes
2answers
145 views

MaxCounters solution in C# from Codility

I programmed a little in java a while back, and now I'm learning C#.This is the first exercise of "medium" or "respectable" difficulty according to Codility, so I'm pretty pleased of finding out that ...
4
votes
1answer
78 views

Manually formatting numbers in Python

I was working on a little Python challenge that was a bit more difficult than expected: format any non-negative number so 1000 turns into ...
2
votes
1answer
56 views

LeetCode: Queue Reconstruction by Height C#

https://leetcode.com/problems/queue-reconstruction-by-height/ Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers \$(h, k)\$, where \$h\$ ...
9
votes
1answer
238 views

Earliest time frog can jump to the other side of a river in C#. Codility's task

I'm new to C#, I programmed a little in java in the past.I had the two previous exercises reviewed here (permCheck, cyclicRotation, with a 100% score, just like this one), and I'm applying what the ...
2
votes
1answer
43 views

Maze path finder using Depth-First Search algorithm

I'm trying to resolve this kata from CodeWars. Kata exercise You are at position [0, 0] in maze NxN and you can only move in one of the four cardinal directions (i.e. North, East, South, West). ...
6
votes
2answers
173 views

Codility's Permutation Check in C#

I've made a few things in Java, and now I'm learning C#. The code passes the tests with 100% final score. I want to know what things can be improved in my code. Task description A non-empty ...
1
vote
3answers
113 views

Sum the largest five numbers

I'm doing a code-challenge problem: Input The first line consists of an integer T (T ≤ 100) which represents the number of test cases. Each test case consists of ...
2
votes
0answers
55 views

LeetCode: House Robber II C#

https://leetcode.com/problems/house-robber-ii/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place ...
4
votes
1answer
83 views

Hacker Rank Climbing The Leaderboard

This has been asked a couple of times but here is my implementation in C++. I have 11/12 solutions completed. The 6th test case which has 200000 intial scores and Alice has even more scores causes my ...
1
vote
1answer
46 views

LeetCode: House Robber I C#

https://leetcode.com/problems/house-robber/ You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping ...
3
votes
1answer
88 views

LeetCode: House Robber III C#

https://leetcode.com/problems/house-robber-iii/ Please review for performance The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "...
4
votes
1answer
58 views

LeetCode: Symmetric Tree C#

https://leetcode.com/explore/interview/card/top-interview-questions-easy/94/trees/627 Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For ...
11
votes
6answers
1k views

Pseudo Game of Cups in Python

DESCRIPTION: [Inspired by Chandler's GameOfCups with Joey in "Friends"]. Program gets 5-digit zipcode from user. (Assume user won't make a mistake, and will enter exactly 5 digits). ...
1
vote
1answer
53 views

Recover a secret string from random triplets

Got this problem from Codewars. There is a secret string which is unknown to you. Given a collection of random triplets from the string, recover the original string. A triplet here is defined ...
11
votes
3answers
2k views

Algorithm for competing cells of 0s and 1s

I'm working on a practice algorithm problem, stated as follows: There are eight houses represented as cells. Each day, the houses compete with adjacent ones. 1 represents an "active" house and 0 ...
3
votes
1answer
63 views

Java solution to CodeChef “Surgical Strikes” challenge

I've just recently completed this programming "challenge" called surgical strikes: \$N\$ Indian Air Force fighter planes are located in different bases across the country. Each airbase is described ...
3
votes
1answer
60 views

LeetCode: Time Based Key-Value Store C#

https://leetcode.com/problems/time-based-key-value-store/ Create a timebased key-value store class TimeMap, that supports two operations. ...
6
votes
3answers
1k views

LeetCode: Top K Frequent Elements C#

https://leetcode.com/explore/interview/card/top-interview-questions-medium/110/sorting-and-searching/799 Given a non-empty array of integers, return the k most frequent elements. Example 1: ...
1
vote
0answers
62 views

Recursion to dynamic programming [closed]

I was trying to solve a problem on de-arrangements (Number of partial derangement such that exactly prime number discs are found away from their natural positions? (Any number of non-prime K disks ...
1
vote
1answer
93 views

Check if is it possible to get to a point that is presented by a number [closed]

Problem description from an Iranian online course, translated with the help of Google Translate: Tired of coding, Mehdi has gone on to his childhood games. But because he doesn't know who to play ...