# Questions tagged [programming-challenge]

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

2,574 questions
Filter by
Sorted by
Tagged with
66 views

### Project Euler #14: Longest Collatz Sequence starting point

Problem statement: The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule above and starting with 13, we ...
3k views

62 views

### Project Euler problem # 3 is this the most efficient approach in Python or can I do better?

The problem statement: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? This code takes 9 seconds!, is there a better way? ...
28 views

### Project Euler Problem # 8 maximum product of sequences

Is there any room for improvement? Your feedback would be helpful. Problem Statement: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. Find ...
23 views

### Counting co-occurence of a file encoded in UTF-8 [on hold]

I need to write a script that can count co-occurences in a UTF-8 encoded file. The length of the co-ocurence is between 2 to ...
489 views

### Find smallest index that is identical to the value in an array

The task is taken from LeetCode Given an array A of distinct integers sorted in ascending order, return the smallest index i that satisfies A[i] == i. Return -1 if no such i exists. ...
285 views

### Bishop game - python

A bishop can capture any other bishop if it lies along the same diagonal line, so long as no other bishop is in its path. Given a list of coordinates of the bishops locations, and a board size, ...
34 views

### Counting Valleys - HackerRank Challenge

For this challenge on HackerRank: A valley is a sequence of consecutive steps below sea level, starting with a step down from sea level and ending with a step up to sea level. Given Gary's ...
18 views

### Google Foobar challenge “queue-to-do” Python partial test case errors [closed]

I started foobar challenge a few days ago, and I'm now in the 3rd stage first question, and I've got the "Queue-to-do" challenge. The problem is that I get some partial errors in the verifying process....
520 views

### Cracking the Coding Interview — 1.5 One Away

I would like to know any suggestions about to improve my code solution and your rating of my approach to the problem, I based my code on the fact that if the strings have different length removing one ...
456 views

### Join 2 arrays together

There are 2 arrays. One that consists of Categories and one of Products. Each product pertains to its specific category. I want ...
44 views

### A solution to the Journey Planner programming challenge

Here is my Javascript solution to the following problem: Given an un-ordered list of flights taken by someone compute the person's itinerary, given a starting airport. If none valid ...
50 views

### “When to take medicine” CodeChef Challenge MEDIC

I just submitted this code to solve the "When to take medicine" challenge on CodeChef: ...
2k views

### Find The One Element In An Array That is Different From The Others

https://www.codewars.com/kata/find-the-stray-number/train/javascript I solved this challenge by sorting from least to greatest, and checking if the first element in the array matched the second ...
141 views

### Solution to Kickstart's Wiggle Walk

I'm trying to optimize my solution to Wiggle Walk for Kickstart's round 1C. Problem Banny has just bought a new programmable robot. Eager to test his coding skills, he has placed the robot ...
105 views

For the given strings (not containing numbers), print their shortened versions, where each adjacent sequence of the same characters longer than 2, change to an expression consisting of a sign and ...
91 views

### Jump Game - Leetcode

Below is my solution for the LeetCode Jump Game Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents ...
24 views

### Find a Sum of Particles in A Set of Boxes Given a Number of Rows and Columns

This is a code challenge, from Codewars, the details of the specific challenge in depth can be found here: https://www.codewars.com/kata/magnet-particules-in-boxes/javascript. The summary of it ...
76 views

### Geektrust: Solve War problem in a OO way in Python

I solved this programming challenge whose objective is to come up with an OO solution to the problem. The problem statement is quite verbose and the tl;dr version would be: Given an enemy army(...
46 views

### Maximum Width binary tree

Here is my code for the LeetCode problem For a given binary tree, find the maximum width of the binary tree. The width of one level is defined as the length between the end-nodes even if there are <...
59 views

### Find A Series of Numbers Who when Squared and Summed are equal to a given Square

I am working on a CodeWars titled 'Square into Squares. Protect trees!' it can be found here: https://www.codewars.com/kata/54eb33e5bc1a25440d000891/train/javascript I have a working solution, the ...
35 views

### Find the sum of Fibonacci sequence

I have already done many of the Project Euler questions in other languages before, but whenever learning a new language, I like to do the problems again in that language. Here is my elixir version ...
88 views

### Compute Manhattan distance from origin given a set of left-right-step directions

I am solving the problems for Advent of Code 2016 to learn Rust programming. The prompt for the first problem can be summarized: I start at position 0,0 on a regular grid. I am given a set of ...
220 views

### Calculate the largest palindromic number from the product of two 6-digit numbers (100000 to 999999)

Are there any efficient ways to solve this problem, for example using bitwise operator? ...
58 views

### Jumping on the clouds

I have started the Hackerrank interview preparation kit. The first problem I have solved with Swift is as follows: Emma is playing a new mobile game that starts with consecutively numbered clouds. ...
43 views

### Graph-coloring solution using depth-first search

I'm trying to solve this question: Andryusha goes through a park each day. The squares and paths between them look boring to Andryusha, so he decided to decorate them. The park consists of n ...
84 views

### Union, Intersection and Diff of two sorted arrays in C#

This is the original question https://www.geeksforgeeks.org/union-and-intersection-of-two-sorted-arrays-2/ Given two sorted arrays, find their union and intersection. ...
78 views

### My Sal's Shipping challenge on Codecademy

This is my attempt on the Python 3 Sal's Shipping challenge on Codecademy (Challenge Link (instructions in the link)). I'd really appreciate anyone to take the time to review my code. I'm a very new ...
70 views

### Project Euler #3 with Python

I tried to solve some Euler's problems, this is the solution I found for problem #3 with Python. The problem asks: The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor ...
117 views

### Run length encoding in C#

This is the original question: https://www.geeksforgeeks.org/run-length-encoding/ Given an input string, write a function that returns the Run Length Encoded string for the input string. For ...
2k views

### Tiny URL creator

Coding challenge: Convert a given long URL into a Tiny URL. The length of this Tiny URL should be fixed and the same for all URLs. You should return the full URL if given a shortened URL. I am ...
1k views

### Repeated Strings Hacker Rank challenge

I'm doing a hacker rank challenge with this one called "Repeated String". I attempted this challenge in my weaker language java. The goal is to print out the occurrences of the letter a. First you're ...
40 views

### Choose numbers from a grid, minimising the sum

Given a 2-D input matrix, I need to pick elements from it. constraint: you can pick one number at each row, each column given: number boards are given expected output: print least sum of ...
176 views

### Bit-based universe simulation

I am working with this problem (https://open.kattis.com/problems/whowantstoliveforever). As the problem states, my program has to determine if the universe lives or dies based on the input 0s and 1s. ...
59 views

### Finding a vertex of a tree such that every subtree rooted at that vertex is of a uniform color

I'm trying to optimally solve codeforces problem 763A: Each New Year Timofey and his friends cut down a tree of n vertices and bring it home. After that they paint all the n its vertices, so ...
51 views

### String Rotation

I have solved a previous year question of 2018 codevita (link) in Python. Problem Description: Rotate a given String in the specified direction by specified magnitude. After each rotation make a ...
63 views

### Finding sum of divisors of numbers between the range (1 to 1e16)

The exact link to the question : https://www.spoj.com/problems/DIVSUM2/ Input: An integer stating the number of test cases (equal to 500), and that many lines follow, each containing one integer ...
74 views

### Find the largest product of an array

This task is taken from www.interviewbit.com Given an array of integers, return the highest product possible by multiplying 3 numbers from the array Input: ...
107 views

### Find all possible words in a board of characters

This question has 2 possible solutions and I am trying to implement the DFS solution. Here is the Trie and DFS solution: Boggle using Trie and DFS Please review for performance. Given a ...
76 views

### Boggle using Trie and DFS

I already mentioned in my previous code review, there are two solutions for this problem https://www.geeksforgeeks.org/boggle-find-possible-words-board-characters/ this is the first: Find all ...
65 views

### LeetCode:implement strstr C#

https://leetcode.com/problems/implement-strstr/ I implemented Rabin-Karp algorithm https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm please review for performance, also if you were in an ...
77 views

### Cracking the code interview: Problem 1 .6 basic string compression

I created a github repository containing my code solutions for some of the exercises proposed in the book, I updated my solution for the problem 1.6 at https://github.com/dariosicily/cracking-the-code-...
83 views

### codekata: Binary search on an int array

I'm following Karate Chop kata for a binary search. I really wanted to avoid built in functionality within the language. I'm pretty new to C# so any recommendations is greatly appreciated. Spec: ...