Skip to content

Instantly share code, notes, and snippets.

long sum = 0, max = Integer.MIN_VALUE, min = Integer.MAX_VALUE;
for(int num: nums) sum += num;
for(int num: nums){
max = Math.max(max, sum - num);
min = Math.min(min, sum - num);
}
// return max & min
return new int[]{max, min};
@rezaramadhanirianto
rezaramadhanirianto / System Design.md
Created August 13, 2022 18:20 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
Below are the Big O performance of common functions of different Java Collections.
List | Add | Remove | Get | Contains | Next | Data Structure
---------------------|------|--------|------|----------|------|---------------
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array
Big O complexities for common methods of Java Collections and common sorting algorithms.
Complexity (Best to Worst)
===================================================================================================
O(1) < O(log n) < O(n) < O(n log n) < O(n^2) < O(2^n) < O(n!)
Collections
===================================================================================================
syntax="proto3";
package output;
option go_package = "/output";
import "google/protobuf/empty.proto";
message OutputRequest{
string title = 1;
}
package main
import (
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"grpc/my-simple-grpc/output"
"time"
)
package main
import (
"context"
"fmt"
"google.golang.org/protobuf/types/known/emptypb"
"grpc/my-simple-grpc/output"
)
type OutputServiceServer struct {
package main
import (
"fmt"
"google.golang.org/grpc"
"grpc/my-simple-grpc/output"
"log"
"net"
)