Skip to content

Instantly share code, notes, and snippets.

View lornawanjiru's full-sized avatar
💭
👾 Coding

lornawanjiru lornawanjiru

💭
👾 Coding
View GitHub Profile
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.11;
//Different data structures
contract Variable{
// Fized size types which hold a fixed memory size
bool isReady;
uint a ;
address recepient;
//used mainly for strings that wont exceed 32byte
@lornawanjiru
lornawanjiru / Data-structure-and-algorithm.js
Last active April 18, 2022 17:01
Data structure and algorithm notes. I have tackled a number of questions and realized i would forget some algorithms since I don't repeat the questions as much. I made this gist to help me go through the question intensively.
##Longest Substring with At Most K Distinct Characters
var lengthOfLongestSubstringKDistinct = function(s, k) {
//incase the length of the string is the same or less than the distict number then return the length of the string.
if(k >= s.length ){
return s.length;
}
//define an empty hash map variable.
let hmap = {}
let max = 0;
//iterating through the string.