Skip to content

Instantly share code, notes, and snippets.

View akshaynagpal's full-sized avatar
💭
I may be slow to respond.

Akshay Nagpal akshaynagpal

💭
I may be slow to respond.
View GitHub Profile
@akshaynagpal
akshaynagpal / trie101.py
Last active October 11, 2020 23:02
Trie implementation in Python 3 from scratch
class TrieNode:
def __init__(self):
self.children = {}
self.isEndOfWord = False
class Trie:
def __init__(self):
self.root = TrieNode()
def insertWord(self, word):

Keybase proof

I hereby claim:

  • I am akshaynagpal on github.
  • I am akshaynagpal (https://keybase.io/akshaynagpal) on keybase.
  • I have a public key ASBg4Y73DXZzaar-dqVmvb1YmueY1nutmKSNBZWxJJq3eQo

To claim this, I am signing this object:

@akshaynagpal
akshaynagpal / filter-gallery.js
Last active August 24, 2020 08:29
Filter Gallery using HTML5, JavaScript, JQuery & Bootstrap Demo: https://jsbin.com/jeyadac
@akshaynagpal
akshaynagpal / clearBitsIthrough0.java
Created July 15, 2016 12:29
clear n bits in a binary number from both sides
public static int clearBitsIthrough0(int num,int i){
System.out.println("clearing bits "+i+" to 0 of number:"+Integer.toBinaryString(num));
int mask = ~(0<<31); // mask with all bits set
mask = mask<<i+1; // mask with bits 0 to i cleared
System.out.println("using mask:"+Integer.toBinaryString(mask));
return num & mask;
}
@akshaynagpal
akshaynagpal / LinkedList.java
Last active November 5, 2022 09:16
Linked List From Scratch in Java
package src.LinkedList;
public class LinkedList {
public Node head;
public int listCount;
public LinkedList(){
head = new Node(0);
listCount = 0;
}
@akshaynagpal
akshaynagpal / index.html
Created June 29, 2015 06:29
Scatterplot
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<script src='//ramnathv.github.io/rCharts/libraries/widgets/polycharts/js/polychart2.standalone.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
@akshaynagpal
akshaynagpal / png_to_txt_binary.py
Created January 16, 2015 17:39
png_to_txt_binary
import PIL
from PIL import Image
"""
#resizing the image to 32 X 32 pixels
img = Image.open('one.png')
img = img.resize((32,32),PIL.Image.ANTIALIAS)
img.save('one_2.png')
"""
@akshaynagpal
akshaynagpal / string_reverse.py
Created December 10, 2014 12:50
Reverse a string in python without using reversed() or [::-1]
def reverse(test):
n = len(test)
x=""
for i in range(n-1,-1,-1):
x += test[i]
return x
@akshaynagpal
akshaynagpal / StackDemo.java
Created August 18, 2014 11:24
Using stack in java with collections framework
/*
* The StackDemo program gives user defined menu to carry different stack operations.
*
* @author Akshay Nagpal - https://www.twitter.com/akshay2626
* @since 2014-08-18
* @param x -Element inputted by the user.
* @param choice -Number chosen by the user from the menu according to which the appropriate operation is carried out.
*/
import java.util.*;