This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ROMAN_MAPPING = { | |
1: 'I', | |
5: 'V', | |
10: 'X', | |
50: 'L', | |
100: 'C', | |
500: 'D', | |
1000: 'M', | |
4: 'IV', | |
9: 'IX', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Heap { | |
constructor() { | |
this.container = []; | |
} | |
getLeftChildIndex(parentIndex) { | |
return 2 * parentIndex + 1; | |
} | |
getRightChildIndex(parentIndex) { | |
return 2 * parentIndex + 2; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LRUCache = function (capacity) { | |
this.cache = []; | |
this.capacity = capacity; | |
this.count = 0; | |
}; | |
LRUCache.prototype.get = function (key) { | |
const obj = this.cache.find((item) => item.key === key); | |
if (obj) { | |
this.cache = this.cache.filter((item) => item.key !== key); | |
this.cache.push(obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode 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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
int main(int argc, const char * argv[]) { | |
@autoreleasepool { | |
BOOL isRaining = true; | |
if(isRaining) { | |
printf("Get Umbrellla"); | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NS_ASSUME_NONNULL_BEGIN | |
@interface Movie : NSObject { | |
NSString* name; | |
NSInteger year; | |
NSInteger rating; | |
} | |
- (void)setName:(NSString*) movieName; | |
- (void)setYear:(NSInteger) releaseYear; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "Movie.h" | |
@implementation Movie | |
- (void)setName:(NSString *)movieName { | |
name = movieName; | |
} | |
- (void)setYear:(NSInteger)releaseYear { | |
year = releaseYear; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import XCTest | |
struct LoggedInUser { | |
let name: String | |
} | |
class LoginViewController: UIViewController { | |
var login: (((LoggedInUser) -> Void) -> Void)? | |
var user: String? |
OlderNewer