• ###### geofflangenderfercommented on "Count the Digit" ocaml solution

O(n log n) time
O(1) space because no extra data structures used

this is best

O(n) time
O(1) space

• ###### monadiuscommented on "Mumbling" ocaml solution

When you post a comment with code please use the spoiler flag. All comments without the spoiler flag are visible in the Dashboard.

• ###### geofflangenderfercommented on "Mumbling" ocaml solution

This comment is hidden because it contains spoiler information about the solution

• ###### geofflangenderfercommented on "Mumbling" ocaml solution

This comment is hidden because it contains spoiler information about the solution

• ###### geofflangenderfercommented on "Mumbling" ocaml solution

O(n^2) time because String.sub creates a new string for each element of the input

• ###### geofflangenderfercommented on "Mumbling" ocaml solution

This comment is hidden because it contains spoiler information about the solution

• ###### monadiuscommented on "Is it a palindrome?" ocaml solution

This solution has `O(String.length s)` space complexity because `String.lowercase_ascii` creates a new string.

• ###### FlakeTwistcommented on "Is it a palindrome?" ocaml solution

Thanks for the pointer (no pun intended)! In hindsight that's a clear optimisation.

• ###### geofflangenderfercommented on "99 Problems, #6: detecting a palindrome list" ocaml solution

Nice

O(List.length list) time complexity
O(List.length lr) space complexity due to stack space from reverse

• ###### geofflangenderfercommented on "Is it a palindrome?" ocaml solution

O(String.length s) time complexity
O(1) space complexity bc aux is tail recursive

• ###### geofflangenderfercommented on "Is it a palindrome?" ocaml solution

I think this is O(n^2) because String.sub creates a new string on each call.

I had the same idea. I avoid creating a new string by keeping track of two pointers, beginning and end.

• ###### monadiuscommented on "Opposite number" ocaml solution

`~-` is the integer negation operator.

what is ~?

• ###### monadiuscommented on "Powers of 2" ocaml solution

`@` concatenates two lists. Here is the official reference.