Skip to content

Instantly share code, notes, and snippets.

View abhinavjonnada82's full-sized avatar

ABHINAV JONNADA abhinavjonnada82

  • Washington, DC
  • 16:49 (UTC -12:00)
View GitHub Profile
import React from 'react';
import './SearchBar.css';
constructor(props){
super(props);
this.handleTermChange.handleLocationChange.handleSearch = this.handleTermChange.handleLocationChange.handleSearch.bind(this);
}
const sortByOptions = {
"Best Match": "best_match",
@abhinavjonnada82
abhinavjonnada82 / The Technical Interview Cheat Sheet.md
Created November 24, 2018 18:12 — 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.
@abhinavjonnada82
abhinavjonnada82 / LinkedL.py
Last active September 27, 2019 04:12
Linked List - LeetCode
# cycle in a inked lists
def hasCycle(self, head: ListNode) -> bool:
first = head
second = head
while first and second and second.next: # Important takes care of edge cases
first = first.next
second = second.next.next
if first == second:
return True
return False
# Balance Parantheses
def isValid(string):
balLis = [i for i in string ]
stack = []
mapping = {")": "(", "}": "{", "]": "["} # Dictionary
for i in balLis:
if i == "(" or i == "[" or i == "{":
stack.append(i)
elif i ==")" or i == "]" or i == "}" and len(stack) > 0:
if stack[-1] == mapping[i]:
# containerMostWater
def containerMostWater(arr):
# O(N) runtime
# O(1) space
start = 0
end = len(arr)-1
maxDist = 0
if (len(arr) < 2):
return -1
while start < end:
# Finonacci
def getNthFib(n):
if n == 1:
return 0
if n == 2:
return 1
else:
return getNthFib(n-1) + getNthFib(n-2)
# Powerset
# Binary Search (Edge case: i/p: [1] o/p: [0,0])
class Solution:
def searchRange(nums, target):
left = searchLeft(nums, target, 0, len(nums)-1)
if left < 0:
return [-1, -1]
else:
right = searchRight(nums, target, left, len(nums)-1)
return [left, right]
# Need to work on this!
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
class BST:
def __init__(self):
self.root = None
# O(n) time | O(d) space
def invertBinaryTree(tree):
if tree is None:
return 0
(tree.left, tree.right) = (tree.right, tree.left)
if tree.left:
invertBinaryTree(tree.left)
if tree.right:
invertBinaryTree(tree.right)
# isPalindrome
# Runtime: O(N)
# Space: O(N)
def isPalindrome(strings):
mid = len(strings)//2
if len(strings) <= 1:
return False
if len(strings) % 2 == 0:
leftPtr = mid - 1