Xtensor & Xtensor-blas Library - Numpy for C++
Intro - What & Why?
I am currently working on my own deep learning & optimization library in C++, for my research in Data Science and Analytics Course at Maynooth University, Ireland. While searching for an existing tensor library (eigen/armadillo/trilinos - do not support tensors). I discovered Xtensor and Xtensor-blas, which has syntax...
Saturday, 19 August 2017
Data Science & Machine Learning - 6.3 Matplotlib Subplots & Other Features
Hi friends,
Welcome to another post on Python's Matplotlib library under Data Science & Machine Learning. In the previous post, we discussed basic ways to draw plots using Matplotlib. In this post, we'll see how to draw subplots using the Matplotlib library.
Note: All the commands discussed...
Thursday, 17 August 2017
Data Science & Machine Learning - 6.2 Matplotlib Basic Plots
Hi friends,
Welcome to another post on Matplotlib under Data Science & Machine Learning. In the previous post, we discussed the installation process of Matplotlib. In this we will see the basic plots supported by Matplotlib.
Note: All the commands discussed below are run in the Jupyter Notebook...
Sunday, 13 August 2017
101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
Approach : Use the simple recursive solution.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
...
104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Height of empty binary tree is 0 and with just root node is 1.
1
/ \
2 3
\
...
Saturday, 12 August 2017
83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, return 1->2->3.
Approach : The key to solve the problem is using the right loop condition and maintaining necessary pointers in each loop.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**
...
100. Same Tree
Given two binary trees, write a function to check if they are equal or not.
Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
Below are some examples:
Ex. 1:Tree 1: 10 20 ...
Friday, 11 August 2017
70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Approach : The standard recursive solution times out so the idea is to use the iterative solution to find the nth fibonacci number.
int climbStairs(int n) {
...
69. Sqrt(x)
Implement int sqrt(int x).
Return the floor if x is not a perfect square.
Approach : Using binary search making sure that overflow does not happen by taking long long.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Solution {
public:
int mySqrt(int x) {
if(x <= 1){
return x;
}
int low = 0, high = x / 2;
//long to prevent...
Tuesday, 8 August 2017
38. Count and Say
Problem: The count-and-say sequence is the sequence of integers with the first five terms as following:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 is read off as "one 1" or 11.
11 is read off as "two 1s" or 21.
21 is read off as "one 2, then one 1" or 1211.
Given an integer n, generate the nth term...
Sunday, 6 August 2017
67. Add Binary
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100"
Approach : The idea is to start from the right and keep adding digits and forwarding carry (if any). Also, take care of the case when one of them gets exhausted. For that, keep adding zero to the other one and forward carry if required.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
string...
Thursday, 3 August 2017
Data Science & Machine Learning - 6.1 Matplotlib & Its Installation

Hi friends,
Welcome to this post on Data Visualization under Data Science & Machine Learning. In the previous post, we performed some practical data analysis using Pandas on the Kaggle SF Salaries Dataset. In this post, we'll learn about Matplotlib, one of the most popular Python libraries...