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
0
votes
0answers
13 views

Rosetta Stone translation challenge

I recently came across this programming challenge and managed to find a workable solution. The challenge contains various type of data input and my code seems to have workable solution that fulfills ...
4
votes
2answers
355 views

CodeAbbey - Blackjack Counting

Here is my solution for CodeAbbey - Blackjack Counting My code passes all tests on Code Abbey but I think I have some poor implementation specifically with my handling of the Aces in the score but ...
4
votes
1answer
67 views

Codility Fish (queue) programming challenge

Today I have attempted a Codility exercise "Fish" (https://app.codility.com/programmers/lessons/7-stacks_and_queues/fish/), and I have to say I found it to be: 1) Not necessarily "easy" as implied by ...
0
votes
1answer
33 views

Pyramid Slide Down solution with Dynamic Programming [closed]

A function that solves the slide down problem. In summary, the task is to find the path from top to bottom of a triangular grid of numbers that has the largest sum. ...
2
votes
2answers
98 views

Console application for bank management

I am new to C. I tried to make a bank management console application. I want some one to review it for advice to enhance and develop my coding skills. This is what the program does with the inputs: <...
3
votes
1answer
40 views

Determining whether a string is transformable into another by repetitively increasing its prefixes alphabetically

Here's Alice and Strings, a programming challenge on hackerearth: Two strings \$A\$ and \$B\$ comprising of lower case English letters are compatible if they are equal or can be made equal by ...
3
votes
2answers
103 views

LeetCode: Longest String Chain (Java)

For the question, I had a pretty messy solution so I would like some advice on how to better use Java to make the code a bit cleaner. Also, a semi-hack that I did that I'm not proud of is checking if <...
3
votes
1answer
56 views

LeetCode: Most Frequent Subtree Sum

My solution to LeetCode problem Most Frequent Subtree Sum works, but I have several questions regarding the code. I am also looking for an advice on how to improve the code. Problem: Given the ...
5
votes
2answers
176 views

Creating a list from combinations of the original data

I am trying to create a list based on some data, but the code I am using is very slow when I run it on large data. So I suspect I am not using all of the Python power for this task. Is there a more ...
3
votes
2answers
283 views

WebService to calculate transaction statistics

Recently got rejected in a code challenge that was a very simple WebService with 3 endpoins: POST /transactions to add transactions with an ammount and timestamp....
3
votes
2answers
158 views

Finding median of sub arrays taking too much time

I'm trying to solve a programming challenge where I have to find the median of given subarrays of an array. I have used std::vector's ...
3
votes
1answer
46 views

Grading Students - Hackerrank

Here is my solution to Grading Students courtesy of HackerRank. My code passes all tests in the testing suite but I feel like there could be a better implementation of it. But nonetheless, what are ...
3
votes
1answer
32 views

LeetCode: Binary Tree Level Order Traversal C#

Please review for performance. and also naming convention https://leetcode.com/problems/binary-tree-level-order-traversal/ Given a binary tree, return the level order traversal of its nodes' ...
5
votes
2answers
95 views

HackerRank: Friend Circles (DFS in Java)

I got this problem on a HackerRank challenge and this was the best I could come up with. It's basically just using DFS to find connected components (in this case, friend circles). I was having a tough ...
4
votes
3answers
73 views

LeetCode: Validate Binary Search Tree C#

I was struggling with this question for many times, and I have solved it every time, because I understand the concept. but I can never get to a good concise solution which is easy to follow. In a ...
0
votes
1answer
91 views

The Great Julya Calendar

Challenge An integer is provided as an input. In each step, we have to subtract a number from the input which already exists as a digit of the input. In this way, we have to make the input ...
2
votes
1answer
63 views

Project Euler #47: find four consecutive integers, each with four distinct prime factors

Project Euler Problem 47 Find the first four consecutive integers to have four distinct prime factors each. What is the first of these numbers? This is my solution for problem 47 on Project Euler. ...
-1
votes
3answers
94 views

Find the maximum number of 4-passengers contiguous clusters

Problem Statement An airline wants to allocate seats in their aircrafts such that each group of four passengers travelling together are to be seated next to each other in clusters of 4. A contiguous ...
10
votes
2answers
911 views

Perform a Caesar Cipher Shift on a given string

I'd like feedback on my solution to the outlined programming challenge (medium level). I've tried it fast in any way I know how to, but, what might be a more efficient and/or pythonic solution? [...
2
votes
1answer
71 views

Comparing version numbers with JavaScript

I have written a function that compares two version number strings (e.g. 1.2.0 and 1.2.2) and return 1 if the first string is greater, ...
1
vote
1answer
63 views

Count minimum adjacent swaps - HackerRank New Year Chaos

We need to find the minimum number of adjacent swaps required to order a given vector. The maximum number of swaps that an element can carry out is 2. If the vector can not be ordered under this ...
3
votes
1answer
83 views

Find and return the earliest occurring word from a string which contains the most repeating letters

I'd like feedback on my solution to the outlined programming challenge (medium level). I've tried it fast in any way I know how to, but, what might be a more efficient and/or pythonic solution? [...
0
votes
1answer
61 views

Codewars: Prime Streaming (PG-13)

I'm timing out on Codewars' Prime Streaming kata. Below is my code: ...
3
votes
1answer
63 views

Run length encoding of an input string (Coderbyte 'Run Length' challenge)

I'd like feedback on my solution to the outlined (medium level) programming challenge. What might be a more efficient or Pythonic solution? The challenge as outlined by Coderbyte: [Run Length] (...
2
votes
0answers
72 views

Given an integer array A and a range, find a subarray within the range with a minimum sum

Problem HackerRank Range query: You are given an array A of n integers. You have to perform ...
7
votes
2answers
159 views

Find the closest enemy in a 2D grid with wrapping allowed

I'd like feedback on my solution to the outlined programming challenge. Is numpy a good candidate module for this? What might be a more efficient or Pythonic solution? Closest Enemy II Have ...
2
votes
1answer
87 views

Dynamic Array Problem (Hacker rank)

I am trying to solve the Dynamic Array problem on HackerRank: Create a list, seqList, of N empty sequences, where each sequence is indexed from 0 to N-1. The elements within each of the N ...
0
votes
2answers
245 views

Find the maximum value of | Ai - Aj | + | i - j |: [closed]

hackerearth.com practice problem Can you solve it?: Given an array 'A' consisting of 'n' integers, find the maximum value of the following expression: \$\lvert A_i - A_j\rvert + \lvert i - j\...
0
votes
1answer
37 views

Sock merchant from hackerrank - idiomatic typescript?

Sock Merchant John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many ...
-1
votes
2answers
81 views

Moving Average from data stream [closed]

I wrote a code for one of the leetcode problems but I am not satisfied. I believe I could improve it. Here is my code: ...
5
votes
4answers
1k views

Find a 2x2 vowel square in a grid (Coderbyte 'Vowel Square' problem)

My solution to the Coderbyte task 'Vowel Square'. It's a simple task, but I'm sure there's a more Pythonic solution than mine. The problem: Vowel Square Have the function ...
4
votes
4answers
207 views

Finding the number of longest contiguous increasing subsequences in a given array

This is different from classic LIS problem. Here I want number of contiguous longest increasing subsequences! For example: ...
3
votes
1answer
38 views

Flash Memory block write counting & thresholding

I am trying to solve this question: In a block storage system, new data is written in blocks. We are going to represent the flash memory as one sequential array. We have a list of block writes ...
4
votes
2answers
231 views

Counting Duplicates - Code War

This is a problem from CodeWar. Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. ...
4
votes
1answer
74 views

C functions for fast IO for competitive programming

In some (perhaps not well-designed) competitive programming problems, the runtime and score is dependent on how fast your program can process input. Therefore I've written a small C99 library with ...
-4
votes
1answer
55 views

Geting maximum prime factor for a given number [closed]

I'm trying to solve a problem from Project Euler: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? and here is my attempt: ...
4
votes
2answers
139 views

Given n input strings and m query strings, find each query frequency in the list of input strings

I'm doing questions on HackerRank to brush up on Java & CS. Problem This problem is called Sparse Arrays in HackerRank. There is a collection of input strings and a collection of query ...
3
votes
2answers
62 views

Sorted insert on a doubly linked list (HackerRank)

I've decided to do a simple linked list question to brush up my Java & CS. This is the solution for Given a reference to the head of a doubly-linked list and an integer, \$data\$ , create a ...
2
votes
2answers
81 views

Find all pairs of numbers such that the number of binary 1's in their OR is maximum

So, I tried to solve this question and my code did not execute within time-limits. https://www.hackerrank.com/challenges/acm-icpc-team Here's my code, ...
7
votes
2answers
1k views

Find the correct path through a 5 x 5 grid (coderbyte 'Correct path')

I've completed the following coderbyte question and would like feedback as to whether it follows Python best practices, is efficient and so forth. The coderbyte problem: Have the function ...
6
votes
3answers
750 views

Construct the Array from HackerRank

This is my answer for https://www.hackerrank.com/challenges/construct-the-array/problem (Passes all the test cases) Problem Your goal is to find the number of ways to construct an array such ...
3
votes
1answer
111 views

Find positive integer with a minimum number of binary 1's such that its bitwise AND with all array elements is not 0

Task You have an array of positive integers. Your task is to find an integer x such that the following are true: Bitwise AND between ...
13
votes
2answers
746 views

Beginner Coin Flip project

I think I finally finished a small coin flip project I found online. However, I'm pretty confident this is far from the optimal solution and would really appreciate any feedback on how this could be ...
6
votes
3answers
99 views

Leetcode Three Sum

From here: 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. Note: The ...
5
votes
2answers
116 views

Frequency Queries (Hackerrank)

This is the problem: You are given queries. Each query is of the form two integers described below: 1 x: Insert x in your data structure. 2 y: Delete one occurrence of y from your data ...
1
vote
1answer
56 views

Hangman game in beginning Java

Hangman game coded in Java (at a beginner's level) where Hangman.java can be run with one or more arguments. Hangman.java: ...
9
votes
1answer
262 views

Number in words: recursive function

I would appreciate some feedback on the below code I wrote for a Project Euler problem. The answer comes out correct but I'd like feedback on the design of the function and implementation of ...
2
votes
1answer
41 views

R solution to max product in matrix for four adjacent numbers (Euler 11)

Background This is solution to Problem 11 on Project Euler that is concerned with finding largest product of four adjacent numbers in the provided grid. Other than solving the problem I was also ...
2
votes
0answers
18 views

Codewars: Remote Control Virtual Keyboard

This is my solution to the Codewars problem TV Remote (symbols). Description In short, you are given a virtual keyboard with 3 modes between which can be switched by pressing the ...
4
votes
2answers
271 views

Computing Scrabble score in Golang

I think we all know the game of Scrabble and how popular it is as a simple programming challenge. Here's my attempt at computing a Scrabble score for a given word done in Go. I must admit, I'm fairly ...

1 2 3 4 5 57