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
-2
votes
1answer
65 views

How to work in linear time with DFS

I tried a Hackerrank problem and it gives me a successful message, it works fine for Hackerrank criteria. The member states of the UN are planning to send 2 people to the moon. They want them to be ...
4
votes
1answer
118 views

Leetcode three sum in Javascript

I was doing 3sum question on leetcode Question 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 ...
2
votes
0answers
36 views

Project Euler #14: Longest Collatz sequence on HackerRank

The following is the conclusion in a long chain of attempts to solve Project Euler problem #14 (Longest Collatz sequence) on HackerRank in the Haskell programming language. The problem is defined as ...
3
votes
1answer
115 views

arithmetic with numbers and letters

I've started learning JavaScript last week. Today I ran into a JS exercise available at this link codewars exercise and decided to give it a try. I've used very basic JS because I know only a small ...
5
votes
4answers
216 views

LeetCode: Roman to Integer in Java

I tried solve this easy leetcode challenge in java. Challenge link Here is my solution ...
10
votes
3answers
2k views

Simple Sudoku Solver in Python

This is my naive approach on implementing a Sudoku solver, which is okay for simple Sudokus like this: ...
5
votes
3answers
76 views

Add two digit strings and return the result as string

I haven't done C in a while. This looks like a simple problem to start. Leetcode problem 415 Given two non-negative integers num1 and ...
6
votes
2answers
939 views

Counting Balanced numbers in a given array

I am trying a code challenge. Here is the problem description When an element is deleted from an array, the higher-indexed elements shift down one index to fill the gap. A "balancing element" ...
1
vote
1answer
72 views

C++ Beginner. Project Euler 14: Longest Collatz sequence under one million [closed]

Hello, I'm a C++ beginner, learning the language while trying to code Project Euler problems. I'm having trouble coding problem 14, which I'll copy here: The following iterative sequence is defined ...
2
votes
1answer
59 views

Hackerrank problem -“Another Prime Problem”

I came across this issue in the problem titled: Another Prime Problem. Here's my solution with JavaScript which passed test case-1, but for other test cases it led to timeout. ...
1
vote
0answers
36 views

Knight Tour Heuristic

God sidetracked by this question: “Rock-Paper-Scissors Tournament” Which led me to the "Knight's Tour" problem. Initially did a brute force solution. This worked for most of the test. But timed out ...
0
votes
2answers
157 views

Sherlock and Anagrams in Javascript

I am trying to solve a Hackerrank problem Sherlock and Anagrams. I think my code is valid but somehow times out for some of the test cases. Any tips on how to improve its performance? Critique ...
2
votes
1answer
82 views

Calculate your total happiness, which depends on the integers in the given sets [closed]

I am a beginner in programming. And I am learning python as my first language. I went on to do some challenges on HackerRank and stumbled upon this problem. The problem goes like this: There is an ...
7
votes
2answers
111 views

Largest product in a grid - Project Euler 11

A stab at Project Euler Problem 11: Largest product in a grid ...
5
votes
2answers
610 views

Euler 12: counting divisors of a triangle number

This is the question: The sequence of triangle numbers is generated by adding the natural numbers. So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. The first ten terms would be: ...
2
votes
0answers
32 views

Project Euler Problem 54 poker hands in OCaml

I've been refactoring my OCaml solution for Project Euler problem 54, which is about comparing poker hands. While I'm mostly satisfied with my second iteration of the refactor, I stumbled upon two ...
3
votes
1answer
61 views

Find the number of swaps that has taken place. New Year Chaos. Hackerrank

I am trying to solve the following Hackerrank Problem. I have written the code for the problem. However, it runs for some of the test cases while for others it doesn't. It shows the message : "Your ...
1
vote
1answer
140 views

Maximal Char Requests in a String

I have been trying to deal with this problem set, and I have figured out how to solve it as well. But there is one problem that is ...
3
votes
2answers
88 views

Which products should be purchased with the given amount of money: Hackerrank?

I am writing code for the challenge given here . Below the text: Each time Sunny and Johnny take a trip to the Ice Cream Parlor, they pool their money to buy ice cream. On any given day, the ...
3
votes
2answers
110 views

Leap year check in Java (functional style)

I have done the leap year check on https://exercism.io already in a lot of languages. Today I came back to the exercise in Java and was playing around with some maybe more funny ways to do the check. ...
0
votes
0answers
36 views

Q: Leetcode: Find Pivot Index Java

https://leetcode.com/problems/find-pivot-index/ Question: Given an array of integers nums, write a method that returns the "pivot" index of this array. We define the pivot index as the ...
1
vote
0answers
43 views

Rock Paper Scissors Python Revision [closed]

I recently programmed a decently-sized program in Python, since I have just started really getting a feel for it. I am currently learning about dictionaries, so I didn't include any, but next time I ...
2
votes
2answers
104 views

Yraglac's transit woes

I decided to dive into the world of functional programming since my programming so far has been mostly in C/C++, Java, and Python. I've gone through a couple Haskell tutorials and played around in ...
4
votes
1answer
86 views

How to design shopping cart Java application which satisfy modular, extensible and maintainable

I am new in Application Design. I have use-case as below As per the above story I have implemented code as below without any Modularity, Extensible and Maintainable. Could someone share the thoughts ...
1
vote
0answers
61 views

GeeksForGeeks: Alien dictionary C#

https://www.geeksforgeeks.org/given-sorted-dictionary-find-precedence-characters/ please review for performance, the adjacency list is the problematic part for me. Given a sorted dictionary (array ...
-1
votes
1answer
66 views

Integer pairs with more than 3 common divisors

findPairs produces the Integer pairs so that the numbers from 1 to N and the pair of numbers have a sum less than 50 and have more than 3 common divisors. Could ...
0
votes
0answers
71 views

LeetCode: Course Schedule II C#

https://leetcode.com/problems/course-schedule-ii/ Please review for performance, please pay attention to the DFS function can this is be optimized? There are a total of n courses you have to take, ...
0
votes
1answer
99 views

A python Hang Man Game [closed]

can anyone give me advice on how i can make my code more compact and efficient, and if you can, an implementation using OOP? Since, i just started learning Object Oriented Programming and it looks ...
1
vote
0answers
38 views

LeetCode:MineSweeper C#

https://leetcode.com/problems/minesweeper/ please review for performance. I really don't like the implementation I made for GetNumberOfMines() function, but within the time limits i did this. it is ...
0
votes
1answer
76 views

Python User Input [closed]

I have recently completed the code challenge for exercise 48 in Learn Python3 the Hard Way. I was looking for any feedback on my solution and any ideas for improvement! The full task can be found ...
0
votes
0answers
24 views

LeetCode: Delete Nodes And Return Forest C#

https://leetcode.com/problems/delete-nodes-and-return-forest/ Given the root of a binary tree, each node in the tree has a distinct value. After deleting all nodes with a value in to_delete, we are ...
-1
votes
1answer
55 views

Project Euler's Multiples of 3 and 5 - Problem - Python [duplicate]

I just tried to solve this Problem in Project Euler but i don't understand why this code is not working and the output answer is wrong.QUESTION - If we list all the natural numbers below 10 that are ...
3
votes
2answers
98 views

LeetCode: Deepest Leaves Sum C#

Given a binary tree, return the sum of values of its deepest leaves. Constraints: The number of nodes in the tree is between 1 and 10^4. The value of nodes is between 1 and 100. ...
0
votes
1answer
70 views

LeetCode: FloodFill C#

https://leetcode.com/problems/flood-fill/ An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr,...
2
votes
1answer
38 views

LeetCode: Increasing Order Search Tree C#

https://leetcode.com/problems/increasing-order-search-tree/ Please review for performance Given a binary search tree, rearrange the tree in in-order so that the leftmost node in the tree is now ...
7
votes
3answers
215 views

Refactor the code which performs “cross-product”, “reduce”, “product of list” and “sum of list”

I have come up with a sequence of steps to find the maximum product of y positive numbers which add up to x. But the program is ...
-3
votes
1answer
98 views

Does my code follow good clean code conventions? [closed]

Here is a class that I have implemented in order to sort rows of parameters in the form of an array of strings. ...
1
vote
0answers
25 views

LeetCode: Search a 2D Matrix C#

https://leetcode.com/problems/search-a-2d-matrix/ Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row ...
1
vote
1answer
96 views

LeetCode: Divide Array in Sets of K Consecutive Numbers C#

https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/ Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of ...
2
votes
1answer
60 views

Bathroom stalls in Python 3 (Google Code Jam 2017)

This problem is tested against 3 sets of input data to see if the submitted solution gives an incorrect answer, if the solution exceeds the time limit, or if the solution exceeds the memory limit: ...
1
vote
1answer
185 views

Shortest path in Binary Maze

I want a feedback on my code for the below known problem from Daily coding challenge: You are given an M by N matrix consisting of booleans that represents a board. Each True boolean represents a ...
2
votes
2answers
75 views

Advent of Code 2019 day 2 in F#

I sped through the 5hr F# pluralsight course this week-end and thought I'd sement my learning by going through as many Advent of Code puzzles I could with this new learning. However, already on day 2 ...
3
votes
1answer
63 views

LeetCode: Network Delay Time Bellman Ford C#

https://leetcode.com/problems/network-delay-time/ There are N network nodes, labelled 1 to N. Given times, a list of travel times as directed edges times[i] = (u, v, w), where u is the ...
0
votes
0answers
35 views

LeetCode: Sliding Window Median C# Minheap + MaxHeap

https://leetcode.com/problems/sliding-window-median/ Please review for performance. and coding style, no need to review the max and min heaps. median is the mean of the two middle value. ...
5
votes
2answers
202 views

Simple Bubble Sort swap counter C++

This is the solution for a simple challenge from Hackerrank.I am just trying to solve Sorting: Bubble Sort Problem on HackerRank. We are asked to count the number of swaps performed during a bubble ...
3
votes
1answer
77 views

LeetCode: Sliding Window Median C#

https://leetcode.com/problems/sliding-window-median/ Median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value. So the median is the mean ...
0
votes
2answers
119 views

ProjectEuler.net problem #50, Consecutive Prime Sum

I am trying to solve ProjectEuler.net problem #50, Consecutive Prime Sum. Here is the problem: The prime 41, can be written as the sum of six consecutive primes: ...
1
vote
1answer
96 views

LeetCode: Sum of Two Integers C#

https://leetcode.com/problems/sum-of-two-integers/ Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: ...
3
votes
4answers
265 views

LeetCode: Number of steps to reduce a number to zero C#

https://leetcode.com/problems/number-of-steps-to-reduce-a-number-to-zero/ Given a non-negative integer num, return the number of steps to reduce it to zero. If the current number is even, you ...
2
votes
1answer
60 views

Advent of Code 2019 Day 7 (simple emulator, opcode processing)

Since couple of days ago I started to learn python by doing AoC 2019. I would like to share with you my solution to day7 (Amplification Circuit) part 1 and part 2. Challenge summary: --- Day 7: ...

1 2
3
4 5
60