Skip to content

Instantly share code, notes, and snippets.

View sharunkumar's full-sized avatar
💻
Working on new projects

Sharun sharunkumar

💻
Working on new projects
View GitHub Profile
@sharunkumar
sharunkumar / BuggyMouse.ahk
Last active June 15, 2023 20:42
Buggy Mouse Autohotkey Script
; Source: https://superuser.com/questions/207731/configure-debounce-time-in-windows-for-mouse
/*
** Buggy-Mouse.ahk - Fix a buggy mouse. Stop it from double-clicking when you try to single-click.
**
** NOTE: Please use this URL when linking to Buggy Mouse: r.secsrv.net/AutoHotkey/Scripts/Buggy-Mouse
**
** Updated: Thu, Nov 1, 2012 --- 11/1/12, 10:19:19am EDT
** Location: r.secsrv.net/AutoHotkey/Scripts/Buggy-Mouse
**
@sharunkumar
sharunkumar / .bashrc
Last active July 18, 2023 21:31
configurations for my WSL setup
bind TAB:menu-complete
bind "\C-H":shell-backward-kill-word
bind "\e[3;5~":shell-kill-word
@sharunkumar
sharunkumar / Convert-PdfToGif.ps1
Created April 25, 2023 19:18
Convert PDF to GIF
function Convert-PdfToGif($pdfpath) {
$pdf = Get-Item $pdfpath
$name = $pdf.BaseName
pdftoppm -png "$($pdf.FullName)" $name
$pngs = Get-ChildItem "$name-*.png"
$num = [math]::Ceiling([math]::Log10($pngs.Length + 1))
@sharunkumar
sharunkumar / 01Matrix.java
Last active April 5, 2023 18:59
DFS and BFS
// BFS
class Node {
int row;
int col;
int step;
Node(int row, int col, int step) {
this.row = row;
this.col = col;
this.step = step;
class Solution {
public List<List<String>> groupAnagrams(String[] strs) {
if (strs.length == 0) return new ArrayList();
Map<String, List> ans = new HashMap<String, List>();
for (String s : strs) {
char[] ca = s.toCharArray();
Arrays.sort(ca);
String key = String.valueOf(ca);
if (!ans.containsKey(key)) ans.put(key, new ArrayList());
ans.get(key).add(s);
@sharunkumar
sharunkumar / product_except_self.py
Last active March 27, 2023 22:19
238. Product of Array Except Self
# https://leetcode.com/problems/product-of-array-except-self/description/
# Runtime 219 ms Beats 96.61% Memory 21.1 MB Beats 95.12%
class Solution:
def productExceptSelf(self, nums: List[int]) -> List[int]:
zeroes = set()
prod = 1
for i, x in enumerate(nums):
@sharunkumar
sharunkumar / BSTIterator.java
Last active March 22, 2023 19:27
Binary Search Trees
class BSTIterator {
Stack<TreeNode> stack;
public BSTIterator(TreeNode root) {
this.stack = new Stack<TreeNode>();
this._leftmostInorder(root);
}
private void _leftmostInorder(TreeNode root) {
@sharunkumar
sharunkumar / IsomorphicStrings.java
Last active March 15, 2023 19:01
String Programs
// Java program to check if two strings
// areIsomorphic
import java.io.*;
import java.util.*;
class GFG {
static boolean areIsomorphic(String str1, String str2)
{
// https://www.geeksforgeeks.org/lexicographically-smallest-string-possible-by-using-given-operations/
// Given a string S consisting of digits from 0 to 9 inclusive, the task is to form the lexicographically
// smallest string by performing an operation any number of times. In one operation you can choose any
// position i and delete the digit d at s[i] and insert min(d+1, 9) on any position (at the beginning,
// at the end, or in between any two adjacent digits).
import java.io.*;
import java.util.*;
import java.util.PriorityQueue;
@sharunkumar
sharunkumar / SyncKeybindings.ps1
Created February 28, 2023 12:00
PowerShell script to copy the main keybindings to every profile in VSCode
cd $env:APPDATA\Code\User
Get-ChildItem .\profiles\ | % { copy .\keybindings.json "$_\keybindings.json" }