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
66 views

HackerRank - Climbing the Leaderboard: I don't understand why my code is exceeding the time limit

Climbing the Leaderboard An arcade game player wants to climb to the top of the leaderboard and track their ranking. The game uses Dense Ranking, so its leaderboard works like this: The player with ...
1
vote
2answers
91 views

HackerRank "Array Manipulation" challenge (using Microsoft concurrent extensions)

I've been practising my coding skills because I have an interview coming up. The HackerRank challenge has 16 test cases; the code passes 9 of them and the other 7 time out. If you go to HackerRank ...
1
vote
1answer
59 views

DNA Challenge from CS50

Added the problem link below and my implementation of it. Took me a few hours to program. I have added comments to explain my thought process. Problem Link Goal - To implement a program that ...
1
vote
1answer
69 views

Python IPv6 verifier, parser and converter

This is a simple Python 3 program that verifies whether a string is a valid IPv6 address or not, parses IPv6 address to its hexadecimal and decimal values, and converts an integer to IPv6 format. I am ...
3
votes
1answer
71 views

IOSP Kata: merge two sorted arrays without iterators

I wrote the code below as a Kata to practice the Integration Operation Segregation Principle (IOSP, clean-code-developers.com). I would like to have some feedback ...
2
votes
3answers
59 views

Finds Keywords in Log Files

This is my first project in C and I wanted a more experienced person's insight on how I made the whole program. Just looking for feedback it works how I want it to. The Github is here. Thank you so ...
4
votes
1answer
80 views

Determine whether an array contains duplicate values

My solution for the leet code problem to search an array of ints for duplicate values and return a boolean seems quite efficient (< 90% of submissions runtime). However, I am currently reviewing ...
3
votes
2answers
100 views

pattern matching coding challenge

I have implemented a simple pattern matching for the below algorithm in Java with time complexity of O(n)(n is the size of the input array). Any suggestions for optimization?? one of the most ...
3
votes
3answers
406 views

Find the average score, given data in a table with labeled columns not in a fixed order

I was on Hacker Rank for the first time and there was a question that required to get the inputs from STDIN and use collections.namedtuple(). It was my first time ...
6
votes
2answers
193 views

Container with most water, with pre-computation of possible bounds

Here's my attempt at leetcode's container with most water. Problem: Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn ...
1
vote
2answers
46 views

Evaluate the roots of Bhaskara’s formula

I'm creating a program that finds the roots of Bhaskara’s formula and prints them. I'm looking for advice to improve my logic more and more. ...
3
votes
1answer
114 views

Find potentional sponsor for every animal

This is a programming challenge in Czeck. My translation follows. Does anyone know what the time complexity of my code is? Input: The first line contains 2 integers: the number of animals 1 ≤N ≤100 ...
1
vote
0answers
79 views

Python functions to serialize nested data structures human readably

See Serializing (nested) data structures in a human-readable format for more details. In the last two days I have significantly improved my function, and wrote seven implementations of it. I have ...
5
votes
3answers
264 views

Counting swaps in a sequence sorting algorithm

I have been working on this question, https://open.kattis.com/problems/sequences. You are given a sequence, in the form of a string with characters ‘0’, ‘1’, and ‘?’ only. Suppose there are n ‘?’s. ...
2
votes
3answers
86 views

Leetcode First Unique Character in a String code optimisation

I was working on First Unique Character in a String Question Given a string s, find the first non-repeating character in it and return its index. If it does not exist, return -1. Example 1: ...
-2
votes
1answer
60 views

leetcode 169 optimzations reducing complexity [closed]

This is for leetcode problem: https://leetcode.com/problems/majority-element There is something wrong with the way I create solutions, and not sure how to stop doing it. Basically the problem is I ...
0
votes
1answer
111 views

Codeforces - problem: (A) Mike and palindrome

While on SO someone posted this question and I gave it a quick try. My solution passed all the testcases. Link to the problem: Problem: (A) Mike and palindrome Question: Mike has a string s ...
2
votes
1answer
65 views

CodeChef - Red Alert

I have solved this problem from the CodeChef platform using the Python prorgamming language Here is the code: ...
2
votes
1answer
47 views

Find the closest match to a string [closed]

Input The first line of input contains a string s: the word misspelled by your partner. Assume that your partner did not add or remove any letters; they only replaced letters with incorrect ones. The ...
2
votes
1answer
89 views

Drug Analyzer challenge

What do I need help with? I'm doing the challenge below, in which I need to increase code performance. It's currently at 63% and I need to increase it to at least 71% however I can't optimize more ...
0
votes
0answers
36 views

Iterative solution for Tower of Hanoi challenge

Recently I'm interested in the Tower of Hanoi problem. The simplest solution is probably the recursive one but I'm trying to challenge myself by solving it iteratively. After observing the pattern of ...
2
votes
2answers
52 views

Find the 'n' most frequent words in a text, aka word frequency

I'm doing freeCodeCamp's Coding Interview Prep to improve my JavaScript skills. This challenge is called "Word Frequency", and is based on the Rosetta Code's entry of the same name. The ...
2
votes
3answers
66 views

Phrase to acronym in C from exercism.io

I am learning C and doing challenges like those found on exercism.io and the various data structure & algorithm sites. I have a sense that while this works and it makes sense to me that it can be ...
0
votes
2answers
82 views

Year/month difference calculator

My program calculates the user's age in years and months. It takes the user's birth year and month and then the current year and month as input. ...
3
votes
3answers
748 views

Calculate movie ticket price

My program displays the price of a movie ticket. The price is based on the customer’s age. If the user enters a negative number, the program displays the “Invalid age” message. ...
3
votes
1answer
146 views

Recursive solution of ordered Coin Combinations II (CSES)

Question Link Consider a money system consisting of n coins. Each coin has a positive integer value. Your task is to calculate the number of distinct ordered ways you can produce a money sum x using ...
9
votes
2answers
673 views

Yet another minesweeper field calculator

The task is to read in a data file containing a representation of a rectangular array with '*' signifying a mine and '.' signifying the absence of one. Each such array is preceded by a row and column ...
3
votes
1answer
92 views

ZigZag Conversion Coding Challenge

This is my solution for ZigZag Conversion, a coding challenge from LeetCode. The challenge: Write a program that takes two parameters, a string and a number of rows, that interprets the string as if ...
3
votes
2answers
134 views

Online Judge 10189: Minesweeper (C++)

I'm new to C++ (not to programming in general), which I want to learn to participate in some programming contests. I solved the Online Judge Minesweeper Challange. Since I'm not familiar with C++, any ...
1
vote
2answers
66 views

Improving Project Euler code problem #10

So, I just finished Problem 10 on Project Euler, but it took about 3 to 4 minutes for my output to come out, due to bad coding, I guess, any suggestions on how could I optimize my code? Question The ...
0
votes
0answers
61 views

Better Approach for the House Robbery Problem (LeetCode 198)?

The problem states that you have to rob the maximum money stashed in the houses but you cannot rob two adjacent houses. array[i] denotes the money in the (i)th house. I got the following code ...
-1
votes
2answers
115 views

Serving In Tennis

Alice and Borys are playing tennis and it is unknown who served the first game. After each game, the serve changes to other player. If the server wins the game, then it is said that s/he holds the ...
1
vote
1answer
92 views

Rock paper scissors coding assignment

I had a coding assignment to write a Rock Paper Scissors game. The main task is not to show a solution but rather to test the coding style. The rules are such: Problem: rock is "O", paper is ...
4
votes
3answers
59 views

HackInScience exercise: Sequence Mining

I am working on a practice problem found here: https://www.hackinscience.org/exercises/sequence-mining Overview Sequence mining is useful for analyzing list of events when order matters. It's used ...
1
vote
0answers
38 views

Codewars: Path Finder

Task 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). Return true if you can reach position [N-1, N-1] or false ...
0
votes
1answer
52 views

Climbing the leaderboard (Hacker Rank) via binary search

I am trying to solve the Climbing the leaderboard problem on Hacker Rank. My code passes all the test cases except Test Cases 6 to 9, which I assume are using large data sets. I'm using binary search ...
1
vote
2answers
113 views
1
vote
2answers
98 views

Search for text in a file

I have this implementation of Grep where I use re.search: ...
3
votes
1answer
114 views

Project Euler #43 (C++)

Here's my C++ solution for PE 43: ...
0
votes
0answers
26 views

Refactor Javascript filter that handles click and changing together dropdown filters

I'm looking to rework and make it easier to read this handleFilterChange function This is helper being used in the function ...
2
votes
2answers
90 views

An implementation of Uber's “Fare Estimator”

CodeSignal put out a challenge by Uber that involves writing a "fare estimator" that involves a function dependent on cost per minute, cost per mile, ride time and ride distance. The formula ...
4
votes
2answers
88 views

Bisection, linear recurrences and even Fibonacci numbers

So this code is yet another attempt at solving the second Project Euler problem to improve my handling of Python. The purpose of the code is to solve the problem below Each new term in the Fibonacci ...
2
votes
2answers
1k views

How to do modulo thing fast (less execution time)

I was solving a question on a coding website and this website has a limit for execution time of code. My code takes 1.01 sec but the limit is 1 sec. I am unable to find any changes in my code that ...
2
votes
1answer
56 views

Project Euler 1 using functional programming in JS

So I am once again beating a dead horse, by solving the first Project Euler problem: 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 ...
3
votes
2answers
964 views

Make Array Consecutive

Ratiorg got statues of different sizes as a present from CodeMaster for his birthday, each statue having an non-negative integer size. Since he likes to make things perfect, he wants to arrange them ...
1
vote
2answers
109 views

Leetcode kth largest element without using heaps

I was working on kth largest element problem on leetcode Question Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element in ...
10
votes
4answers
3k views

First non-repeating Character, with a single loop in Python

I recently tried to solve the first non-repeating character problem. Please tell me if my solution is valid. I'm aiming for O(n) with a single loop. My thinking is, it would be easy to tell you what ...
0
votes
1answer
25 views

Cubic Permutations | Project Euler #62

The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits ...
3
votes
1answer
33 views

Attempting to solve minimum window substring problem using Python 3.8

Hello programming gurus/reviewers, I attempted to solve the Minimum Window Substring (Leetcode 76) problem using Python 3. My solution involved using Counters and backtracking. On submission, the ...

1
2 3 4 5
65