# “Valid Parentheses” Cheat Sheet javascript solution

The Valid Parentheses is in the easy category and is a good start for understanding more challenging algorithms using the stack and array as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge:

“Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid.

An input string is valid if:

1. Open brackets must be closed in the correct order.”LeetCode

Note:

`// String s// Determine…`

# “Squares of a Sorted Array” Ruby Solution Cheat Sheet.

The Squares of a Sorted Array List is in the easy category and is a good start for understanding more challenging algorithms using arrays as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge: “Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.”LeetCode.

Note:

`//Array data structure//Input sorted array smaller to a greater element//Return square of each element sorted smaller to greater element.`

Example:

`nums = [-3,-2,0,4,10]return [0,4,9,16,100]`

Explanation:

Create a…

# “Squares of a Sorted Array” Javascript Solution Cheat Sheet.

The “Squares of a Sorted Array “is in the easy category and is a good start for understanding more challenging algorithms using arrays as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge: “Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.”LeetCode.

Note:

`//Array data structure//Input sorted array smaller to a greater element//Return square of each element sorted smaller to greater element.`

Example:

`nums = [-3,-2,0,4,10]return [0,4,9,16,100]`

Explanation:

loop through the…

# “Linked List Cycle” Javascript Solution Cheat Sheet

The Linked List Cycle List is in the easy category and is a good start for understanding more challenging algorithms using a linked list as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

## Challenge:

Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of…

# “Reverse Linked List” Javascript solution Cheat Sheet

The “Reverse Linked List” is in the easy category and is a good start for understanding more challenging algorithms using a linked list as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge: “Given the head of a singly linked list, reverse the list, and return the reversed list.”LeetCode

Note:

`// Singly linked list data structure// Given head “Object”// Reverse the list// Return reversed list`

Example:

`input: head =[5,6,7,8,9,10]  next   | 5 -> 6 -> 7 -> 8 -> 9…`

# “Range Sum of BST” Javascript solution Cheat Sheet

The Range Sum of the BST challenge is in the easy category and is a good start for understanding more challenging algorithms using trees as a data structure. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge: “Given the root node of a binary search tree and two integers low and high, return the sum of values of all nodes with a value in the inclusive range [low, high].”LeetCode

Note:

`//Binary search tree data structure.//Two integers low and high defined the range.//Return sum of values within the range…`

# “Longest Common Prefix” cheat sheet Javascript solution

The Longest Common Prefix challenge is in the easy category and is a good start for understanding more challenging algorithms. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge:

“Write a function to find the longest common prefix string amongst an array of strings.

If there is no common prefix, return an empty string “”. LeetCode

Note:

`//Find longest equal prefix// Array of strings//Return “” if empty//Prefix will always start at the beginning of the string`

Example:

`string = [“pot”, “pop”, “top”]return “”string = [“flower”,”…`

# “Roman Integer” Javascript Solution Cheat Sheet

The “Remove Roman Integer” challenge is in the easy category and is a good start for understanding more challenging algorithms. I will focus on explaining a solution that works and not on the O time and space complexity.

Challenge: “Roman numerals are represented by seven different symbols: I, V, X, L, C, D, and M.

Symbol Value

I 1

V 5

X 10

L 50

C 100

D 500

M 1000

For example, 2 is written as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. …

# Remove Duplicates from Sorted Array Cheat Sheet Javascript Solution.

The Remove Duplicate challenge is in the easy category and is a good start for understanding more challenging algorithms. I will focus on explaining a solution that works and not on the O time and space complexity.

## Challenge:

“Given sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.” LeetCode

Notes:

`-first element always unique-sorted array-remove duplicate-return the new length`

## Example:

`arr = [3,3,4,4,4,5,5]new arr =[3,4,5]…`

# Palindrome Number LeetCode Cheat Sheet Javascript Solution

This LeetCode Challenge is really similar to the “reverse integer challenge” with a little spin. This time we want to return a boolean value.

The Palindrome challenge is in the easy category and is a good start for understanding more challenging algorithms. I will focus on explaining a solution that works and not on the O time and space complexity.

Palindrome Number Challenge

“Given an integer x, return true if x is palindrome integer. An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.” (LeetCode)

`Examplex= 565…`