# Paribus to save your day!

One of my friends posted about Paribus a few months back, the concept of getting a refund without doing any work at all, appealed instantly to me and I signed up for the service. I linked my Gmail account and Amazon account so that it could track the purchases and apply for a refund when it notices a price drop within the refund window. They can apply for a refund on your behalf to a list of merchants mentioned on their site, which features an impressive list of popular stores one would usually go for online shopping. They charge a 25% cut on the refund amount.

Since I am not an active online shopper and none of my purchases qualified for a refund, I almost forgot that I had signed up for this service until I got an email last week that said: "\$2 Found - From Team Paribus".

And I was almost as wowed as Owen Wilson saying wow! 🙂

Pros:

2. No need to worry about keeping track of different refund policies of different stores.
3. Automated filing of claims on your behalf.

Cons:

1. Some people may have security concerns since the service requires you to authorize access to your email account and Amazon account.
2. There is a 25% cut, which could be saved if you are willing to monitor the price daily, keep in mind the refund policy of store, ready to file a claim by visiting the store or the store website.

I think it's a really clever and effective service. I have never gone back to look for a price drop for purchases I make. So, it almost feels like getting back lost money. If you would like to try out this service, you could sign up using this link (yes, this is my referral link so that if you sign up, it can reduce Paribus's % cut in my refund 🙂 ).

# Print matrix elements in spiral order

This is one of the common interview questions used to test how cleanly you can code without ending up in knots handling the indexes.

Problem statement:

Given an N x M matrix, print the elements in spiral order.
Example for matrix:
[
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 10],
[11, 12, 13, 14]
]

Output would be 1 2 3 4 5 10 14 13 12 11 6 7 8 9

Solution:
There could be various ways of solving this. I am sharing the approach I used to solve it.
The idea is to keep 4 indexes to track the matrix boundaries, start with a direction value pointing to right initially and then once it hits the right most boundary, change direction and update the relevant boundary value.
For example, when we are going in right direction, and we hit the boundary, we need to go clockwise and change to go down next and we also need to increment the xMin value as we have covered the row corresponding to that xMin value.

```public static void printSpiral(int[][] matrix, int n, int m) {
int xMin = 0, yMin = 0, xMax = n - 1, yMax = m -1;
// Current co-ordinates
int x = 0, y = 0;
char direction = 'r';
while (xMin <= xMax && yMin <= yMax) {
// Get the next direction
switch(direction) {
case 'd': if (x == xMax) {direction = 'l'; yMax--;} break;
case 'r': if (y == yMax) {direction = 'd'; xMin++;} break;
case 'u': if (x == xMin) {direction = 'r'; yMin++;} break;
case 'l': if (y == yMin) {direction = 'u'; xMax--;} break;
}
// Print the current co-ordinates
System.out.print(matrix[x][y] + " ");
// Update the current co-ordinates
switch(direction) {
case 'd': x++; break;
case 'r': y++; break;
case 'u': x--; break;
case 'l': y--; break;
}
}
}
```

# Tip calculator

How often have you left a tip that you later realized wasn't what you desired to give? Well, I guess from personal experiences, it does happen, as sometimes you miss the calculations a bit. That's why these days you would see a bill (or check which is the more common word for it here in USA) often with tip amounts suggested for our convenience. One could always use the calculator app on their phone to compute the right amount but I think I am yet to come across someone who has done that. And I don't know the reason why we consider using our smartphones to take pictures of food we eat is cool but it's not cool to use it to get the tip amount right. Although, it's the latter that makes a real difference in someone's day (or earnings).

Anyways, so, I googled if there are any apps for it, and surprise! You don't need an app when you got Google 🙂