Thank You for idea of substrings!
In Java I add 3 lines and modifying line with āanswerā - all tests done
Dang it.
First try, one new object created, one line added to sample implementation, one var added to the original print.
Done, all tests passing with flying colors. I love ruby
Now I feel bad because I canāt tell how I did itā¦
EDIT
My two cents for the people that still have some trouble with this: Remember that some structures only allow unique objects
I canāt understand why, but i get āInternal compiler error close to this locationā at the line that contains āForā (VB.net)
Dim n as Integer = Console.ReadLine()
Dim telephone() as String
Dim i as integer
For i = 0 To n-1
telephone(i) = Console.ReadLine()
Next i
Why do i get this error? and also, is that the proper way to store strings on an array? can i use later telephone(i).length to measure the size of each string?
The validation tests in this one include a separate āall numbers are the sameā case, whereas the debugging ones donāt. Though there are duplicates in the last case, the large entry.
This ended up very confusing for me when my bash solution kept timing out on the large case: it was a trivial bug that could be fixed in a few characters, but I spent a long time looking for performance improvements that werenāt actually needed. (Those who solved the more complex problems in bash know what Iām talking about!)
Iām sure many future problem solvers would appreciate having a dedicated āduplicatesā case separate from the large data set.
Or at least having this reminder in the forum that itās worth testing for.
5 lines of code (php)
Lol, this problem is a joke compared to the other medium problems. I did this in less than 5 minutes, implementing it with a hashmap.
If you implement it right, a trie can be ~3 times faster than a hashmap/set (i got ~35 msec for hashset and 13 for trie, in C++).
Not that it matters much, and the hashmap/set solution is much shorter.
If you implement it Right, not using a data structure at all is probably even faster.
You mean like, no arrays, no strings?
Debate? Seriously, just read the definition. If you can solve the puzzle without using any, I will be genuinely impressed.
Seriously, just read the definition.
A conversation destroyer if I ever read one. Suits me.
I am quite new to clojure and I was wondering how others dealt with the (read) function dealing out exceptions because of numbers starting with 0.
clojure.lang.LispReader$ReaderException: java.lang.NumberFormatException: Invalid number: 0123456789
use (read-line) instead of (read)
the clojure stub has problems right now
How I pass the last test with python?
I have a tuple of string and I am comparing, than I count the numbers but that is not efficient. I have this:
for i in range(n): #Each number.
for j in range(i): #Numbers before of this.
for k in range(len(tp[i])): #Digits of the actual number.
#Here I count the numbers.
Yeah, nested loops tend to fail on big data sets. The last test has 10,000 entries, so youāre looping millions of times with that arrangement.
Try using a different data structureā¦ a great many would be better suited than a plain array. Look at a how a tree works, for starters.
How python not have trees I searched in Google and found Classes with many functions, very much code, then i only used a dictionary and do it with 11 lines of code. Now I think that write 100 lines of code for a simple tree is something crazy, at least for my case.
Hi!
Maybe Iām doing something wrong, but I think thereās some bug cause if I try a custom test, like this one:
5
015
014
013
112
056
I never receive the last input, and so process times out, but why? I donāt get itā¦
Youāre doing something wrong . Maybe a while infinite loop?
Mmm, Iām quite puzzled : Iāve developped a Javascript solution which gets 100% score on tests, but only 44% on validation ā¦ I donāt know what Iām getting wrong ā¦
Are we alright that a tree data structure with one node for each number, is the expected storage method ?