Skip to content

Instantly share code, notes, and snippets.

View mohanmca's full-sized avatar

Mohan Narayanaswamy mohanmca

View GitHub Profile
@mohanmca
mohanmca / ShortestSubarrayWithSumAtLeastKFull.java
Created October 12, 2021 03:55 — forked from johnyleebrown/ShortestSubarrayWithSumAtLeastKFull.java
Shortest Subarray with Sum at Least K (partial solution)
class Solution
{
public int shortestSubarray(int[] A, int K)
{
IMQ q = new IMQ(K);
q.push(new Item(0, -1));
for (int i = 0; i < A.length; i++)
{
// rewriting array with prefix sums
@mohanmca
mohanmca / leetcode.md
Last active October 3, 2021 12:13
Analyze question frequency based on company

Steps to find tag frequency of problems set for a company

  1. Goto page that has problem for a company - https://leetcode.com/company/goldman-sachs/
  2. Select check box "Show problem tags"
  3. "Open console of the browser - F12"
  4. Paste below javascript
  let tags = Array.from(document.getElementsByClassName('tags-cell__I1pn'))
 let table = tags.map( e =&gt; Array.from(e.children).map(e1=&gt;e1.innerText)).reduce((a,b) =&gt; a.concat(b),[]).sort().reduce((r,c) =&gt; (r[c] = (r[c] || 0) +1, r), {})
https://inetapps.nus.edu.sg/gda2/Referee.aspx/RefereeReport/Index?id=BF120AADA1B945E5B5296E276BF381DE&data=OdBMw%2ffGb03nqLYI8iFHXAoWlhtLbe0uHdv%2bND3Ao2I%3d
@mohanmca
mohanmca / .block
Created May 24, 2019 22:41 — forked from mbostock/.block
Bullet Charts
license: gpl-3.0
  • I am not qualified to comment on the merits of these technologies as currencies or mechanisms for agreeing contracts. However, from a data systems point of view they contain some interesting ideas. Essentially, they are distributed databases, with a data model and transaction mechanism, in which different replicas can be hosted by mutually untrusting organizations. The replicas continually check each other’s integrity and use a consensus protocol to agree on the transactions that should be executed.
  • Outside of the hype of cryptocurrencies, certificate transparency is a security technology that relies on Merkle trees to check the validity of TLS/SSL certificates
  • Let us replace the word data with Surveilance - “In our surveillance-driven organization we collect real-time surveillance streams and store them in our surveillance warehouse. Our surveillance scientists use advanced analytics and surveillance processing in order to derive new insights.”
  • Even the most totalitarian and repressive regimes could
@mohanmca
mohanmca / richhickey.md
Created April 18, 2018 13:47 — forked from prakhar1989/richhickey.md
richhickey.md

Rich Hickey on becoming a better developer

Rich Hickey • 3 years ago

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

@mohanmca
mohanmca / YcombinatorLinkCounter.md
Created April 4, 2018 15:37
YcombinatorLinkCounter.md
const container = document.evaluate('//a', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE , null)
const items = Array.from(Array(container.snapshotLength).keys())
const _links = items.map(i => container.snapshotItem(i).innerHTML).filter(text => text.indexOf("http")!=-1)
const links = _links.sort().filter((e,i,a) => a.indexOf(e)==i)
console.log("Unique links \n" + links.join("\n"))
let map = {}
_links.sort().map(link => link.substring(0,100)).forEach(link => map[link] = (map[link] || 0) + 1)
Object.entries(map).sort(kv => kv[1]).map(kv =>  kv[1].toString().padEnd(4) + kv[0]).join("\n")