Skip to content

Instantly share code, notes, and snippets.

View sachinlala's full-sized avatar

Sachin Lala sachinlala

  • Bangalore
View GitHub Profile
Required outcomes:
1. Provide an Auto-Complete text-box
2. Two modes:
- mode1: first-character match
- mode2: any character match
3. The match should be case-insensitive
Components:
1. API to render the full payload i.e. list of words
2. Frontend Component to call the API, apply the mode and display the results
@sachinlala
sachinlala / ClickCountData
Last active July 13, 2021 19:04
Click Count Forecasting
Following data-set provides the count of click-counts per day.
Required outcome:
- Based on the data provided, assert & recommend the model which will be most suitable to do forecasting for the traffic (number of click-counts per day).
- Share the outcome in the same format as the input file & also provide a graph for the upcoming traffic projection.
- It will be helpful to review the code & data in a github repository - please commit the notebooks to git & provide link to that if possible
Input Data: https://pastebin.com/F4g5dmnn
Categorisation for a multi-tenant Catalog
1. problem statement:
a. the raw data may or may not have categorisation done
b. enrichment process required to categorise the gift cards:
i. tool based
ii. systematic process
2. data model required which can support:
a. multiple tenants
b. multiple categories (one gift card could be under multiple categories)
Required Outcomes:
1. Create an e-commerce Product Detail page, in the domain of Gift Cards or General Merchandise or Groceries.
2. Create an API with mock data induced into it to render the product detail page:
For the API -
Input: Product URL Key
Output: JSON payload, with following fields: Product Id, Name, Description, Price, Availability, Image URL
* Product Id: Unique Identifier
* Name: The name to display at the top of the detail page
* Description: Brief description (4-5 words)
@sachinlala
sachinlala / Gift Cards Breakage Analysis
Last active July 13, 2021 19:15
Gift Cards Breakage Analysis & Forecasting
## Breakage Analysis & Forecasting
This involves taking a life cycle of a card and calculating how much money is left on the card post expiry.
The goal is to take ALL the cards where we get breakage and calculate the breakage.
Based on the breakage from past years, we need the ability to “forecast” the breakage for future.
Factors adding to the complexity but not limited to these are:
* Type of card - Open / Closed / Semi Closed Loop
* Categories of cards – fashion dining etc.
* Denomination of cards
@sachinlala
sachinlala / Algorithms 101
Last active October 28, 2018 17:52
Foundational Algorithms we must learn and practise.
https://github.com/sachinlala/SimplifyLearning/blob/master/algorithms/ALGORITHMS.md
@sachinlala
sachinlala / CouchBase101.md
Last active May 10, 2018 10:34
Notes about CouchBase

Origin

Couchbase is the merge of two popular NOSQL technologies:

  • Membase, which provides persistence, replication, sharding to the high performance memcached technology
  • CouchDB, which pioneers the document oriented model based on JSON

Read path

  1. Key-based lookup mechanism where the client is expected to provide the key, and only the server hosting the data (with that key) will be contacted.
  2. Query mechanism to retrieve data where the client provides a query (for example, range based on some secondary key) as well as the view (basically the index). The query will be broadcasted to all servers in the cluster and the result will be merged and sent back to the client.

Write path

@sachinlala
sachinlala / LoopInvariant.md
Last active May 10, 2018 05:53
What is a Loop Invariant ?

A loop invariant is a set of conditions that are:

  1. true when the loop is initialized
  2. maintained in each pass through the loop
  3. true at termination

Loop invariant arguments are analogous to mathematical induction: they use a base case along with an inductive step to show that the desired proposition is true in all cases.

For example, one feasible loop invariant for the kth largest/smallest algorithm would be the following:

At each iteration, the “active subarray” (call it activeA) consists of all elements of A which are between min(activeA) and max(activeA), and the current index (call it i) has the property that the ith-smallest element of activeA is the ith-smallest element of A.

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.*;
import java.util.regex.Pattern;
/**
* StringSplitter demonstrates the performance of different methods to split a String.<br>
* It iteratively splits a string (1-2 million times) so that we can get a collective view of the time taken.<br>
*/
@sachinlala
sachinlala / BoyerMooreVoting.java
Last active December 30, 2017 04:50
Find Majority Element
/**
* <a href="https://en.wikipedia.org/wiki/Boyer%E2%80%93Moore_majority_vote_algorithm">Boyer Moore Voting Algorithm</a>
* <p>Basic idea of the algorithm is if we cancel out each occurrence of an element e with all the other elements that are different from e then e will exist till end if it is a majority element.</p>
* Majority = n/2
*/
public class BoyerMooreVoting {
public static int findMajorityElement(int[] nums) {
int majorityIndex = 0;
int count = 1;
for (int i=1; i<nums.length; i++) {