Skip to content

Instantly share code, notes, and snippets.

View Irene-123's full-sized avatar
🎯
Focusing

kirti purohit Irene-123

🎯
Focusing
View GitHub Profile
@Irene-123
Irene-123 / index.html
Created January 9, 2020 11:50
Practice JS LOL Cat Clock
<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">
@Irene-123
Irene-123 / coin_change.py
Created May 25, 2020 03:14
The coin change problem
```python
import math
import os
import random
import re
import sys
#
# Complete the 'getWays' function below.
#
@Irene-123
Irene-123 / fibbonacci.py
Created May 25, 2020 05:49
Efficient algorithm for computing nth fibbonacci number
```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
```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:
@Irene-123
Irene-123 / merge_two_sorted_list.cpp
Created June 14, 2020 05:23
Merge two sorted Lists
```
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;
@Irene-123
Irene-123 / Dutch_flag_prblm_on_leetcode.py
Created June 21, 2020 07:13
Leetcode solution-Sort Colors .Dutch National Flag problem
```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
@Irene-123
Irene-123 / estimate_pi.py
Last active January 20, 2021 07:33
Monte Carlo Estimation of Pi in python
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 .
```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)
@Irene-123
Irene-123 / Climbing_stairs.py
Created June 24, 2020 08:45
70. Climbing Stairs Leetcode Python solution
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)
@Irene-123
Irene-123 / temperatures.py
Created June 25, 2020 04:58
CodinGame Temperatures Puzzle
```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)