Question: I am trying to get wooCommerce order id. I wrote the following script in functions.php but i getting 0.Can you tell how to get the Id.

```
global $woocommerce, $post;
  $order = new WC_Order($post->ID);
  $order_id=$order->get_id();

```

Answer: 
A quick search for "time limit exceeded" and leetcode gives the following result: [enter link description here](https://support.leetcode.com/hc/en-us/articles/360011883714-What-is-the-difference-between-Time-Limit-Exceeded-TLE-and-Timeout-)

With this information.

> 
> If your solution is judged Time Limit Exceeded, it could be one of the following reasons:
> 
> 
> Your code has an underlying infinite loop.
> Your algorithm is too slow and has a high time complexity.
> The data structure you returned is in an invalid state. For example, a linked list that contains a cycle.
> 
> 
> 

Think about those three things.
You can make it faster by using a list comprehension instead:

```
class Solution:
    def triangularSum(self, nums: List[int]) -> int:
        while len(nums) != 1:
            nums = [(nums[i]+nums[i+1])%10 for i in range(len(nums)-1)]
        return nums[0]

```

which gives an output of:
[![enter image description here](https://i.stack.imgur.com/EPyor.png)](https://i.stack.imgur.com/EPyor.png)

Edit: Here's another method that is definitely faster:

```
class Solution:    
    def triangularSum(self, nums: List[int]) -> int:
        # The idea of this is similar to the Pascal's triangle. 
        # If you deconstruct graph from the first example of [1, 2, 3, 4, 5] which is 48 -> 8
        # The coefficient for each number is [1, 4, 6, 4, 1] which is equivalent of row (n-1) in Pascal's triangle

        coefs = self.getRow(len(nums) - 1)

        return sum(num*coef for num, coef in zip(nums, coefs))%10

    @staticmethod
    def getRow(rowIndex: int):
        result = 1 
        yield result
        for i in range(rowIndex, 0, -1):
            result = result * i // (rowIndex+1-i)
            yield result

```

which gives an output of
[![enter image description here](https://i.stack.imgur.com/ilti1.png)](https://i.stack.imgur.com/ilti1.png)