Skip to main content

All Questions

4 votes
1 answer
140 views

Efficient polynomial multiplication in Python

I'm practicing problems for the ICPC competition, and one of the problems requires solving it by using an FFT to compute the product of two polynomials efficiently. Since this is for the ICPC ...
João Areias's user avatar
2 votes
1 answer
98 views

HackerRank Algorithm Problem: Climbing the Leaderboard (Python)

Here is the Hackerrank problem which is related to dense ranking and below is my solution which didn't pass the time limit cases. Any better way to optimize this? ...
peternish's user avatar
3 votes
1 answer
363 views

Python function to find the count of digits of numerals in base n up to a given limit

This is a simple exercise to find the count of digits of all numerals in a given base up to a given limit (not including the limit), I wrote it to determine the ratio of bytes saved when the numbers ...
Ξένη Γήινος's user avatar
7 votes
2 answers
1k views

Find all combinations of length 3 whose sum is divisible by a given number

I came up with a suitable solution to a HackerRank problem that failed because the execution took longer than 10 seconds on lists that were of very large size. The problem: Given a list ...
NFeruch - FreePalestine's user avatar
1 vote
2 answers
718 views

Find the cheapest flight to reach from source to destination

As the input you get the flight schedule as an array, each element of which is the price of a direct flight between 2 cities ...
meallhour's user avatar
  • 133
2 votes
1 answer
4k 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 ...
Amir Motefaker's user avatar
6 votes
1 answer
751 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 ...
Mike's user avatar
  • 63
5 votes
2 answers
675 views

DNA Challenge from CS50

Added the problem link below and my implementation of it. Took me a few hours to program. I have added comments to explain my thought process. Problem Link Goal - To implement a program that ...
singhsokhal's user avatar
1 vote
1 answer
208 views

Rock paper scissors coding assignment

I had a coding assignment to write a Rock Paper Scissors game. The main task is not to show a solution but rather to test the coding style. The rules are such: Problem: rock is "O", paper is ...
Harton's user avatar
  • 33
10 votes
4 answers
3k views

First non-repeating Character, with a single loop in Python

I recently tried to solve the first non-repeating character problem. Please tell me if my solution is valid. I'm aiming for O(n) with a single loop. My thinking is, it would be easy to tell you what ...
zing's user avatar
  • 203
3 votes
1 answer
604 views

3Sum LeetCode problem coding challenge

LeetCode 3Sum 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. Notice that the ...
Joseph Gutstadt's user avatar
1 vote
2 answers
1k views

Simplest possible Tic Tac Toe AI in Python

Last week I challenged myself to create the smallest possible code for a Tic Tac Toe game with an AI as opponent. Smallest possible in regards to say least number of characters used. The requirements ...
eligolf's user avatar
  • 129
3 votes
2 answers
590 views

LeetCode 8: String to Integer (atoi)

I'm posting a solution for LeetCode's "String to Integer (atoi)". If you'd like to review, please do. Thank you! Problem Implement atoi which converts a string to an integer. The function ...
Emma's user avatar
  • 3,592
9 votes
3 answers
640 views

CSES standard solution for range query problem giving TLE

Problem statement is from CSES This is a standard question where we are given a list of numbers and a number of queries. For each query, you have to give the sum of numbers in the given range. My ...
YetAnotherBot's user avatar
4 votes
2 answers
2k views

3-SAT Solver Python

I've written a 3-SAT solver based on this prompt: Alice recently started to work for a hardware design company and as a part of her job, she needs to identify defects in fabricated integrated ...
n00bster's user avatar
  • 165

15 30 50 per page
1
2 3 4 5
11