All Questions
153 questions
5
votes
3
answers
1k
views
Project Euler Problem #1: Multiples of 3 or 5
Project Euler Problem #1
Multiples of 3 or 5 states:
If we list all the natural numbers below 10 that are multiples of 3 or
5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of ...
4
votes
1
answer
142
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 ...
2
votes
1
answer
100
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?
...
3
votes
1
answer
366
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 ...
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 ...
1
vote
2
answers
722
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 ...
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 ...
6
votes
1
answer
758
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 ...
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 ...
1
vote
1
answer
210
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 ...
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 ...
3
votes
1
answer
605
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 ...
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 ...
5
votes
2
answers
605
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 ...
9
votes
3
answers
646
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 ...