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
0 answers
31 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
254 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
8 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
219 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
69 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
90 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
100 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
517 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
124 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
128 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
30 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
91 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
79 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
133 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
66 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
69 views

Algorithm for twoSum

This is my PHP algorithm for the twoSum problem in leetCode: ...
user avatar
  • 3
1 vote
0 answers
45 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
118 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,329
0 votes
3 answers
153 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
168 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
99 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
62 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
82 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
55 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
48 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
42 views

Python one-line binary search

...
user avatar
3 votes
1 answer
83 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
52 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
60 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
51 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
168 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
155 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
106 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
64 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
58 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
164 views

Programming Challenge - Game Scoring

Can this solution be made more efficient? game_scoring.py ...
user avatar
  • 2,897
1 vote
1 answer
207 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
628 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
395 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
77 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
736 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,392
3 votes
1 answer
444 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 vote
2 answers
86 views

It is considered a daemon if it runs in the background - creating a daemon in C

I created a daemon that creates a fifo file with a default name, then is been blocked waiting for messages on that fifo. When an interactive process writes data to that fifo, the daemon wakes up and ...
user avatar
  • 449
3 votes
1 answer
88 views

Maximum Depth of Binary Tree in JavaScript

The task Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. ...
user avatar
  • 3,955
2 votes
0 answers
22 views

Maximum length of a row made up from given dominoes

Given a set of dominoes, find the maximum length of a row that can be made using some of those dominoes. Rotating the dominoes is allowed. Recall: A domino piece consists of 2 numbers from 0 to 6 (e....
user avatar
3 votes
2 answers
144 views

Encoded string algorithm with given rules

Looking for general feedback and if there is a solution that can reduce the time complexity from the current O(n2)? Thank you. Problem Statement Consider a string that consists of lowercase English ...
user avatar
4 votes
1 answer
225 views

Kattis challenge, processing string with special characters and conditions

I'm new to programming challenges and I'm attempting the following Kattis challenge Sim. This problem is an extension of another Kattis problem - backspace. In that problem, every time we see a ...
user avatar
2 votes
1 answer
111 views

Maximum subarray sum modulo m

This is a well-known problem from a HackerRank challenge: Given an array and a number M, output the maximum of all subarray sums modulo M, M between 1 and 1E14. A ...
user avatar
  • 581
4 votes
3 answers
594 views

Wordle puzzle game

I am a beginner programmer with not much experience, the little I do have is with Python specifically. With all the fuss going around about the popular word game "Wordle" I wanted to ...
user avatar

1
2 3 4 5
66