Doubly Linked List | Python

Implementation of Doubly Linked List in Python class DoublyLinkedList(object): def __init__(self,val): self.value = val self.next_node = None self.prev_node = None a = DoublyLinkedList(1) b = DoublyLinkedList(2) c = DoublyLinkedList(3) a.next_node = b b.prev_node = a b.next_node = c c.prev_node = b

Advertisements

Singly Linked Lists | Python

Implementation of singly linked lists in Python. class Node(object): def __init__(self,val): self.value = val self.nextNode = Node a = Node(1) b = Node(2) c = Node(3) a.nextNode = b b.nextNode = c print a.nextNode.value

Array Pair Sum | Python

Problem Given an integer array, output all the unique pairs that sum up to a specific value k. So the input: pair_sum([1,3,2,2],4) would return 2 pairs: (1,3) (2,2) Solution def get_unique_pair(list_of_elems,k): if len(list_of_elems) < 2: print "Please increase data" else: seen = set() output = set() for num in list_of_elems: target = k - num … Continue reading Array Pair Sum | Python

Anagram problem | Python

Solution for Anagram problem in Python. #Anagram problem # input1 = 'public relations' # output1 = 'crap built on lies' input = 'client eastwood' output = 'old west action' def check_for_anagram(input1,output1): """ checks for Anagram """ input1 = input1.lower() output1 = output1.lower() len_of_input1 = len(input1) len_of_output1 = len(output1) input_1_dict = {} output_1_dict = {} if … Continue reading Anagram problem | Python

Create Pycharm Launcher in Ubuntu

Quick way to create Pycharm launcher.  Start Pycharm using the ./pycharm.sh file located under bin folder. Once the Pycharm application loads, navigate to tools menu and select "Create Desktop Entry.." This type of window will open up.  Check the box if you want the launcher for all users. If you Check the box i.e "Create … Continue reading Create Pycharm Launcher in Ubuntu

Fetch upcoming 10 events of user using google calendar API in Python

  * Python command-line application that makes requests to the Google Calendar API to fetch upcoming 10 events. The entire feature can be achieve in three steps. Setting up Google Calendar API. Installing google client library. Creating python script. Let's Get Started : Setting up Google Calendar API. Go to google console. Create or select … Continue reading Fetch upcoming 10 events of user using google calendar API in Python