This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>LOLCAT CLOCK</title> | |
<link href="https://fonts.googleapis.com/css?family=Bungee|Bungee+Shade|Covered+By+Your+Grace" rel="stylesheet"> | |
<link href="https://fonts.googleapis.com/css?family=Open+Sans:800" rel="stylesheet"> | |
<link rel="stylesheet" type="text/css" href="style.css"> | |
</head> | |
<body> | |
<div class="page"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python | |
import math | |
import os | |
import random | |
import re | |
import sys | |
# | |
# Complete the 'getWays' function below. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python3 | |
#code contributed by kirti purohit. | |
#time complexity O(n) | |
#which is much more efficient than the naive algorithm having a time complexity of O(2**n) | |
def fib(n,memo): | |
result=0 | |
if memo[n] is not None: | |
return memo[n] | |
if n==1 or n==2: | |
result=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python3 | |
# https://www.hackerrank.com/challenges/quicksort1/problem | |
def quickSort(arr): | |
p=arr[0] | |
left=[] | |
right=[] | |
equal=[] | |
for i in range(1,n): | |
if arr[i]>p: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
class Solution { | |
public: | |
ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { | |
// Start typing your C/C++ solution below | |
// DO NOT write int main() function | |
if(l1==NULL) return l2; | |
if(l2==NULL) return l1; | |
ListNode *p1=l1; | |
ListNode *p2=l2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python3 | |
#https://en.wikipedia.org/wiki/Dutch_national_flag_problem | |
#https://leetcode.com/problems/sort-colors/ | |
def sortColors(self, nums): | |
red, white, blue = 0, 0, len(nums)-1 | |
while white <= blue: | |
if nums[white] == 0: | |
nums[red], nums[white] = nums[white], nums[red] | |
white += 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PROBLEM STATEMENT- You have a cicle of radius 1 embedded in the square . There are some random points everywhere ,some inside the circle | |
and some outside which contribute to the points in square | |
**************DISPLAY IS PROVIDED BELOW IN THE COMMENT SECTION******** | |
ALGORITHM- 1. Generate some random numbers between 0 and 1 | |
2. check the distance of the point from the origin | |
3. if x**2 + y**2 =distance <1 then the point lies inside the circle | |
4. Increment nums_points_circle | |
5. Increment nums_total_points . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python3 | |
class Solution: | |
def multiply(self, num1: str, num2: str) -> str: | |
def mul(num1, num2): | |
if len(num1) == 1 or len(num2) == 1: | |
return int(num1) * int(num2) | |
m = min(len(num1), len(num2)) // 2 | |
a, b = num1[:len(num1) - m], num1[len(num1) - m:] | |
c, d = num2[:len(num2) - m], num2[len(num2) - m:] | |
z0 = mul(b, d) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This problem has typically 3-4 approaches .I'm gonna show two of them here . | |
1. DYANAMIC PROGRAMMING APPROACH . | |
```python3 | |
class Solution: | |
def climbStairs(self, n: int) -> int: | |
if n==0: | |
return 0 | |
if n==1: | |
return 1 | |
dp=[0]*(n+1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```python3 | |
import sys | |
import math | |
from functools import reduce | |
# Auto-generated code below aims at helping you parse | |
# the standard input according to the problem statement. | |
n = int(input()) | |
if n==0: | |
print(0) |
OlderNewer