Skip to content

Instantly share code, notes, and snippets.

@KodeSeeker
KodeSeeker / QuickSelect.java
Created January 6, 2019 19:29 — forked from unnikked/QuickSelect.java
A basic implementation of quickselect algorithm in Java. Intentionally unused generics.
import java.util.Arrays;
/**
* quickselect is a selection algorithm to find the kth smallest element in an
* unordered list. Like quicksort, it is efficient in practice and has good
* average-case performance, but has poor worst-case performance. Quickselect
* and variants is the selection algorithm most often used in efficient
* real-world implementations.
*
* Quickselect uses the same overall approach as quicksort, choosing one
@KodeSeeker
KodeSeeker / The Technical Interview Cheat Sheet.md
Last active June 28, 2018 06:44 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
public class SpiralMatrix {
enum Direction {
LEFT_RIGHT, TOP_DOWN, RIGHT_LEFT, BOTTOM_UP
};
public static void traverseMatrixInSpiral(char[][] matrix, int initialRow,
int finalRow, int initialColumn, int finalColumn, int totalElems,
int visited, Direction direction) {
System.out.println("Num Elems: " + totalElems + " visited: " + visited);
public static int MaxSubsetSum(int[] nums)
{
//we need define two key variables before loop
//firstly we need a temp sum to keep track of the sum of numbers we processed so far
//also we need a maxSum to keep track of the currently max sum so far for return purpose
int tempSum = 0;
int maxSum = 0;
//we define the following three index variables to keep track of the sum's start and end indexes.
int tempSumStartIndex = 0;