Skip to content

Instantly share code, notes, and snippets.

View basekays's full-sized avatar

Hyejin Kay Albito basekays

View GitHub Profile
/**
* Definition for singly-linked list.
* function ListNode(val) {
* this.val = val;
* this.next = null;
* }
*/
/**
* @param {ListNode} head
* @return {ListNode}
/**
* @param {string} s
* @return {boolean}
*/
const reference = {
'(': ')',
'{': '}',
'[': ']',
};
//input string
//output number
// I can be placed before V (5) and X (10) to make 4 and 9.
// X can be placed before L (50) and C (100) to make 40 and 90.
// C can be placed before D (500) and M (1000) to make 400 and 900.
var romanToInt = function(string) {
var reference = {
'I': 1,
//input string
//output number
// I can be placed before V (5) and X (10) to make 4 and 9.
// X can be placed before L (50) and C (100) to make 40 and 90.
// C can be placed before D (500) and M (1000) to make 400 and 900.
var romanToInt = function(string) {
var reference = {
'I': 1,
/**
* Definition for binary tree
* function TreeNode(val) {
* this.val = val;
* this.left = this.right = null;
* }
*/
/**
* @constructor
/**
* Return true if this NestedInteger holds a single integer, rather than a nested list.
* @return {boolean}
* this.isInteger = function() {
* ...
* };
* Return the single integer that this NestedInteger holds, if it holds a single integer
* Return null if this NestedInteger holds a nested list
* @return {integer}
* this.getInteger = function() {
/**
* Return true if this NestedInteger holds a single integer, rather than a nested list.
* this.isInteger = function() {
* ...
* };
* Return the single integer that this NestedInteger holds, if it holds a single integer
* Return null if this NestedInteger holds a nested list
* this.getInteger = function() {
* ...
* };
/**
* // This is the interface that allows for creating nested lists.
* // You should not implement it, or speculate about its implementation
* function NestedInteger() {
*
* Return true if this NestedInteger holds a single integer, rather than a nested list.
* @return {boolean}
* this.isInteger = function() {
* ...
* };
//input = array, number
//output = array
//test case
//[2, 7, 11, 15], 13
//[0, 2]
function twoSum (array, number) {
var solutionObject = {};
for (let i = 0; i < array.length; i++) {
//input = integer
//output = integer
//test case
// 123
// -> 321
function reverseInteger(integer) {
var result = '';
var stringified = integer.toString();