https://play.golang.org/p/dqp7po8Tg_4 is a working solution and it takes
only O(n^2), if you are curios. Your way of creating a numMem is also nice.
Thanks.

2018-05-23 12:55 GMT+05:30 Karan Chaudhary <fghj...@gmail.com>:

> One other simpler (and not so elegant) solution is to use separate set for
> each element.
>
> https://play.golang.org/p/9ZSRfAyOX4-
>
> @Bakul's solution sounds good but haven't tried to understand it clearly.
>
>
>
>
> On Wednesday, 23 May 2018 11:46:15 UTC+5:30, Sankar wrote:
>>
>> Use an array instead of a slice. An array has a fixed size and can be
>>> used as a key to a map
>>>
>>> https://play.golang.org/p/xxxmrwpx08A
>>>
>>
>> This seem to not work. The arr is returning only duplicate elements in
>> your playground url.
>>
>> For example:
>>
>>        var arr [][]int
>> for mem := range m {
>> fmt.Println("Appending: ", mem[:])
>> arr = append(arr, mem[:])
>> }
>> fmt.Println("Final arr is:", arr)
>>
>> the output is:
>>
>> Appending:  [-1 0 1]
>> Appending:  [-1 -1 2]
>> Final arr is: [[-1 -1 2] [-1 -1 2]]
>>
>> I am not really able to understand why the above code works so. The
>> "Appending" and the "Final arr" statements have different values.
>>
>> --
>> Sankar P
>> http://psankar.blogspot.com
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "golang-nuts" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/golang-nuts/fcBDb2wjtac/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> golang-nuts+unsubscr...@googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Sankar P
http://psankar.blogspot.com

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to