Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
(12, 6), (12, 6), (8, 2) <- Three pairs as there are two 12 there.
languge C, don't modify input array.
Why for n = 6 expected 3?
Array = {4, 8, 12, 12, 3, 6, 2}
Submitted: 0
Expected: 3
Log
n = 2
1 1 3 3
res = 4
n = 4
1 1 5 6 9 16 27
res = 3
n = 6
4 8 12 12 3 6 2
res = 0
Thanks for answer!
It was my mistake: empty input srting was reason of problem with memory.
OPTION 1
You are probably malloc'ing the exact len of the string.
For e.g.
Instead try
OPTION 2
Make sure you are not free'ing memory prematurely and then writing to the memory that was allocated
earlier. This can also cause SIGSEG to be raised.
Alternatively, think of an approach which eliminates the need to do either malloc'ing or free'ing.
This exercise is all about string examination, which doesn't require you to make copy of anything.
Just count the number of distinct characters that occur more than once.
One approach (in pseudo code) would be:
C, use malloc() and free() for memory.
Which language are you try to solve this kata in?
your first order of business is to study your code for which line has the bug causing the
Invalid memory access
error message. it's likely that you're trying to assign a value to an unavailable memory location, such as beyond the bounds of memory allocated for a static array...EDIT: okay, those look like random tests. they are going to be different all the time.
This comment is hidden because it contains spoiler information about the solution
Hi everyone!
Solution passed all sample tests, works fine in IDE, but when I try attempt I get next error in one of tests:
Test Crashed
Caught unexpected signal: SIGSEGV (11). Invalid memory access.
How can I get string, which crashed test?
Thanks!
"aabBcde" -> 2 # 'a' occurs twice and 'b' twice (
b
andB
)