Skip to content

Instantly share code, notes, and snippets.

View rajeakshay's full-sized avatar

Akshay Raje rajeakshay

  • Bloomberg LP
  • Toronto, ON
  • 12:44 (UTC -05:00)
  • LinkedIn in/rajeakshay
View GitHub Profile
@rajeakshay
rajeakshay / vscode-neovim.md
Last active November 12, 2024 22:35
VSCode + NeoVim Quick Reference

VSCode + NeoVim

DISCLAIMER:
These are my notes for quick reference and not meant to be an exhaustive VSCode + NeoVim cheatsheet. Refer to VSCode, NeoVim and vscode-neovim documentation for the latest details.

Quick Setup

  1. Install NeoVim 0.10.0+ and VSCode.
  2. Install vscode-neovim plugin in VSCode.
  3. Enable system clipboard in NeoVim's init.lua -
    -- Set clipboard to global clipboard
@rajeakshay
rajeakshay / rust-book.md
Last active May 29, 2023 18:13
Notes from 'The Rust Programming Language' at https://rust-book.cs.brown.edu/

DISCLAIMER: These notes from 'The Rust Programming Language' book are my own and meant for my personal reference. They are not endorsed by the Rust Foundation. Visit https://www.rust-lang.org/ for the official material for learning Rust.

Installing Rust

  1. Install Rust from https://rustup.rs/.
  2. Check installation with -
    rustc --version
    
    OR
@rajeakshay
rajeakshay / PrintConflictingIntervals.java
Created September 23, 2016 05:27
In a calendar where multiple events can be scheduled over the same time window, print a list of all conflicting time windows along with the event IDs that are conflicting.
/**
* In a calendar where multiple events can be scheduled over the same time window, print a list of all
* conflicting time windows along with the event IDs that are conflicting. All times are in 24 hour format.
* Example:
* Input:
* Event 1 : 2014-01-01 9:45 - 2014-01-01 10:30
* Event 2 : 2014-01-01 10:00 - 2014-01-01 10:30
* Event 3 : 2014-01-01 10:20 - 2014-01-01 10:45
*
* Output:
@rajeakshay
rajeakshay / AllPathsFromASource.java
Created September 23, 2016 05:03
Print all paths from a given source to a destination - (http://www.geeksforgeeks.org/find-paths-given-source-destination/) Given a directed graph, a source vertex ‘s’ and a destination vertex ‘d’, print all paths from given ‘s’ to ‘d’.
/**
* Print all paths from a given source to a destination - (http://www.geeksforgeeks.org/find-paths-given-source-destination/)
* Given a directed graph, a source vertex ‘s’ and a destination vertex ‘d’, print all paths from given ‘s’ to ‘d’.
* */
import java.util.*;
public class AllPathsFromASource {
static class Graph{
int V;
Map<Integer, List<Integer>> adj; // Adjacency list
@rajeakshay
rajeakshay / AllOutcomesOfAnExpression.java
Last active September 10, 2024 08:19
Find all possible outcomes of a given expression - Given an arithmetic expression, find all possible outcomes of this expression. Different outcomes are evaluated by putting brackets at different places. There will be no spaces in the input. Only operators '+','-', and '*' are allowed. Numbers can have multiple digits. Example: Input: 1+3*2 Outp…
/**
* Find all possible outcomes of a given expression (http://www.geeksforgeeks.org/find-all-possible-outcomes-of-a-given-expression/)
* ================================================
* Given an arithmetic expression, find all possible outcomes of this expression. Different outcomes are evaluated by
* putting brackets at different places.
* NOTES:
* 1. There will be no spaces in the input.
* 2. Only operators '+','-', and '*' are allowed.
* 3. Numbers can have multiple digits.
*
@rajeakshay
rajeakshay / InsertInterval.java
Created September 18, 2016 12:06
LeetCode 57. Insert Interval - (Problem Link - https://leetcode.com/problems/insert-interval/) Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9], insert and merge [2…
/**
LeetCode 57. Insert Interval
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start times.
Example 1:
Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9].
Example 2:
Given [1,2],[3,5],[6,7],[8,10],[12,16], insert and merge [4,9] in as [1,2],[3,10],[12,16].
@rajeakshay
rajeakshay / SurroundedRegions.java
Last active September 18, 2016 12:14
LeetCode 130. Surrounded Regions - (Problem Link - https://leetcode.com/problems/surrounded-regions/) Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded region. For example, [X X X X, X O O X, X X O X, X O X X] After running your fu…
/**
LeetCode 130. Surrounded Regions
Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
For example,
X X X X
X O O X
X X O X
X O X X
@rajeakshay
rajeakshay / NumberOfIslands.java
Last active September 18, 2016 12:14
LeetCode 200. Number of Islands - (Problem Link: https://leetcode.com/problems/number-of-islands/) Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded b…
/**
*
LeetCode 200. Number of Islands
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands.
An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
You may assume all four edges of the grid are all surrounded by water.
Example 1:
11110
11010
11000
@rajeakshay
rajeakshay / DecodeString.java
Last active October 9, 2018 02:13
LeetCode 394. Decode String - (Problem Link - https://leetcode.com/contest/3/problems/decode-string/) Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assu…
/**
* LeetCode 394. Decode String - (Problem Link - https://leetcode.com/contest/3/problems/decode-string/)
*
* Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded_string
* inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.
* You may assume that the input string is always valid; No extra white spaces, square brackets are well-formed, etc.
* Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat
* numbers, k. For example, there won't be input like 3a or 2[4].
*
* Examples:
@rajeakshay
rajeakshay / BillPughSingleton.java
Created August 8, 2016 23:06
Two primary approaches of implementing a Singleton class in Java.
/**
*
* Thread-safe singleton with lazy initialization. (Bill Pugh's approach)
*
* NOTES -
* When BillPughSingleton class is loaded, SingletonHelper class is not loaded into memory. Only when someone calls
* getInstance() method, does the SingletonHelper class gets loaded and creates a BillPughSingleton instance.
*
* The advantage comes from the lazy initialization. BillPughSingleton instance, which might be potentially consuming
* very high memory, will only be created when getInstance is called the first time.