Pinned Repositories
1119.-Remove-Vowels-from-a-String
1146.-Snapshot-Array
Implement a SnapshotArray that supports the following interface: SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0.
ACSI-github
Apartment-Hunting
You're looking to move into a new apartment, and you're given a list of blocks where each block contains an apartment that you could move into. In order to pick your apartment, you want to optimize its location. You also have a list of requirements: a list of buildings that are important to you. For instance, you might value having a school and a gym near your apartment. The list of blocks that you have contains information at every block about all of the buildings that are present and absent at the block in question. For instance, for every block, you might know whether a school, a pool, an office, and a gym are present or not. In order to optimize your life, you want to minimize the farthest distance you'd have to walk from your apartment to reach all of your required buildings. Write a function that takes in a list of blocks and a list of your required buildings and that returns the location (the index) of the block that is most optimal for you. Sample input: [ { "gym": False, "school": True, "store": False, }, { "gym": True, "school": False, "s
Architable2
Breadth-first-search
Implement the breadthFirstSearch method on the node class
Fintrack
Web Progressive app that lets you track and manage your finances with D3 graphs. Technology used: Technology used: React, Redux, Cloud Firestore, Express, Plaid API, D3.js, Agile(Waffle), Heroku, TDD (Mocha)
PWA
RestroomFinder
SpringBootMircoservices
prince7475's Repositories
prince7475/Palindrome-Partitioning-Min-Cuts
Given a non-empty string, write a function that returns the minimum number of cuts needed to perform on the string such that each remaining substring is a palindrome. A palindrome is defined as a string that is written the same forward as backward. Note that single-character strings are palindromes. Sample input:"noonabbad" Sample output: 2 ("noon | abba | d")
prince7475/MaxProfit-With-K-Transactions
Max Profit With K Transactions You are given an array of integers representing the prices of a single stock on various days (each index in the array represents a different day). You are also given an integer k, which represents the number of transactions you are allowed to make. One transaction consists of buying the stock on a given day and selling it on another, later day. Write a function that returns the maximum profit that you can make buying and selling the stock, given k transactions. Note that you can only hold 1 share of the stock at a time; in other words, you cannot buy more than 1 share of the stock on any given day, and you cannot buy a share of the stock if you are still holding another share. Note that you also don't need to use all k transactions that you're allowed. Sample input: [5, 11, 3, 50, 60, 90], 2 Sample output: 93 (Buy: 5, Sell: 11; Buy: 3, Sell: 90)
prince7475/Iterative-In-order-traversal
Write a function that takes in a Binary Tree and traverses it using the in-order traversal technique but without using recursion. As the tree is being traversed, a callback function passed in as an argument to the main function should be called on each node (i.e. callback(currentNode)). Each Binary Tree node has a value stored in a property called "value," a parent node in a property called "parent," and two children nodes stored in properties called "left" and "right," respectively. Children nodes can either be Binary Tree nodes themselves or the None (null) value. Sample input: 1 / \ 2 3 / / \ 4 6 7 \ 9 Sample output: callback(4) callback(9) callback(2) callback(1) callback(6) callback(3) callback(7
prince7475/Bellman-Ford
prince7475/Dijkstra-Shortest-Path
prince7475/Apartment-Hunting
You're looking to move into a new apartment, and you're given a list of blocks where each block contains an apartment that you could move into. In order to pick your apartment, you want to optimize its location. You also have a list of requirements: a list of buildings that are important to you. For instance, you might value having a school and a gym near your apartment. The list of blocks that you have contains information at every block about all of the buildings that are present and absent at the block in question. For instance, for every block, you might know whether a school, a pool, an office, and a gym are present or not. In order to optimize your life, you want to minimize the farthest distance you'd have to walk from your apartment to reach all of your required buildings. Write a function that takes in a list of blocks and a list of your required buildings and that returns the location (the index) of the block that is most optimal for you. Sample input: [ { "gym": False, "school": True, "store": False, }, { "gym": True, "school": False, "s
prince7475/Merge-Sort
Write a function that takes in an array of integers and returns a sorted version of that array. Use the Merge Sort algorithm to sort the array. Sample input: [8, 5, 2, 9, 5, 6, 3] Sample output: [2, 3, 5, 5, 6, 8, 9]
prince7475/Longest-Substring-Without-Duplication
Longest Substring Without Duplication Write a function that takes in a string and that returns its longest substring without duplicate characters. Assume that there will only be one longest substring without duplication. Sample input:"clementisacap" Sample output:"mentisac"
prince7475/Finding-The-Shortest-Path-In-A-Graph
Find the Shortest Path in a directed Acyclic graph (DAG)
prince7475/FindNumberOfMovesToExit
prince7475/Lowest-Common-Manager
You're given three inputs, all of which are instances of a class that have a "directReports" property pointing to their direct reports. The first input is the top manager in an organizational chart (i.e., the only instance that is not anybody else's direct report), and the other two inputs are reports in the organizational chart. Write a function that returns the lowest common manager to the two reports. Sample input: Node A, Node E, Node I (from the organizational chart below) A / \ B C / \ / \ D E F G / \ H I Sample output: Node B
prince7475/Pattern-Matcher
Pattern Matcher You are given two non-empty strings. The first one is a pattern consisting of only "x"s and / or "y"s; the other one is a normal string of alphanumeric characters. Write a function that checks whether or not the normal string matches the pattern. A string S0 is said to match a pattern if replacing all"x"s in the pattern with some string S1 and replacing all"y"s in the pattern with some string S2 yields the same string S0. If the input string does not match the input pattern, return an empty array; otherwise, return an array holding the representations of"x" and "y"in the normal string, in that order. If the pattern does not contain any "x"s or "y"s, the respective letter should be represented by an empty string in the final array that you return. Assume that there will never be more than one pair of strings S1 and S2 that appropriately represent"x" and "y"in the input string. Sample input:"xxyxxy","gogopowerrangergogopowerranger" Sample output: ["go","powerranger"]
prince7475/Underscorify-Substring
Write a function that takes in two strings: a main string and a potential substring of the main string. The function should return a version of the main string with every instance of the substring in it wrapped between underscore
prince7475/Search-For-Range
Write a function that takes in a sorted array of integers as well as a target integer. The function should use a variation of the Binary Search algorithm to find a range of indices in between which the target number is contained in the array and should return this range in the form of an array. The first number in the output array should represent the first index at which the target number is located while the second number should represent the last index at which the target number is located. The function should return [-1, -1] if the number is not contained in the array. Sample input: [0, 1, 21, 33, 45, 45, 45, 45, 45, 45, 61, 71, 73], 45 Sample output: [4, 9]
prince7475/MIn-Number-Of-Jumps
You are given a non-empty array of integers. Each element represents the maximum number of steps you can take forward. For example, if the element at index 1 is 3, you can go from index 1 to index 2, 3, or 4. Write a function that returns the minimum number of jumps needed to reach the final index. Note that jumping from index i to index i + x always constitutes 1 jump, no matter how large x is.
prince7475/Find-Loop
Write a function that takes in the head of a Singly Linked List that contains a loop (in other words, the list's tail node points to some node in the list instead of the None (null) value). The function should return the node (the actual node - not just its value) from which the loop originates in constant space. Note that every node in the Singly Linked List has a "value" property storing its value as well as a "next" property pointing to the next node in the list.
prince7475/Multi-String-Search
prince7475/Quick-Select
Write a function that takes in an array of distinct integers as well as an integer k and returns the kth smallest number in that array in linear time, on average. The array could be sorted, but isn't necessarily so. Sample input: [8, 5, 2, 9, 7, 6, 3], 3 Sample output: 5
prince7475/Shifted-Binary-Search
Write a function that takes in a sorted array of integers as well as a target integer. The caveat is that the numbers in the array have been shifted by some amount; in other words, they have been moved to the left or the right by one or more positions. For example, [1, 2, 3, 4] might become [3, 4, 1, 2]. The function should use a variation of the Binary Search algorithm to find if the target number is contained in the array and should return its index if it is, otherwise -1. Sample input: [45, 61, 71, 72, 73, 0, 1, 21, 33, 45], 33 Sample output: 8
prince7475/Reverse-Linked-List
Write a function that takes in the head of a Singly Linked List (assume that the list has at least 1 node; in other words, the head will never be a null value). The function should reverse the list and return its new head. Note that every node in the Singly Linked List has a "value" property storing its value as well as a "next" property pointing to the next node in the list or None (null) if it is the tail of the list. Sample input: 0 -> 1 -> 2 -> 3 -> 4 -> 5 (the head node with value 0) Sample output: 5 -> 4 -> 3 -> 2 -> 1 -> 0 (the new head node with value 5)
prince7475/max-sum-increasing-subsequence
Given an non-empty array of integers, write a function that returns an array of length 2. The first element in the output array should be an integer value representing the greatest sum that can be generated from a strictly-increasing subsequence in the array. The second element should be an array of the numbers in that subsequence. A subsequence is defined as a set of numbers that are not necessarily adjacent but that are in the same order as they appear in the array. Assume that there will only be one increasing subsequence with the greatest sum. Sample input: [10, 70, 20, 30, 50, 11, 30]
prince7475/Heap-Sort
Write a function that takes in an array of integers and returns a sorted version of that array. Use the Heap Sort algorithm to sort the array. Sample input: [8, 5, 2, 9, 5, 6, 3] Sample output: [2, 3, 5, 5, 6, 8, 9]
prince7475/Disk-Stacking
You are given a non-empty array of arrays. Each subarray holds three integers and represents a disk. These integers denote each disk's width, depth, and height, respectively. Your goal is to stack up the disks and to maximize the total height of the stack. A disk must have a strictly smaller width, depth, and height than any other disk below it. Write a function that returns an array of the disks in the final stack, starting with the top disk and ending with the bottom disk. Note that you cannot rotate disks; in other words, the integers in each subarray must represent [width, depth, height] at all times. Assume that there will only be one stack with the greatest total height. Sample input: [[2, 1, 2], [3, 2, 3], [2, 2, 8], [2, 3, 4], [1, 3, 1], [4, 4, 5]] Sample output: [[2, 1, 2], [3, 2, 3], [4, 4, 5]]
prince7475/Boggle-Board
You are given a two-dimensional array (matrix) of potentially unequal height and width containing letters; this matrix represents a boggle board. You are also given a list of words. Write a function that returns an array of all the words contained in the boggle board. A word is constructed in the boggle board by connecting adjacent (horizontally, vertically, or diagonally) letters, without using any single letter at a given position more than once; while words can of course have repeated letters, those repeated letters must come from different positions in the boggle board in order for the word to be contained in the board. Note that two or more words are allowed to overlap and use the same letters in the boggle board.
prince7475/Numbers-in-pi
Given a string representation of the first n digits of Pi and a list of your favorite numbers (all positive integers in string format), write a function that returns the smallest number of spaces that need to be added to the n digits of Pi such that all resulting numbers are found in the list of favorite numbers. If no number of spaces to be added exists such that all resulting numbers are found in the list of favorite numbers, the function should return -1.
prince7475/Water-Area-
You are given an array of integers. Each non-zero integer represents the height of a pillar of width 1. Imagine water being poured over all of the pillars and return the surface area of the water trapped between the pillars viewed from the front. Note that spilled water should be ignored. Refer to the first minute of the video explanation below for a visual example.
prince7475/Longest-Common-Subsequence
Implement a function that returns the longest subsequence common to two given strings. A subsequence is defined as a group of characters that appear sequentially, with no importance given to their actual position in a string. In other words, characters do not need to appear consecutively in order to form a subsequence. Assume that there will only be one longest common subsequence.
prince7475/Same-BST
An array of integers is said to represent the Binary Search Tree (BST) obtained by inserting each integer in the array (from left to right) into the BST. Write a function that takes in two arrays of integers and returns a boolean representing whether or not these arrays represent the same BST. Note that you are not allowed to construct any BSTs in your code. A BST is a Binary Tree that consists only of BST nodes. A node is said to be a BST node if and only if it satisfies the BST property: its value is strictly greater than the values of every node to its left; its value is less than or equal to the values of every node to its right; and both of its children nodes are either BST nodes themselves or None (null) values.
prince7475/Interweaving-Strings
Write a function that takes in three strings and returns a boolean representing whether or not the third string can be formed by interweaving the first two strings. To interweave strings means to merge them by alternating their letters without any specific pattern. For instance, the strings "abc" and "123" can be interwoven as "a1b2c3", as "abc123", and as "ab1c23" (this list is nonexhaustive).
prince7475/Merge-Linked-Lists
Write a function that takes in the heads of two Singly Linked Lists that are in sorted order, respectively (assume that the lists have at least 1 node; in other words, the heads will never be null values). The function should merge the lists and return the head of the merged list; the merged list should be in sorted order. Note that every node in the Singly Linked Lists has a "value" property storing its value as well as a "next" property pointing to the next node in the list or None (null) if it is the tail of the list.