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
3 votes
1 answer
55 views

Time limit error in 'The Minion Game' using python in Hacker Rank

This is the question link for the quick reference. Problem : There are two players Kevin and Stuart have to play a game in which they're pleased to create multiple strings and will get +1 score for ...
user avatar
3 votes
2 answers
74 views

Geektrust coding challenge: simulating a marketplace for loans

This is the my solution to a coding challenge in Geektrust. The question is linked here. A shortened version would be as follows. The aim is to simulate a marketplace for banks to lend money to ...
user avatar
  • 31
3 votes
2 answers
56 views

Leetcode 14. Longest Common Prefix beats only ~50% of C++ solutions

The task is to find the longest common prefix. While I had no trouble to find the solution, I'm interested in the statistics of my code: Runtime: 7 ms, faster than 56.36% of C++ online submissions ...
user avatar
0 votes
1 answer
71 views

duplicate an open file descriptor [closed]

My program implements a function similar to `dup2'. I would like you to please find any problems with the code and what I could improve. code: ...
user avatar
3 votes
1 answer
69 views

Partition List in 2 parts

I came up with the following code while trying to solve the Leetcode partition list problem Though my solution is accepted, I am not happy with a few of the additional variables which I am creating. ...
user avatar
  • 175
3 votes
2 answers
88 views

Counting primes less than n in Python

I implemented (a refinement of) the Sieve of Eratosthenes for counting primes less than a given number n. This is a coding exercise from LeetCode. The class Solution...
user avatar
3 votes
2 answers
76 views

MP3 Playlist Class in Python

Background Info I am an intermediate level Python programmer. This is my implementation of a MP3 Playlist class challenge that was hosted on 101 Computing.Net. The ...
user avatar
  • 131
4 votes
1 answer
59 views

Python program for the Longest Substring Without Repeating Characters

I write my Python program below for this Leetcode problem: Given a string s, find the length of the longest substring without repeating characters. Example 1: ...
user avatar
4 votes
3 answers
301 views

Split word based on terms from an array

I was faced with a coding challenge and I'm looking for a more elegant way to achieve the goal. The challenge Take the word baseball from the first item in the string array and split it into two ...
user avatar
9 votes
3 answers
2k views

Determine if Hill or Valley

This is my accepted submission for LeetCode. The problem is You are given a 0-indexed integer array nums. An index i is part of ...
user avatar
2 votes
3 answers
233 views

Subarrays with length

You are given an array A of length N (where N is as large as 2×105). All elements of the array are positive integers less than or equal to N. Determine the count of subarrays (contiguous subsequences) ...
user avatar
0 votes
1 answer
72 views

Largest product in a series

Problem description: The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832. 73167176531330624919225119674426574742355349194934 ...
user avatar
2 votes
3 answers
1k views

the 10001st prime number

Problem description: By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10001st prime number? Prime number: A prime number is a whole ...
user avatar
3 votes
1 answer
112 views

LeetCode 68. Text Justification

I am trying out Leetcode problem 68 and I need your help to asses the code. I am pretty new to this. Given an array of strings words and a width ...
user avatar
0 votes
2 answers
107 views

Sum square difference

Problem description: The sum of the squares of the first ten natural numbers is, 1² + 2² + … + 10² = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + … + 10)² = 55² = 3025 Hence ...
user avatar
2 votes
1 answer
662 views

The smallest positive number that is evenly divisible by all of the numbers from 1 to 20

Problem description: 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder. What is the smallest positive number that is evenly divisible by all of ...
user avatar
3 votes
3 answers
146 views

The largest palindrome made from the product of two 3-digit numbers

Problem description: A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the ...
user avatar
4 votes
2 answers
136 views

Calculate the first largest factor of 600851475143

ٍProblem description: The prime factors of 13195 are 5, 7, 13 and 29. Largest prime factor 13195 is 29. What is the largest prime factor of the number 600851475143 ? Prime Factor: any of the prime ...
user avatar
1 vote
0 answers
32 views

Cleanly modifying values in hashmap for a k-sum challenge

Just started learning Rust and here's a program that has caused me some agony to implement in Rust. This is very easy to implement in C++, but Rust's borrow checker is causing all sorts of trouble. My ...
user avatar
  • 33
1 vote
1 answer
95 views

JavaScript function that generates Fibonacci like sequences of given order

Generalizations of Fibonacci numbers Fibonacci numbers of higher order A Fibonacci sequence of order \$n\$ is an integer sequence in which each sequence element is the sum of the previous \$n\$ ...
user avatar
1 vote
1 answer
88 views

A simple JavaScript function that does prime factorization

This is a simple JavaScript function that does prime factorization. I wrote it on an Android phone with online editor (I don't have access to computers in night time): Code: ...
user avatar
2 votes
2 answers
158 views

FizzBuzz in JavaScript (node.js), my first JavaScript program

I had just decided to learn JavaScript, so I wrote this program. I am sure you know what FizzBuzz is so I wouldn't describe it here. Console output: ...
user avatar
1 vote
1 answer
82 views

Infix calculator programming challenge Kattis.com

I'm working on this C++ coding problem: Input is a sequence of up to commands, one per line, ending at end of file. Each command is a definition, a calculation, or a clear. All tokens within a ...
user avatar
0 votes
2 answers
96 views

Algorithm for twoSum

This is my PHP algorithm for the twoSum problem in leetCode: ...
user avatar
  • 3
1 vote
0 answers
51 views

PyQt6 program that lets you adjust the HSV values of an RGB color

I don't know how to actually describe what this script does concisely. I am writing GUI programs using PyQt6, and I want the most beautiful palette for my programs, so I browsed Wikipedia for a bunch ...
user avatar
0 votes
2 answers
140 views

LeetCode: C# fibonacci number iterative solution

https://leetcode.com/problems/fibonacci-number/ The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones,...
user avatar
  • 5,331
0 votes
3 answers
169 views

Find local maxima of a sequence

I'm well versed in Python and Java, am just starting out with C++. Am enjoying the language and would really appreciate feedback on this solution. kata: Return positions and values of the "peaks&...
user avatar
3 votes
1 answer
198 views

Codewars - How many pages in a book?

Problem Statement Every book has n pages with 1 to n pages. The summary is made by adding ...
user avatar
1 vote
1 answer
120 views

Finding the winner of a tic-tac-toe game in Swift

Working on the problem Find Winner on a Tic Tac Toe Game, I took several hours longer than an artificial time constraint the site had for mock interview purposes. This leads me to wonder if my ...
user avatar
2 votes
1 answer
69 views

Leetcode problem: minimum removal to make valid parentheses

I was working on this problem on leetcode Question Your task is to remove the minimum number of parentheses ( '(' or ')', in any positions ) so that the resulting parentheses string is valid and ...
user avatar
  • 179
3 votes
1 answer
92 views

Python 3 number convertor that converts floats between decimal and bases 2-36

This is a Python 3 script that converts any real number (ints and floats) from decimal notation to any positional number system ...
user avatar
0 votes
1 answer
63 views

Distribute items over array in order to minimize the difference between min and max array values

I came across this problem in a programming challenge a few days ago. I came up with the implementation below, however it resulted in a "time limit exceeded" failure for a few of the test ...
user avatar
0 votes
1 answer
53 views

Haskell solution to Day 2 problem of Advent of Code '21

I won't restate the problem in full, but in a nutshell you have to parse a file with a "direction" and a "magnitude", for instance: ...
user avatar
  • 199
0 votes
0 answers
49 views

Python one-line binary search

...
user avatar
3 votes
1 answer
125 views

Algorithm Challenge: Fuzzy Search

I recently took part in an algorithm challenge to create a Fuzzy search with the following criteria: Given a set array, create a function that receives one argument and returns a new array containing ...
user avatar
0 votes
0 answers
58 views

Finding all "triplets" of an integer array but in a more optimal manner

I'm practicing the following problem Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. ...
user avatar
  • 31
3 votes
1 answer
68 views

Function to sum all Armstrong numbers within a range

I've tried to solve a challenge posted on a LinkedIn forum using Haskell - a language I'm still learning the basics of - and, while the code works correctly, I would like to get some feedback on the ...
user avatar
  • 199
2 votes
1 answer
55 views

follow-up - Checking Nested Bracket Levels in Strings Programming Challenge

A follow-up to this question, this post improves on test case issues. To restate problem parameters, a given string S is considered closed if it: Has a matching ...
user avatar
  • 2,897
3 votes
2 answers
175 views

Programming Challenge - Capturing Bracket Levels

I don't have a formal description for this problem, but here are the parameters: Given a string S check that each opening bracket has a matching closing bracket. ...
user avatar
  • 2,897
4 votes
0 answers
160 views

GeekTrust: Traffic problem - functional programming

First attempt to write functional programming, been following OO paradigm all through my programming journey Please review the code and let me know if any comments and violations of functional ...
user avatar
3 votes
1 answer
120 views

Array rotation in C++

I am completely new to data structures and algorithms. I tried this problem on hackerank. I got the desired output but my code wasn't efficient enough to execute in the given time limit. How can I ...
user avatar
  • 89
2 votes
2 answers
73 views

Programming Challenge: Python 3 DNS query resolver using socket

This is a DNS query resolver written in Python 3 using socket, I wrote it entirely by myself, it supports 8 primary DNS query types: A, NS, CNAME, SOA, PTR, MX, TXT,...
user avatar
6 votes
0 answers
60 views

Chapter 8 Challenge: Add employee names to a department

The boring but exciting challenge: Using a HashMap and HashSet, create a text interface to allow a user to add employee names ...
user avatar
  • 61
2 votes
1 answer
189 views

Programming Challenge - Game Scoring

Can this solution be made more efficient? game_scoring.py ...
user avatar
  • 2,897
1 vote
1 answer
300 views

HackerRank CountingSort 1 in C#

Comparison Sorting Quicksort usually has a running time of n x log(n), but is there an algorithm that can sort even faster? In general, this is not possible. Most sorting algorithms are comparison ...
user avatar
11 votes
2 answers
673 views

Calculator using variable names

I've recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions....
user avatar
6 votes
1 answer
418 views

LFU Cache implementation in Python 3

Need some feedback on this implementation of LFU cache in python3. Original problem : https://leetcode.com/problems/lfu-cache/ Would really appreciate some feedback on readability, understandability ...
user avatar
  • 63
3 votes
1 answer
84 views

Highly divisible triangular number

Highly divisible triangular number, my solution My solution of challenge from Project Euler takes too much time to execute. Although on lower numbers it works fine. Anyone could look up to my code and ...
user avatar
  • 31
4 votes
2 answers
747 views

Coding exercise to implement IsApproximatelyEqual in Java

this assignment was given to me within the job application process (well, really not much infos given): for our applikation we have to compare very often floating point numbers (double, float). Can ...
user avatar
  • 2,482
3 votes
1 answer
447 views

Which fruit fall onto my house?

I am following a question on a programming challenge website (here's the original reference). What I have is a house (start & endpoint) and some types of trees at their respective location points. ...
user avatar
  • 33

1
2 3 4 5
66