Skip to content

Instantly share code, notes, and snippets.

View revanthpobala's full-sized avatar

Revanth revanthpobala

  • Express Scripts
  • United States
View GitHub Profile
@revanthpobala
revanthpobala / docker-compose.yml
Created July 28, 2017 01:40
Docker images to setup the selenium grid
version: '2'
services:
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox
volumes:
"""
Given a target, find the list of numbers that sum to the target
"""
def targetSum(a,k):
s={0:[]}
res = []
for x in a:
ns=dict(s)
for j in s:
if j+x == k:
@revanthpobala
revanthpobala / deepcopy_linked_list_using_python.py
Last active March 25, 2017 05:37
Clone a new linked that has random pointers
"""
Deep copy linked list with random pointers
"""
class Node():
def __init__(self,val):
self.val = val;
self.random = None
self.next = None
def morris_tree_traversal(root):
current = root
result = []
while current is not None:
if current.left is None:
result.append(current.val)
current = current.right
else:
pre = current.left
while(pre.right is not None and pre.right is not current):
"""
Dynamic Programming | Set 27 (Maximum sum rectangle in a 2D matrix)
http://www.geeksforgeeks.org/dynamic-programming-set-27-max-sum-rectangle-in-a-2d-matrix/
The idea is that to rotate the matrix and use kadane's maxSumArray and
add the lists one by one to get the maximum sum of the matrix
"""
import sys
def maxSumSubArray(arr):
@revanthpobala
revanthpobala / encrypt_folder.py
Created August 13, 2016 20:47
Encrypt a Folder
from hashlib import md5
from Crypto.Cipher import AES
from Crypto import Random
import base64
import os
def derive_key_and_iv(password, salt, key_length, iv_length):
d = d_i = ''
while len(d) < key_length + iv_length: