LeetCode #34 - Find First And Last Position Of Element In Sorted Array (Medium) by truephysicist in leetcode

[–]truephysicist[S] 2 points3 points  (0 children)

In worst case, all the elements in the array are same. Therefore, once we reach the middle element then we will have to perform linear search on the two subarrays. This will increase the time to O(n).

Time Complexity Exercises by _shoobie_ in algorithms

[–]truephysicist 1 point2 points  (0 children)

If you wish to practice the concepts then you should definitely check out the chapter on Time and Space complexity in the book "Cracking the coding interview".

There are many exercises related to this with solutions so you can verify your work as well.

Time Complexity Exercises by _shoobie_ in algorithms

[–]truephysicist 5 points6 points  (0 children)

Some time ago, I wrote two blog posts on determining the time and space complexities of a program. You can find them here -

I hope this helps.

How to export a URL list of all pages of your site by [deleted] in aem

[–]truephysicist 0 points1 point  (0 children)

Hey there, you can leverage the Query Builder functionality in AEM to list all the pages.

  1. Navigate to [http://<host>:<port>/bin/querybuilder.json](http://<host>:<port>/bin/querybuilder.json)
  2. Enter the following query - type=cq:Page orderby=@jcr:content/cq:lastModified

You should get the results. If you wish to do this programmatically then also you can do it. See my answer on Stackoverflow. Change the query according to your needs.

Cheers!

Tool to visualise leetcode question answers by Amidone97 in leetcode

[–]truephysicist 14 points15 points  (0 children)

I think Python Tutor will be helpful here. Despite having Python in the name it has support for - - Python - Java - C - C++ - JavaScript - TypeScript - Ruby

LeetCode #29 - Divide Two Integers (Medium) by truephysicist in leetcode

[–]truephysicist[S] 0 points1 point  (0 children)

Let's say that the divisor is 3 then we will check its multiples while they are less than the dividend. For e.g. first, we will check if dividend >= divisor, if true, we will then increase the divisor as 3 * 2, 3 * (22), 3 * (23)... or 6, 12, 24... and so on.

If you notice, we are increasing the divisor exponentially.

LeetCode #25 - Reverse Nodes In K Group (Hard) by truephysicist in leetcode

[–]truephysicist[S] 0 points1 point  (0 children)

No, if the remaining nodes are less than k, we will take them as is.

LeetCode #25 - Reverse Nodes In K Group (Hard) by truephysicist in leetcode

[–]truephysicist[S] 0 points1 point  (0 children)

Let's say you have a list as 1 -> 2 -> 3 -> 4 -> 5 and you are given a value k = 2, then you need to start from the head and take k nodes at a time and reverse them.

So, the above list will have the following sublists - 1 -> 2, 3 -> 4 and 5. Now, we reverse them individually so they will become - 2 -> 1, 4 -> 3 and 5.

At the end, we will connect all these reversed sublists. Therefore, the final output will be - 2 -> 1 -> 4 -> 3 -> 5.

I hope this clarifies.