Skip to content

Instantly share code, notes, and snippets.

View prashant4224's full-sized avatar
🏠
Working From Home

Prashant Jeerankalagi prashant4224

🏠
Working From Home
View GitHub Profile
// We can use stl container list as a double
// ended queue to store the cache keys, with
// the descending time of reference from front
// to back and a set container to check presence
// of a key. But to fetch the address of the key
// in the list using find(), it takes O(N) time.
// This can be optimized by storing a reference
// (iterator) to each key in a hash map.
#include <bits/stdc++.h>
using namespace std;
@prashant4224
prashant4224 / gist:02d690bfa9b681f4e9947f2dee0d7e41
Created March 14, 2021 17:58 — forked from psayre23/gist:c30a821239f4818b0709
Runtime Complexity of Java Collections
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
@prashant4224
prashant4224 / Version.java
Created July 6, 2020 10:45 — forked from brianguertin/Version.java
Simple SemVer version parsing and comparison in Java
public class Version implements Comparable<Version> {
@NonNull
public final int[] numbers;
public Version(@NonNull String version) {
final String split[] = version.split("\\-")[0].split("\\.");
numbers = new int[split.length];
for (int i = 0; i < split.length; i++) {
numbers[i] = Integer.valueOf(split[i]);
}
@prashant4224
prashant4224 / Jenkinsfile
Created June 24, 2020 09:34 — forked from mskutin/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@prashant4224
prashant4224 / Jenkinsfile
Created June 24, 2020 09:32
jenkinsfile and sonarqube
node {
echo "======================================="
echo "JENKINS_HOME = ${env.JENKINS_HOME}"
echo "JOB_NAME = ${env.JOB_NAME}"
echo "REPO_GIT = " + REPO_GIT
echo "DEFAULT_GIT_BRANCH = "+ DEFAULT_GIT_BRANCH
echo "SONAR_SERVER = "+ SONAR_SERVER
echo "======================================="
def sonarInstance=hudson.plugins.sonar.SonarInstallation.get(SONAR_SERVER).name;