Skip to content
Advertisement

Tag: time-complexity

CodeSignal reverseParentheses Failing one case

Write a function that reverses characters in (possibly nested) parentheses in the input string. Input strings will always be well-formed with matching ()s. For inputString = “(bar)”, the output should be reverseInParentheses(inputString) = “rab”; For inputString = “foo(bar)baz”, the output should be reverseInParentheses(inputString) = “foorabbaz”; For inputString = “foo(bar(baz))blim”, the output should be reverseInParentheses(inputString) = “foobazrabblim”. [input] string inputString A

Object.entries() time complexity

Does anyone know the complexity of Object.entries() in Javascript? Based on this question I’d guess at maybe O(n) as well if it’s implemented by obtaining the keys and values as arrays then zipping them together? Answer (V8 developer here.) Short answer: yes, the complexity of Object.entries() is O(n) in most cases. For large objects (thousands of properties), it is O(n

Advertisement