Skip to content

Instantly share code, notes, and snippets.

View athulmurali's full-sized avatar
🎯

Athul Muralidharan athulmurali

🎯
View GitHub Profile
@athulmurali
athulmurali / MinMaxHeap.py
Last active June 6, 2019 04:47
MinMaxHeap in Python
import heapq
class MaxInt(int):
def __init__(self,val):
self.val = val
def __lt__(self,other): return self.val > other.val
class heap:
def __init__(self, arr =[], num_type = int):
self.arr = arr
@athulmurali
athulmurali / meetingRooms2.py
Last active June 6, 2019 04:57
Meeting Rooms ||
# Definition for an interval.
# class Interval:
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution:
def minMeetingRooms(self, intervals: List[Interval]) -> int:
import heapq
heap = []
@athulmurali
athulmurali / ReduxFix.md
Last active June 6, 2019 20:56
ReduxFix.md

There are some issues in redux fundamentals here.

A store should be created once. Whenever, you select a topic , you will have to update the store but not re-create them. Move the createStore code accordingly.

Since you are using only one reducer, the following should be code to create a redux store. You were passing an object as a second argument which is a place for a redux middleware but not any other argument or parameter

@athulmurali
athulmurali / k_largest.py
Last active June 18, 2019 02:57
K largest and smallest elements in python
import heapq
def k_largest(arr,k):
h= []
heapq.heapify(h)
for i in arr:
heapq.heappush(h,i)
if len(h) > k :
heapq.heappop(h)
result = []
while h:
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
local_sum = 0
global_sum = -float("inf")
for i in nums:
local_sum = local_sum + i
if i >= local_sum:
local_sum = i
if local_sum > global_sum:
class Solution:
def nextPermutation(self, nums: List[int]) -> None:
n = len(nums)
prev = -float("inf")
ind = n -1
for i in range(n):
ind = n - i -1
if nums[ind] < prev:
j = n -1
while(nums[j] <= nums[ind] and j > ind) :
@athulmurali
athulmurali / Amazon_q.json
Last active July 11, 2019 22:56
Amazon_questions
{
"Amazon": [
[
"1",
"Two Sum",
"44.3%",
"Easy"
],
[
"2",
Practise:
1. Create a js based html with button
2. Click button to call flask api
3. Flask api sends response as stream
4. Request gets closed
-- Flask :
def merge_arr(a, b):
result = []
i = 0
j = 0
while i < len(a) or j < len(b):
if i < len(a) and ((j < len(b) and a[i] < b[j]) or j >= len(b)):
result.append(a[i])
i += 1
@athulmurali
athulmurali / README.md
Last active October 22, 2019 05:27
Spring boot common issues | Debug

Things to do:

  1. Update the schema name in DatabaseConnection.java

  2. Remove all duplicate code for creating connection in all DAOs first.

  3. Just use the getConnection method from DatabaseConnection.java At any instance, do not duplicate the connection strings or copy paste connection methods to stay away from trouble.

  4. Remove duplicate package tags in pom.xml