Skip to main content

Questions tagged [programming-challenge]

Use this tag when the code is a solution to a programming challenge. Always include a sufficient description of the problem to be solved - while a link to the challenge is welcome, the review request needs to be complete when the challenge site is unavailable.

Filter by
Sorted by
Tagged with
2 votes
3 answers
1k views

I am working on this LeetCode problem where I have to count the minimum number of operations to make all elements in an array equal to zero 3542. Minimum Operations to Convert All Elements to Zero ...
Jared McCarthy's user avatar
4 votes
2 answers
509 views

I'm resolving a problem from CodeForces: C. Beautiful XOR. This is what the code is supposed to do: You have two numbers a and b. You must transform a into b using XOR operations (...
Jared McCarthy's user avatar
5 votes
5 answers
1k views

I implemented a recursive solution that compares the left and right subtree in mirrored fashion. It works for my test cases, but I would like to know if there are any best practices that would make ...
Jared McCarthy's user avatar
0 votes
3 answers
222 views

I implemented quick sort after merge sort as part of LeetCode question for sorting an array. The solution code can be found at https://leetcode.com/problems/sort-an-array/solutions/7180269/i-...
Dovud Jo'rayev's user avatar
4 votes
3 answers
452 views

As a follow-up to my previous question, I've decided to post a follow-up question with a revised code that accommodates most of the inputs from the previous question's comments, namely: Used ...
Stony's user avatar
  • 107
5 votes
3 answers
570 views

I need to solve the following competitive programming problem from coderun.ru: Strength of a Pyramid Top The pyramid consists of n horizontal layers of blocks: the first layer contains n blocks, the ...
Stony's user avatar
  • 107
7 votes
4 answers
1k views

I am trying to solve the 909th challenge of Project Euler. It is basically about replacing specific patterns in a string until no pattern is found. A given string like ...
polfosol's user avatar
  • 319
5 votes
2 answers
409 views

I'm creating a wordsearch generator that takes a list of words and outputs a 10x10 grid (2D array) of letters. This is roughly how it works: loop over words use boolean ...
Aya Noaman's user avatar
3 votes
2 answers
252 views

Here is a third implementation, the second is in my question Place queens and rooks with the higher score (extension of the queen problem) and an initial one is in my answer for the question N queen ...
bruno's user avatar
  • 212
4 votes
1 answer
196 views

This is a continuation of the question N queen problem-like (+rooks and a different goal) written by someone else, where I answered. EDIT I continued to work on the subject and a third implementation ...
bruno's user avatar
  • 212
5 votes
3 answers
1k views

Project Euler Problem #1 Multiples of 3 or 5 states: If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of ...
toolic's user avatar
  • 16.4k
6 votes
2 answers
459 views

Link to kata: linkRank: 6 kyuKata author: @rsalgado I have been recently learning Ruby-lang and have been attempting to solve the following kata from Codewars involving Goldbach's Conjecture: ...
CrSb0001's user avatar
  • 619
6 votes
2 answers
732 views

Here's my (correct) solution to a HackerRank question: Weather Observation Station 8 Query the list of CITY names from STATION which have vowels (i.e., a, e, i, o, and u) as both their first and last ...
JTB's user avatar
  • 277
6 votes
1 answer
593 views

I am working on a problem on LeetCode. Considering only lowercase characters from 'a' to 'z', I have written some Java code to check if a permutation of a given pattern is a substring of a given ...
EngineerP's user avatar
1 vote
1 answer
178 views

I'm writing JS for the FreeCodeCamp todo list; the corresponding HTML and CSS for this can be found on their page. I have made one edit to the HTML - the button with type "submit" has been ...
ApexPolenta's user avatar
4 votes
1 answer
119 views

I'm working on an optimization problem involving a turn-based chocolate-sharing game, and I need help optimizing my current brute-force solution. Problem Description: You and your friend take turns ...
CodeCrusader's user avatar
7 votes
1 answer
117 views

I am trying to complete a challenge - a simple .net core API with one simple endpoint. This endpoint should validate the user's information and return a unique ID. He should provide: 1) Name, 2) ...
Tania Marinova's user avatar
5 votes
2 answers
229 views

Problem: MLE I am confused as to why the LeetCode judge reports Memory Limit Exceeded when my solution looks close to the editorial solution. I not too familiar with ...
user430243's user avatar
7 votes
4 answers
996 views

I'm working right now on Project Euler problem 54, and I figured that this was the perfect opportunity to try to work with classes. This is my first time, so I'm sure that there are a lot of style, ...
Brais Romero's user avatar
7 votes
5 answers
2k views

I am a C++ dev trying to solve problems in C to practice it, specifically the LeetCode Merge Strings Alternately problem: You are given two strings word1 and word2. Merge the strings by adding ...
ijklr's user avatar
  • 397
6 votes
2 answers
326 views

Link to problem: linkNumber of solvers: 27 out of 844Solve rate (per person): 3.199%Success rate (over all submissions): 1.78% Project Euler+ on HackerRank is basically supposed to be a generalization ...
CrSb0001's user avatar
  • 619
5 votes
3 answers
1k views

How can the following recursion + memoization code be converted into a tabulation format dynamic programming solution? The code is working, but I want to improve it. The challenge I am facing is ...
Elias El hachem's user avatar
8 votes
5 answers
1k views

I tried solving the LeetCode question like many others, trying to incorporate the O(n) time complexity requirement. Squares of a Sorted Array Given an integer array ...
Littlejacob2603's user avatar
8 votes
2 answers
282 views

This is posted in response to this request made in a discussion of my "C-ish" answer to a recent Code Review question regarding a Python solution to a Leetcode challenge. It was reported ...
user avatar
11 votes
4 answers
2k views

(Source: Leetcode 93: Restore IP Addresses [Medium])(Topics: [String] [Backtracking]) The problem is as follows: Definition: A valid IP address is defined to consist of exactly four integers ...
CrSb0001's user avatar
  • 619
5 votes
2 answers
427 views

I'm starting to learn rust and figured my first simple project would be to solve some of the Euler problems. I'd appreciate if anyone could tell me where I might be ...
zephyr's user avatar
  • 223
3 votes
2 answers
196 views

This is part 2 of Day 4 of 2024's AoC: The problem is as follows: It's an X-MAS puzzle in which you're supposed to find two MAS in the shape of an X. One way to achieve that is like this: ...
Lozminda's user avatar
  • 153
6 votes
5 answers
896 views

The following code solves Advent Of Code 2021 Day 10. The goal for this time around is evaluating whether a line of brackets is complete, has a syntax error or is missing some closing brackets. ...
138 Aspen's user avatar
  • 469
5 votes
2 answers
987 views

This program tried to solve LeetCode problem 3366: Minimum Array Sum. It fails for k odd, op1+op2 high enough such there are more odd value to optionally subtract k from than subtractions to allot. A ...
greybeard's user avatar
  • 7,819
3 votes
1 answer
108 views

I have recently started learning lisp by reading ANSI Common Lisp, and I thought advent of code would be good for practice. Any feedback on my code for Day 1 would be appreciated. ...
advent-of-code-asker's user avatar
4 votes
1 answer
120 views

Here is the solution to the LeetCode Sliding Puzzle Problem #773. The problem is to find the shortest solution for a 3 x 2 sliding puzzle. I would appreciate any ideas to improve this code. But it's ...
Eugene Krokhalev's user avatar
6 votes
1 answer
112 views

Here is the solution to LeetCode Problem #1072. The problem is to find the maximum number of rows in a matrix where all the values can be made equal after some columns are flipped. It's assumed that ...
Eugene Krokhalev's user avatar
8 votes
2 answers
892 views

I am working on the Build Your Own wc Tool coding challenge in C++. I have a working implementation that seems to match the output of the wc command for different ...
Ganesh Tata's user avatar
4 votes
1 answer
183 views

I've been trying to learn Rust by working through Advent of Code 2023, specifically for day 7, part 1, here. It's Poker Lite: You're given a list of hands. The input is formatted as ...
roganjosh's user avatar
  • 143
4 votes
4 answers
479 views

Problem statement: Write a program called multi_input.cpp that prompts the user to enter several integers in any combination of octal, decimal, or hexadecimal, ...
Tuhami's user avatar
  • 41
3 votes
1 answer
271 views

I was practicing question 1a of the British Informatics Olympiad 2020 past paper. The Roman look-and-say description of a string (of Is, Vs, Xs, Ls, Cs, Ds and Ms) is made by taking each block of ...
sbottingota's user avatar
  • 1,143
1 vote
1 answer
297 views

I am trying to solve the following problem in leetcode. https://leetcode.com/problems/kth-largest-element-in-an-array/description Given an integer array \$nums\$ and an integer \$k\$, return the \$k^\...
Debanjan's user avatar
6 votes
1 answer
459 views

The intent of this test file is to go through each of my Project Euler solutions and see if they: return the correct answer, and do so in under 60 seconds (unless expected otherwise). I am using ...
Olivia A's user avatar
5 votes
1 answer
96 views

I was practising question 2a of the British Informatics Olympiad 2024 past paper. In this task you will manipulate lists of integers to create new lists. There are three fundamental lists that you ...
sbottingota's user avatar
  • 1,143
4 votes
1 answer
158 views

I'm practicing problems for the ICPC competition, and one of the problems requires solving it by using an FFT to compute the product of two polynomials efficiently. Since this is for the ICPC ...
João Areias's user avatar
4 votes
2 answers
409 views

I was practicing question 3a of the British Informatics Olympiad 2021 past paper. A shop is looking to display some boxes (conveniently labelled A, B, …) in their window. There is a desired order for ...
sbottingota's user avatar
  • 1,143
4 votes
1 answer
149 views

I was practicing question 1a of the British Informatics Olympiad 2021 past paper. A pat is a single letter or a string of letters which can be split into a left and right string (of at least 1 letter)...
sbottingota's user avatar
  • 1,143
1 vote
1 answer
137 views

This is a problem from a previous semester that I am trying to upsolve. I am trying to solve a problem involving the total number of ways of decomposing a number using only repdigits. A repdigit is a ...
Lesserrafim's user avatar
6 votes
3 answers
857 views

I was practicing question 1a of the British Informatics Olympiad 2023 past paper. In the Fibonacci sequence each number is generated by adding the previous two numbers in the sequence. We will start ...
sbottingota's user avatar
  • 1,143
6 votes
1 answer
407 views

I was practicing question 1a of the 2022 British Informatics Olympiad past paper. Each letter in the alphabet can be given a value based on its position in the alphabet, A being 1 through to Z being ...
sbottingota's user avatar
  • 1,143
6 votes
3 answers
926 views

Problem (Rephrased from here): The radical of \$n\$, \$rad(n)\$, is the product of distinct prime factors of \$n\$. For example, \$504 = 2^3 × 3^2 × 7\$, so \$rad(504) = 2 × 3 × 7 = 42\$. We shall ...
Nadav Nevo's user avatar
6 votes
2 answers
522 views

I first saw this challenge when a user posted it to SO about two years ago without a shred of code. The post's plea, "How do I get started?" meant the user's post didn't survive long on that ...
user avatar
2 votes
1 answer
71 views

Consider a bucket array containing sorted and/or empty buckets, and the goal is to extract the longest possible sequence in sorted order, under the following conditions: Only one element in each ...
M.A.'s user avatar
  • 121
3 votes
1 answer
256 views

I was playing around with leetcode's Number of Islands. As per the challenge's description: Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the ...
ccot's user avatar
  • 351
3 votes
2 answers
117 views

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 ...
TAHER El Mehdi's user avatar

1
2 3 4 5
68