Skip to content

Instantly share code, notes, and snippets.

View srsandy's full-sized avatar
👨‍💻
Learning everyday.

Sandeep「 Flame 」 srsandy

👨‍💻
Learning everyday.
View GitHub Profile
@srsandy
srsandy / terminal-git-branch-name.md
Created August 10, 2019 05:25 — forked from joseluisq/terminal-git-branch-name.md
Add Git Branch Name to Terminal Prompt (Mac)

Add Git Branch Name to Terminal Prompt (Mac)

image

Open ~/.bash_profile in your favorite editor and add the following content to the bottom.

# Git branch in prompt.

parse_git_branch() {
@srsandy
srsandy / DataStructureOperationsComplexity.md
Created August 6, 2019 07:17
Data Structure Operations Complexity

Data Structure Operations Complexity

Data Structure Access Search Insertion Deletion Comments
Array 1 n n n
Stack n n 1 1
Queue n n 1 1
Linked List n n 1 n
Hash Table - n n n In case of perfect hash function costs would be O(1)
Binary Search Tree n n n n In case of balanced tree costs would be O(log(n))
@srsandy
srsandy / ArraySortingAlgorithmsComplexity.md
Created August 6, 2019 07:16
Array Sorting Algorithms Complexity

Array Sorting Algorithms Complexity

Name Best Average Worst Memory Stable Comments
Bubble sort n n2 n2 1 Yes
Insertion sort n n2 n2 1 Yes
Selection sort n2 n2 n2 1 No
Heap sort n log(n) n log(n) n log(n) 1 No
Merge sort n log(n) n log(n) n log(n) n Yes
Quick sort n log(n) n log(n) n2 log(n) No Quick
@srsandy
srsandy / AboutMe.png
Last active April 30, 2020 20:27
Sandeep Ranjan 👨🏻‍💻
AboutMe.png
@srsandy
srsandy / ImpJavaFunctions.md
Last active March 13, 2021 07:54
Java Methods for Interviews

Methods that can help you code quicker and better.

String/Array

toCharArray() //get char array of a String

charAt(int x) //get a char at the specific index

length() //string length
@srsandy
srsandy / BigNumberAdd.java
Last active March 19, 2020 13:07
Adding big numbers using Strings in java
public String Add(String input1, String input2) {
String ans = "";
int len1 = input1.length();
int len2 = input2.length();
if(len1 < len2){
String temp = input1;
input1 = input2;
input2 = temp;
}
@srsandy
srsandy / sharedMemoryArray.c
Last active January 22, 2024 00:52
Store an Array in shared memory c
// write.c
#include<stdio.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>
int main(int argc, char const *argv[]) {
int key = ftok(".", 34);
int *arr;
@srsandy
srsandy / ie67891011-css-hacks.txt
Created October 12, 2018 12:33 — forked from vidaaudrey/ie67891011-css-hacks.txt
IE CSS hacks - IE6, 7, 8, 9, 10, 11
IE6 Only
==================
_selector {...}
IE6 & IE7
==================
*html or { _property: }
IE7 Only
==================
@srsandy
srsandy / JavaScript Notes.md
Last active July 10, 2020 12:58
JavaScript Notes

Javascript Notes

var, let & const

  • var provides functional scoping but not block scoping. var allow to log the variable without declaring it though it shows undefined.
  • let provides functional scoping as well as block scoping.
  • const provies functional scoping as well as block scoping but you cannot reassign value to a const type variable.

let and const will not allow you the log the variable without declaring it.

| Keyword | Scope | Hoisting|Can Be Reassigned|Can Be Redeclared

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).