# Home # Welcome to My New Technology Blog

• ## Scala vs Python

July 5, 2020

List some of the advantages of using Scala, as opposed to other languages. In order to explain this, I am comparing Scala vs Python. If you want to write some serious Apache Spark programming it is better to choose Scala because of following reasons. Note: Following comparisons are based on the fact that I am… Read more

• ## Certifications

August 8, 2021
• ## Euclidean vs Manhattan Distance

August 4, 2020

Euclidean Distance: In order to calculate the distance b/w tow points in a given Space – can be a N-dimensional, we can use Euclidean distance formula: D(x1,x2) = SQRT((x1-x2)**2 + (y1-y2)**2) where SQRT is Square Root D stands for distance b/w point x1,x2. we can extend this for N- dimensional plan as follows D(x1,x2,x3,…xn) =… Read more

View all posts

Get new content delivered directly to your inbox.

## Python coding

Rearrange a number list such that positive numbers will fit at the end of the list; negative numbers at the beginning of the list:

O(n): T(N) as we are doing in-place and traversing the list only once.

def rearrange(lst):

```#assume that left most element is a positive element

leftMostPostiveElementIndex = 0

for curr in range(len(lst)):

if (lst[curr] < 0):

if (curr is not leftMostPostiveElementIndex):
#swamp two
lst[curr], lst[leftMostPostiveElementIndex] = lst[leftMostPostiveElementIndex], lst[curr]

leftMostPostiveElementIndex +=1
return lst
```

print(rearrange([10,-1,20,4,5,-9,-6]))