Skip to content

Instantly share code, notes, and snippets.

@smackia
smackia / code.cpp
Last active October 21, 2021 12:08
Pepcoding21/10/2021 MergeKsortedLists
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, pair<int, int> > ppi;
vector<int>mergeKSortedLists(vector<vector<int>>&lists) {
vector<int> rv;
priority_queue<ppi, vector<ppi>, greater<ppi> > pq;
@smackia
smackia / code.cpp
Last active October 21, 2021 12:08
Pepcoding21/10/2021 WritePriorityQueueUsingHeap
#include<bits/stdc++.h>
using namespace std;
vector<int> data;
int _size() {
return data.size();
}
void upheapify(int i) {
@smackia
smackia / FAQ
Created October 26, 2021 11:30
All Indices In An Array
Ques 1: Why we are taking fsf variable in the solution code?
Ans 1: We are taking fsf variable to count the number of times the data present in the array.
Ques 2: Why we are updating fsf when we are finding the data in the array ?
Ans 2: Beacuse when the base case hit we will form a new array of size fsf which will store the index .
Ques 3: Why we are not filling the array while going up on the stack ?
Ans 3: Beacuse initially we did't know how many same elements are present in the array so we can't create new array for storing the index of the element.So when we are going up we are counting the number of elements and when we are coming down we are storing the index in the array .
@smackia
smackia / FAQ
Created October 26, 2021 13:30
Write Hashmap
Ques 1: What is hash function ?
Ans: A "hash function", takes the key as the input and gives us the index of the bucket of the array at which that key is stored.
Ques 2: Why we write rehashing function ?
Ans : We write rehash() function to renews the array "buckets" with a length twice of the original array.
Ques 3: What are lamda function ?
Ans 3: A lambda expression is one or more line of code which works like function or method. It takes a parameter and returns the value. Lambda expression can be used to convert ArrayList to HashMap
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
box-sizing: border-box;
@smackia
smackia / Partical_Task_7.html
Created November 8, 2021 08:24
DOM Practical Series.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<style>
.pink {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
p {
font-size: 1.5rem;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
* {
box-sizing: border-box;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
#pass {
display: block;