A message from our CEO about the future of Stack Overflow and Stack Exchange. Read 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
4
votes
0answers
41 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
80 views

Codewars: Sum Strings

Sum Strings Codewars kata. It's supposed to be able to handle big integers.   Question Given the string representations of two integers, return the string representation of the sum of ...
2
votes
1answer
47 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
235 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\...
-1
votes
2answers
73 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: ...
0
votes
1answer
23 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 ...
2
votes
0answers
16 views

Credit Card Form using RXjs

I am trying to improve my skills and I'd like to work on avoiding bad practices and mistakes. Can anyone skim over my code and point out what should have been implemented more efficiently or in a ...
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 ...
-2
votes
0answers
34 views

Maximise value of goods in a triangular container [closed]

In this task I should find the best solution to the given problem. You are given M - capacity of the ship where you can store elements with heights smaller than i-th height for example on the 1st ...
4
votes
4answers
196 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: ...
4
votes
2answers
174 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. ...
7
votes
2answers
3k views

BinaryGap challenge

A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N. For example, number 9 has binary ...
3
votes
1answer
34 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 ...
13
votes
4answers
2k views

Find the next multiple of N that is a perfect square number

Given a number \$t\$, (\$1 \leq t \leq 1000\$) that represent testcases and \$t\$ numbers \$n\$ (\$1 \leq n \leq 10^9\$). Show the next multiple of \$n\$ that is a perfect square number. ...
4
votes
1answer
68 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
52 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: ...
6
votes
1answer
401 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, ...
5
votes
2answers
1k views

Predict the best day to buy and sell the shares

I was trying out my hand at solving problems and came across this HackerRank problem. I have written a solution which passes for a few test cases but times out for most others (time limit - 3 seconds)....
4
votes
2answers
121 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 ...
2
votes
2answers
80 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, ...
3
votes
2answers
50 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 ...
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 ...
13
votes
2answers
733 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
696 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
2answers
117 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 ...
6
votes
1answer
123 views

City Construction Solution times out for large input

Problem The country of Hackerland has n cities connected by m uni-directional roads. The cities are numbered from ...
-1
votes
0answers
26 views

Sum of lengths of contiguous subarrays of unique integers

hackerearth.com Unique Subarrays: A contiguous subarray is defined as unique if all the integers contained within it occur exactly once. There is a unique weight associated with each of the ...
3
votes
1answer
102 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 ...
6
votes
3answers
87 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
106 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
50 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
249 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 ...
1
vote
0answers
20 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 ...
5
votes
1answer
157 views

Search and Replace (FreeCodeCamp intermediate algorithm scripting)

I completed the challenge and passed the tests: Perform a search and replace on the sentence using the arguments provided and return the new sentence. First argument is the sentence to perform ...
6
votes
1answer
1k views

Project Euler Problem #6 - sum square difference

The sum of the squares of the first ten natural numbers is: \$1^2 + 2^2 + ... + 10^2 = 385\$ The square of the sum of the first ten natural numbers is: \$(1 + 2 + ... + 10)^2 = 55^2 = ...
4
votes
2answers
262 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 ...
7
votes
2answers
4k views

Project Euler 11: Largest product in a grid

Problem 11 Largest product in a grid What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the 20×20 grid? ...
2
votes
0answers
15 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 ...
3
votes
1answer
79 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)!, ...
2
votes
1answer
40 views

Codewars: Pick peaks

Pick peaks Wrote my "hello world" on Thursday, so definitely a beginner. I know some Python, so not a novice to programming in general. Question For example, the array ...
5
votes
1answer
78 views

Sorting software version list using Python 2.7 (no modules)

I am participating in a challenge and one of the challenges was to write a script to sort a list of software versions (ex: 1.0, 1.3.2, 12, 1.3.0). Here is the my solution: ...
1
vote
1answer
47 views

Codewars: Reverse or Rotate

CodeWars 6 Kyu: Reverse or rotate? I wrote my Javascript "hello world" on Thursday, so I'm definitely a JS beginner. I do have some experience in Python though, so I'm not a complete novice to ...
6
votes
3answers
313 views

Complete Intcode Computer (Advent of Code 2019: Day 9)

My best languages are Python and Rust, but I want to improve my C++ skills, so I decided to try my hand at Advent of Code 2019 in C++. So far I have not encountered any major issues, but I want to ...
2
votes
1answer
63 views

Subset Component Task

I've solved a problem Subset Component Problem You are given an array with n 64-bit integers: d[0],d[1],….,d[n-1]. ...
8
votes
3answers
718 views

Balanced centrifuge configurations

Given an input N as the size of a centrifuge, I need to find out the number of balanced configurations. The full description is here. Centrifuge is a piece of ...
1
vote
1answer
96 views

Project Euler # 37 Truncatable primes in Python

The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can ...
8
votes
3answers
13k views

Count consecutive ones in a binary list

There is a list consisting of zeroes and ones. I want to find out the length of the longest streak of ones. Is there a better solution? ...
4
votes
1answer
55 views

Golang checks for equilateral, isosceles, or scalene triangle

For me, learning the basics of a new programming language is best done through some easy to intermediate challenges. Here's one that's rather well known and relatively simple - determine if a triangle ...
6
votes
1answer
577 views

HackerRank ACM ICPC Team

You are given a list of \$N\$ people who are attending ACM-ICPC World Finals. Each of them are either well versed in a topic or they are not. Find out the maximum number of topics a 2-person team can ...