All Questions
20 questions
2
votes
3
answers
2k
views
Given a sorted array nums, remove the duplicates in-place
I wrote an algorithm to solve this challenge but would love some feedback on its efficiency and, if you were an interviewer, what your opinion would be on my solution. I believe my time complexity is \...
3
votes
2
answers
733
views
Merging the frequency rankings of boys' names and girls' names
Problem statement:
The html pages for each year which represents the top 1000 most common Girl and Boy names in the order of their frequency are ranked and provided. And they are ranked based on the ...
3
votes
2
answers
4k
views
Hackerrank Submission Optimisation for Melodious Password
Given question from Hackerrank:
a password consists of exactly n lowercase English letters.
the password is melodious, meaning that consonants can only be next to
...
2
votes
1
answer
98
views
Optimize Performance challenge 'Vinay Queried '
Input:
The first line contains N denoting the length of Target String. This
line is followed by the Target String. The Target String is followed
by an integer Q denoting the number of queries ...
3
votes
1
answer
594
views
Project Euler #58: Primes along the diagonals of a square spiral
I am working on Project Euler Problem 58:
Starting with 1 and spiralling anticlockwise in the following way, a
square spiral with side length 7 is formed.
...
3
votes
2
answers
977
views
SPOJ ADDREV challenge - Adding reversed numbers
I'm a beginner Python (2.7) programmer, and I've just started solving basic problems on SPOJ. I correctly solved the ADDREV problem (http://www.spoj.com/problems/ADDREV/), however my code takes 0.06s ...
8
votes
2
answers
751
views
Sum of prime factors of binomial coefficients over 9000!\${}\$
The problem
I have lately been working Project Euler: 231:
The prime factorisation of binomial coefficients
The binomial coefficient \$ ^{10}C_3 = 120 \$.
\$ 120 = 2^3 × 3 × 5 = 2 × 2 × ...
3
votes
1
answer
120
views
Beating a dead horse: Project Euler 4
The task
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 ...
6
votes
1
answer
889
views
Palindromes that are sum of consecutive squares
I have been working on a Project Euler: 125, which took me ages to solve. The problem and source are cited below
The palindromic number 595 is interesting because it can be written as
the sum of ...
7
votes
5
answers
1k
views
Project Euler #35 - Circular primes solution is slow
This is my code for project euler #35 (in Python):
The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such ...
3
votes
2
answers
832
views
Project Euler #42 - Triangle Numbers
Here is the Euler problem referenced, it says:
The n\$^{th}\$ term of the sequence of triangle numbers is given by, t\$_n\$ =
½n(n+1); so the first ten triangle numbers are:
1, 3, 6, 10, 15, ...
4
votes
4
answers
3k
views
Project Euler #8 - Largest product in series
The problem
The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.
...
1
vote
1
answer
1k
views
Print the lexicographically smallest permutation that satisfies the given formation
Problem Statement:
A DOTA game has N heroes, each with a distinct rank from [1..N]. In
DOTA every formation is characterized as a permutation [1...N] of
ranks of players. A formation is Imba ...
2
votes
2
answers
919
views
Project Euler problem 23 - non-abundant sums
I present my solution for Project Euler problem 23 written in Python (2.7).
The problem statement is:
A perfect number is a number for which the sum of its proper divisors
is exactly equal to the ...
12
votes
3
answers
16k
views
Project Euler Problem 12 in Python
I'm trying to do Project Euler Problem 12, which reads as:
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 + ...