### Problem Statement

Find the*n*th digit of the infinite integer sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...

Note:

*n*is positive and will fit within the range of a 32-bit signed integer (*n*< 231).**Link to gitHub**:Code`num1`

and `num2`

represented as string, return the sum of `num1`

and `num2`

.
Note:

- The length of both
`num1`

and`num2`

is < 5100. - Both
`num1`

and`num2`

contains only digits`0-9`

. - Both
`num1`

and`num2`

does not contain any leading zero. - You must not use any built-in BigInteger library or convert the inputs to integer directly.

Given a non-empty integer array of size

In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data.

You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively.

The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were.

If the 'reshape' operation with given parameters is possible and legal, output the new reshaped matrix; Otherwise, output the original matrix.

`0, 1, 2, ..., n`

, find the one that is missing from the array.Problem Statement

Link to Github :Code

Find all the elements of [1, *n*] inclusive that do not appear in this array.

Could you do it without extra space and in O(*n*) runtime? You may assume the returned list does not count as extra space.

Given an array and a value, remove all instances of that value in place and return the new length.

Do not allocate extra space for another array, you must do this in place with constant memory.

The order of elements can be changed. It doesn't matter what you leave beyond the new length.

Link to GitHub** : Code**

Link to GitHub

Do not allocate extra space for another array, you must do this in place with constant memory.

For example,

Given input array*nums* =

Given input array

`[1,1,2]`

,
Your function should return length = *nums* being

`2`

, with the first two elements of `1`

and `2`

respectively. It doesn't matter what you leave beyond the new length.Basically we need to validate if we have near by duplicate

Link to Github :code

Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.

You may assume the integer do not contain any leading zero, except the number 0 itself.

The digits are stored such that the most significant digit is at the head of the list.

Link to GitHub :Code

Link to GitHub :Code

Example |

input = {1, 4, 9, 9}

output ={1, 5, 0, 0 } | |

Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). However, you may not engage in multiple transactions at the same time (ie, you must sell the stock before you buy again).

Space Complexity

1 2 3 4 5 6 7 8 9 10 11 12 13 | stocks=[7,1,5,2,4] def buy_sell_once(s): maxprofit=0 #first loop for i in range(len(s)-1): for j in range(i+1,len(s)): if s[j] - s[i] > maxprofit: maxprofit=s[j] - s[i] return maxprofit m=buy_sell_once(stocks) print(m) |

Space Complexity

1 2 3 4 5 6 7 8 9 10 11 12 | stocks =[7,1,5,2,4] def buy_sell_once_ef(s): max_profit=0 min_price=stocks[0] for price in range(len(stocks)-1): min_price = min(min_price,price) profit =(price-min_price) max_profit=max(profit,max_profit) return max_profit m=buy_sell_once(stocks) print(m) |

- We need a variable to store the maxProfit
- We need to iterate through the array and Get the difference between selling price and buying
**price maxprofit+=prices[i+1]-prices[i]** - We need to make sure that selling price is greater than buying price. This check can be done using if condition
**if(prices[i+1] >prices[i])**

public static int get(int [] prices) { int maxprofit=0; //loop through the array set . We need to keep on adding the profit //We need to buy and sell before buying others for(int i=0;i<prices.length-1;i++) { //We need to make sure that selling is greater than profit if(prices[i+1] >prices[i]) { maxprofit+=prices[i+1]-prices[i]; } } return maxprofit; }

Link to GitHub :Code

Say you have an array for which the *i*th element is the price of a given stock on day *i*.

If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock), design an algorithm to find the maximum profit.

**Link to GitHub** :Code

We can generate PDF in JavaScript using jsPDF library.

Edit in plkr

Steps involved

- Use CDN reference to jsPDF
- Open the document
- Pass the Json Object to the document
- Save the file

Input 12321 is a palindrome number Input 1231 is not a palindrome number

Link to GitHub :Code

There is no option to float center. However by thinking carefully about how elements behave, we can use positioning to achieve the same result

The values for the top and bottom could be anything and we would get the same result

we need to have to set width for the div. If not it would take the full width

Link to GitHub :Code

- Removes an element from the normal document flow.
- It then takes that element and pushes it to the far left as possible.
- Other element would flow far left as possible to floe around the element and takes its original space

.floatRight{ width:200px; height:200px; float:right; background-color: red; }

If we want to inherit css property from other classes we can have nested css classes

Link to Github :Code

Subscribe to:
Posts (Atom)

- Algorithms (52)
- Apache Kafka (7)
- Apache Spark (17)
- Architecture (6)
- Arrays (23)
- Big Data (72)
- Cloud services (5)
- Cognitive technologies (12)
- Data Analytics (2)
- Data Science (1)
- Design (1)
- devOps (1)
- Hadoop (25)
- Hive (10)
- Java (2)
- JavaScript (65)
- JavaScript Run-time (12)
- Machine learning (5)
- Maths (6)
- mongoDb (2)
- MySQL (1)
- Networking (3)
- No SQL (2)
- Node (20)
- Python (23)
- Security (4)
- Spark Grpahx (1)
- Spark MLlib (1)
- Spark Sql (3)
- Spark Streaming (4)
- SQL (26)
- Sqoop (2)
- ssis (3)
- Strings (13)