Skip to content

Instantly share code, notes, and snippets.

View hawaijar's full-sized avatar
🎯
Focusing

Mayengbam Sushil K hawaijar

🎯
Focusing
View GitHub Profile
@hawaijar
hawaijar / index.ts
Created August 15, 2022 07:08
BST construction
class BST {
value: number;
left: BST | null;
right: BST | null;
constructor(value: number) {
this.value = value;
this.left = null;
this.right = null;
}
@hawaijar
hawaijar / index.ts
Created August 13, 2022 00:36
Minimum Window Matching
// classic example of "Sliding Window" Technique
// Please refer to this video explanation: https://www.youtube.com/watch?v=U1q16AFcjKs
(() => {
function smallestSubstringContaining(bigString: string, smallString: string) {
// create a hash out of smallString
const hash: { [key: string]: number } = {};
for (let char of smallString) {
hash[char] = (hash[char] || 0) + 1;
}
let [left, right] = [0, 0];
@hawaijar
hawaijar / docker-compose.yml
Created June 8, 2022 17:28
mongo and mongo-express
# docker-compose.yml
version: "3.8"
services:
mongo:
image: mongo:5.0
container_name: mongo
environment:
- MONGO_INITDB_ROOT_USERNAME=root
- MONGO_INITDB_ROOT_PASSWORD=password
restart: unless-stopped
import UIKit
import XCTest
struct LoggedInUser {
let name: String
}
class LoginViewController: UIViewController {
var login: (((LoggedInUser) -> Void) -> Void)?
var user: String?
#import "Movie.h"
@implementation Movie
- (void)setName:(NSString *)movieName {
name = movieName;
}
- (void)setYear:(NSInteger)releaseYear {
year = releaseYear;
}
NS_ASSUME_NONNULL_BEGIN
@interface Movie : NSObject {
NSString* name;
NSInteger year;
NSInteger rating;
}
- (void)setName:(NSString*) movieName;
- (void)setYear:(NSInteger) releaseYear;
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
BOOL isRaining = true;
if(isRaining) {
printf("Get Umbrellla");
}
else {
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
char charData = 'A';
printf("\nSize of variable charData is %lu byte", sizeof(charData));
int intData = 100;
printf("\nSize of variable intData is %lu bytes", sizeof(intData));
short shortIntData = 20;
printf("\nSize of variable shortIntData is %lu bytes", sizeof(shortIntData));
@hawaijar
hawaijar / stringMatcher.js
Created October 3, 2021 01:51
Smallest substring containing a sequece of characters.
// point 1: Create a hash to capture the characteristics of the 'smallString' - what are the chars and count of its char
// Use two pointers (left & right - initially pointing to the start of 'bigString' ) and start scanning from left to right
/**
*
* @param h1 (bigger string)
* @param h2 (smaller string)
* @return {boolean}
*/
function hashesMatching(h1, h2) {
@hawaijar
hawaijar / lruII.js
Created May 13, 2021 14:49
LRU implementation using hash and list
const Node = function (key, value) {
this.key = key;
this.value = value;
this.next = null;
this.previous = null;
};
const LRUCache = function (capacity) {
this.head = null;
this.tail = null;