Skip to content

Instantly share code, notes, and snippets.

@svraghavan
svraghavan / LongestSubstringKDistinct.java
Created June 12, 2020 16:02 — forked from Schachte/LongestSubstringKDistinct.java
Sliding Window Maximum Sum Subarray
import java.util.*;
class LongestSubstringKDistinct {
public static int findLength(String str, int k) {
int windowStart = 0, maxLength = 0;
Map<Character, Integer> charFrequencyMap = new HashMap<>();
for (int windowEnd = 0; windowEnd < str.length(); windowEnd++) {
char rightChar = str.charAt(windowEnd);
charFrequencyMap.put(rightChar, charFrequencyMap.getOrDefault(rightChar, 0) + 1);
@svraghavan
svraghavan / QuickSort.java
Created June 11, 2020 05:09 — forked from eloipereira/QuickSort.java
Functional Style QuickSort using Java 8 and Streams
import java.util.stream.*;
import java.util.*;
/*
An attempt to implement quickSort using Java 8 as close as possible to
the elegant Haskell implementation:
quicksort [] = []
quicksort (x:xs) =
let smallerSorted = quicksort [a | a <- xs, a <= x]
cmake_minimum_required(VERSION 3.15)
project(LearnCpp)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z -Wall -Wextra -Werror -pedantic-errors -Wconversion -Wsign-conversion")
add_executable(LearnCpp bitstring.cpp)
#include <iostream>
#include <vector>
using namespace std;
vector<string> store;
void getStrings( string s, int digitsLeft )
{
if( digitsLeft == 0 )
@svraghavan
svraghavan / tmux-cheatsheet.markdown
Created May 14, 2019 21:29 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@svraghavan
svraghavan / README.md
Created April 13, 2019 00:17 — forked from magnetikonline/README.md
Bash string manipulation cheatsheet.

Bash string manipulation cheatsheet

Assignment
Assign value to variable if variable is not already set. Value will be returned.

Couple with : no-op if return value is to be discarded.
${variable="value"}
: ${variable="value"}
@svraghavan
svraghavan / free_courses.csv
Created October 27, 2018 17:15
190 universities just launched 600 free online courses. Here’s the full list. - https://qz.com/1437623/600-free-online-courses-you-can-take-from-universities-worldwide/
Category Title URL
Programming CS50’s Introduction to Game Development from Harvard University https://www.class-central.com/course/edx-cs50-s-introduction-to-game-development-11504
Programming CS50’s Mobile App Development with React Native from Harvard University https://www.class-central.com/course/edx-cs50-s-mobile-app-development-with-react-native-11505
Programming CS50’s Web Programming with Python and JavaScript from Harvard University https://www.class-central.com/course/edx-cs50-s-web-programming-with-python-and-javascript-11506
Programming Functions, Methods, and Interfaces in Go from University of California, Irvine https://www.class-central.com/course/coursera-functions-methods-and-interfaces-in-go-12050
Programming Concurrency in Go from University of California, Irvine https://www.class-central.com/course/coursera-concurrency-in-go-12047
Programming Getting Started with Go from University of California, Irvine https://www.class-central.com/course/coursera-getting-started-with-go-1204
@svraghavan
svraghavan / gist:d8e6741fe1aff75ccecfb55378a321da
Created October 18, 2018 02:05 — 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
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
public class Tree {
private int value;