Monthly Archives: September 2018

$ is synonym for JQuery

$ is synonym for JQuery.You can use $(‘p’) or jQuery(‘p’) alternatively. Advertisements

Posted in Uncategorized | Leave a comment

Add 2 Binary Strings using Java

class Solution { public String addBinary(String a, String b) { int c=Integer.parseInt(a, 2) + Integer.parseInt(b, 2) ; return Integer.toBinaryString(c); } }

Posted in Java, LeetCode Solutions, Uncategorized | Leave a comment

Using default dictionary

”’ Created on Sep 22, 2018 @author: asharda ”’ from collections import defaultdict sentence=”Cats hate dogs and dogs hate CATS” word_dic=defaultdict(int) for word in sentence.split(): word_dic[word]+=1 print(word_dic)

Posted in Python, Uncategorized | Leave a comment

Using named tuple Python

”’ Created on Sep 21, 2018 @author: asharda ”’ from collections import namedtuple vector=namedtuple(‘Dimensions’,’x y z’) vec_1=vector(1,1,1) vec_2=vector(2,2,2) tot=vec_1.x+vec_2.x print(“Total seen is”,tot)

Posted in Python, Uncategorized | Leave a comment

Calculate Length of Hypotenuse of Right Angle Triangle

package test5; public class RightTriangle { public static void main(String[] args) { double c; double a=4,b=3; c=Math.sqrt(a*a+b*b); System.out.println(“Length of the hypotenuse is “+c); } }

Posted in Java | Leave a comment

excellent recursion video

Posted in Uncategorized | Leave a comment

Stacks and Queue in Python

a_stack.append(1) a_stack.append(2) a_stack.append(3) print(a_stack.pop()) a_queue=[] a_queue.append(1) a_queue.append(2) print(a_queue.pop(0))

Posted in Uncategorized | Leave a comment