Skip to content

Instantly share code, notes, and snippets.

View hackjutsu's full-sized avatar
:octocat:
building something great

CosmoX hackjutsu

:octocat:
building something great
View GitHub Profile

Stevey's Google Platforms Rant

I was at Amazon for about six and a half years, and now I've been at Google for that long. One thing that struck me immediately about the two companies -- an impression that has been reinforced almost daily -- is that Amazon does everything wrong, and Google does everything right. Sure, it's a sweeping generalization, but a surprisingly accurate one. It's pretty crazy. There are probably a hundred or even two hundred different ways you can compare the two companies, and Google is superior in all but three of them, if I recall correctly. I actually did a spreadsheet at one point but Legal wouldn't let me show it to anyone, even though recruiting loved it.

I mean, just to give you a very brief taste: Amazon's recruiting process is fundamentally flawed by having teams hire for themselves, so their hiring bar is incredibly inconsistent across teams, despite various efforts they've made to level it out. And their operations are a mess; they don't real

Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. From https://leetcode.com/problems/container-with-most-water/

Algorithm

The intuition behind this approach is that the area formed between the lines will always be limited by the height of the shorter line. Further, the farther the lines, the more will be the area obtained.

We take two pointers, one at the beginning and one at the end of the array constituting the length of the lines. Futher, we maintain a variable \text{maxarea}maxarea to store the maximum area obtained till now. At every step, we find out the area formed between them, update \text{maxarea}maxarea and move the pointer pointing to the shorter line towards the other end by one step.

@hackjutsu
hackjutsu / ClientDemo.java
Created May 23, 2019 04:40
[medium snippets] #medium #designPattern #StatePattern
public class ClientDemo {
public static void main(String[] args) {
MP3PlayerContext mp3Player = new MP3PlayerContext();
mp3Player.press();
mp3Player.getState();
mp3Player.press();
mp3Player.getState();
}
}
@hackjutsu
hackjutsu / PlayingState.java
Created May 23, 2019 04:38
[medium snippets] #medium #designPattern #StatePattern
public class PlayingState implements State {
public void pressPlay(MP3PlayerContext context) {
context.setState(new StandbyState());
}
@Override
public String getState() {
return "Playing...";
}
}
@hackjutsu
hackjutsu / State.java
Created May 23, 2019 04:37
[medium snippets] #medium #designPattern #StatePattern
public interface State {
void pressPlay(MP3PlayerContext context);
String getState();
}
@hackjutsu
hackjutsu / MP3PlayerContext.java
Created May 23, 2019 04:35
[medium snippets] #medium #designPattern #StatePattern
public class MP3PlayerContext {
private State state;
public MP3PlayerContext() {
this.state = new StandbyState();
}
public void press() {
state.pressPlay(this);
}
@hackjutsu
hackjutsu / StreetMap.java
Created May 20, 2019 06:45
[medium snippets] #medium #designPattern #BuilderPattern
public class StreetMap {
private final Point origin;
private final Point destination;
private final Color waterColor;
private final Color landColor;
private final Color highTrafficColor;
private final Color mediumTrafficColor;
private final Color lowTrafficColor;
public static class Builder {
@hackjutsu
hackjutsu / ProxyPatternDemo.java
Created May 20, 2019 06:21
[medium snippets] #medium #designPattern #ProxyPattern
public class ProxyPatternDemo {
public static void main(String[] args) {
Image image = new ProxyImage("test_10mb.jpg");
image.display();
System.out.println("");
image.display();
}
}
@hackjutsu
hackjutsu / ProxyImage.java
Created May 20, 2019 06:19
[medium snippets] #medium #designPattern #ProxyPattern
public class ProxyImage implements Image{
private RealImage realImage;
private String fileName;
public ProxyImage(String fileName){
this.fileName = fileName;
}
@Override
public void display() {
@hackjutsu
hackjutsu / RealImage.java
Created May 20, 2019 06:18
[medium snippets] #medium #designPattern #ProxyPattern
public class RealImage implements Image {
private String fileName;
public RealImage(String fileName){
this.fileName = fileName;
loadFromDisk(fileName);
}
@Override
public void display() {