All Questions
35 questions
0
votes
1
answer
52
views
Aggregate transactions in slips
I wrote code to aggregate transactions in slips. I'm concerned with the performance of my code because it uses 3 loops that are nested so the time complexity will be cubic. This code won't scale well ...
0
votes
1
answer
86
views
Parsing shortcodes out of a string
I wrote this shortcode parsing and it runs in \$O(N^2)\$. Is there a way to better optimize this?
...
2
votes
2
answers
764
views
Golang implementation of dining philosophers variant
I would like to implement a variant of the classical dining philosophers problem which has the definition as:
Implement the dining philosopher’s problem with the following constraints/modifications.
...
4
votes
1
answer
343
views
Golang function that reads S3 files and populates maps with strings as keys
I have a below read function which is called by multiple go routines to read s3 files and it populates two concurrent map as ...
2
votes
1
answer
158
views
Golang solution to CTCI 1.2: Check whether two strings are permutations of each other
Just started learning Go recently. Did some questions from Cracking the Coding Interview book. Wrote the solutions in Go. Let me know what you think.
https://github.com/samjingwen/ctci
Below is ...
0
votes
1
answer
107
views
Is there a better "Go" way to implement LC Add Two Numbers solution
Problem Statement:
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the ...
0
votes
1
answer
108
views
How to make Print() method memory & CPU efficient?
Problem Statement
You are receiving n objects in a random order, and you need to print them to stdout correctly ordered by sequence number.
The sequence numbers start from 0 (zero) and you have to ...
2
votes
1
answer
170
views
Blocking send and receive algorithm in Go
I'm sending and receiving data over an interface (serial in this case) with the following behaviour:
The receiver sends back an Ack message if a message is delivered successfully.
If an Ack is not ...
4
votes
1
answer
173
views
CLRS implementation (opportunity to sort subarray) of merge sort in golang
I'm reading "Introduction to Algorithms" by CLRS and I can't find an implementation of the pseudo code from the book in golang. By the original implementation I mean that we deal with extra parameters ...
2
votes
0
answers
43
views
How to define UDP connection sessions more correctly?
Listening to messages from the udp socket, I would like to somehow determine where packets come from and scatter in sessions to get a more detailed report on the received data, I just did it forehead, ...
2
votes
2
answers
94
views
Count the number of discrete values in a slice
I'm using this right now to count the number of discrete values in a given []string. Is there a faster way to do this?
...
4
votes
1
answer
2k
views
Matrix Transpose in Golang
I have write a normal programm "Transpose the matrix" in go. Suppose input are always correct. I also read the article An Efficient Matrix Transpose in CUDA C/C++. So I keen to know how I can use Go-...
7
votes
1
answer
297
views
Boyer Moore Horspool Search Algorithm in Go
I am practicing Go and try to implement Boyer Moore Horspool Algorithm in Go, It returns all ocurrance of a "phrase" in a given text. This code is working, but I would be pleased to have any feedback ...
5
votes
1
answer
179
views
Find the longest word in a string
I have written code in the language Go. I wonder if anyone can do it in a very simple and effective way, because every language has its own way to solve this problem. My experience is in JavaScript. ...
2
votes
3
answers
2k
views
Remove adjacent duplicates in golang
This is an exercise in a book which ask me to implement
Write an in-place function to eliminate adjacent duplicates in a []string slice.
I am relatively new to golang and I am not sure if my ...