MCPcopy Create free account

hub / github.com/FreeTymeKiyan/LeetCode-Sol-Res / types & classes

Types & classes889 in github.com/FreeTymeKiyan/LeetCode-Sol-Res

↓ 1 callersClassatoi
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below
src/main/java/com/freetymekiyan/algorithms/level/easy/atoi.java:30
ClassAccountsMerge
721. Accounts Merge <p> Given a list accounts, each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and th
src/main/java/com/freetymekiyan/algorithms/level/medium/AccountsMerge.java:51
ClassAccountsMergeTest
src/test/java/com/freetymekiyan/algorithms/level/medium/AccountsMergeTest.java:11
ClassAddAndSearchWord
211. Add and Search Word - Data structure design <p> Design a data structure that supports the following two operations: <p> void addWord(word) bool s
src/main/java/com/freetymekiyan/algorithms/level/medium/AddAndSearchWord.java:33
ClassAddBinary
67. Add Binary <p> Given two binary strings, return their sum (also ab binary string). <p> For example, ab = "11" b = "1" Return "100". <p> Company Ta
src/main/java/com/freetymekiyan/algorithms/level/easy/AddBinary.java:17
ClassAddBinaryTest
src/test/java/com/freetymekiyan/algorithms/level/easy/AddBinaryTest.java:7
ClassAddDigits
258. Add Digits <p> Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. <p> For example: <p> Given nu
src/main/java/com/freetymekiyan/algorithms/level/easy/AddDigits.java:30
ClassAddTwoDoubles
Given two double values as strings, return the sum of them as a string. You may not convert the string to a double. <p> E.g. "1.13" + "0.9" => "2.03"
src/main/java/com/freetymekiyan/algorithms/other/AddTwoDoubles.java:12
ClassAddTwoDoublesTest
src/test/java/com/freetymekiyan/algorithms/other/AddTwoDoublesTest.java:7
ClassAddTwoNum
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contai
src/main/java/com/freetymekiyan/algorithms/level/medium/AddTwoNum.java:20
ClassAddTwoNumbers2
You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contai
src/main/java/com/freetymekiyan/algorithms/level/medium/AddTwoNumbers2.java:22
ClassAddTwoNumbers2Test
src/test/java/com/freetymekiyan/algorithms/level/medium/AddTwoNumbers2Test.java:8
ClassAddWithoutOperators
Write a function addRecursive() that returns sum of two integers. The function should not use any of the arithmetic operators (+, ++, –, -, .. etc). <
src/main/java/com/freetymekiyan/algorithms/other/AddWithoutOperators.java:12
ClassAddtiveNumber
306. Additive Number <p> Additive number is a string whose digits can form additive sequence. <p> A valid additive sequence should contain at least th
src/main/java/com/freetymekiyan/algorithms/level/medium/AddtiveNumber.java:39
ClassAlienDictionary
269. Alien Dictionary <p> There is a new alien language which uses the latin alphabet. However, the order among letters are unknown to you. You receiv
src/main/java/com/freetymekiyan/algorithms/level/hard/AlienDictionary.java:38
ClassAlmostBalancedTree
Given a tree, return whether the tree is almost balanced or not. The height different between the leaves of an almost balanced tree cannot exceed 1. N
src/main/java/com/freetymekiyan/algorithms/other/AlmostBalancedTree.java:16
ClassAlmostBalancedTreeTest
src/test/java/com/freetymekiyan/algorithms/other/AlmostBalancedTreeTest.java:9
ClassAnagrams
Given an array of strings, return all groups of strings that are anagrams. <p> Note: All inputs will be in lower-case. <p> Tags: Hash table, String
src/main/java/com/freetymekiyan/algorithms/level/medium/Anagrams.java:12
ClassArithmeticExpressionEvaluation
Dijkstra Two-Stack Algorithm for Expression Evaluation Assumes that the expression is fully parenthesized, with numbers and characters separated by wh
src/main/java/com/freetymekiyan/algorithms/other/ArithmeticExpressionEvaluation.java:9
ClassArithmeticSlices
413. Arithmetic Slices <p> A sequence of number is called arithmetic if it consists of at least three elements and if the difference between any two c
src/main/java/com/freetymekiyan/algorithms/level/medium/ArithmeticSlices.java:35
ClassArithmeticSlicesTest
src/test/java/com/freetymekiyan/algorithms/level/medium/ArithmeticSlicesTest.java:7
ClassArrayStack
array generics resizing loitering iteration <p> void push(Item item) Item pop() boolean isEmpty() int size()
src/main/java/com/freetymekiyan/datastructures/ArrayStack.java:17
ClassAsteroids
We are given an array asteroids of integers representing asteroids in a row. <p> For each asteroid, the absolute value represents its size, and the si
src/main/java/com/freetymekiyan/algorithms/level/medium/Asteroids.java:49
ClassAsteroidsTest
src/test/java/com/freetymekiyan/algorithms/level/medium/AsteroidsTest.java:6
ClassAstroid01
01 0 , can be 0 or 1 Generate all possible outputs Tags: Backtracking
src/main/java/com/freetymekiyan/algorithms/other/Astroid01.java:11
ClassAutocompleteSystem
Your AutocompleteSystem object will be instantiated and called as such: AutocompleteSystem obj = new AutocompleteSystem(sentences, times); List<String
src/main/java/com/freetymekiyan/algorithms/level/hard/DesignSearchAutocompleteSystem.java:81
ClassAverageOfLevelsInBinaryTree
637. Average of Levels in Binary Tree <p> Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array.
src/main/java/com/freetymekiyan/algorithms/level/easy/AverageOfLevelsInBinaryTree.java:31
ClassAverageOfLevelsInBinaryTreeTest
src/test/java/com/freetymekiyan/algorithms/level/easy/AverageOfLevelsInBinaryTreeTest.java:10
ClassBST
Created by kiyan on 5/26/16.
src/main/java/com/freetymekiyan/datastructures/BST.java:7
ClassBSTIterator
Time: O(1), pop the top element on the stack Space: O(h), elements in the stack will never exceed the height of the tree
src/main/cpp/173_Binary_Search_Tree_Iterator.cpp:34
ClassBSTIterator
Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. <p> Calling next() will return t
src/main/java/com/freetymekiyan/algorithms/level/medium/BSTIterator.java:20
ClassBTLevelOrder
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example: Given binary tree
src/main/java/com/freetymekiyan/algorithms/level/easy/BTLevelOrder.java:26
ClassBalancedBinaryTree
110. Balanced Binary Tree <p> Given a binary tree, determine if it is height-balanced. <p> For this problem, a height-balanced binary tree is defined
src/main/java/com/freetymekiyan/algorithms/level/easy/BalancedBinaryTree.java:16
ClassBasicCalculator
224. Basic Calculator <p> Implement a basic calculator to evaluate a simple expression string. <p> The expression string may contain open ( and closin
src/main/java/com/freetymekiyan/algorithms/level/hard/BasicCalculator.java:30
ClassBasicCalculator2
227. Basic Calculator II <p> Implement a basic calculator to evaluate a simple expression string. <p> The expression string contains only non-negative
src/main/java/com/freetymekiyan/algorithms/level/medium/BasicCalculator2.java:22
ClassBestTimeStock
121. Best Time to Buy and Sell Stock <p> Say you have an array for which the ith element is the price of a given stock on day i. <p> If you were only
src/main/java/com/freetymekiyan/algorithms/level/medium/BestTimeStock.java:26
ClassBestTimeStock2
Say you have an array for which the ith element is the price of a given stock on day i. <p> Design an algorithm to find the maximum profit. You may co
src/main/java/com/freetymekiyan/algorithms/level/medium/BestTimeStock2.java:15
ClassBestTimeStockTest
src/test/java/com/freetymekiyan/algorithms/level/medium/BestTimeStockTest.java:7
ClassBestTimeToBuyAndSellStock
Say you have an array for which the ith element is the price of a given stock on day i. <p> If you were only permitted to complete at most one transac
src/main/java/com/freetymekiyan/algorithms/level/easy/BestTimeToBuyAndSellStock.java:29
ClassBestTimeToBuyAndSellStock3
Say you have an array for which the ith element is the price of a given stock on day i. <p> Design an algorithm to find the maximum profit. You may co
src/main/java/com/freetymekiyan/algorithms/level/medium/BestTimeToBuyAndSellStock3.java:16
ClassBestTimeToBuyAndSellStock4
188. Best Time to Buy and Sell Stock IV <p> Say you have an array for which the ith element is the price of a given stock on day i. <p> Design an algo
src/main/java/com/freetymekiyan/algorithms/level/hard/BestTimeToBuyAndSellStock4.java:20
ClassBestTimeToBuyAndSellStockWithTransactionFee
714. Best Time to Buy and Sell Stock with Transaction Fee <p> Your are given an array of integers prices, for which the i-th element is the price of a
src/main/java/com/freetymekiyan/algorithms/level/medium/BestTimeToBuyAndSellStockWithTransactionFee.java:32
ClassBestTimeToBuyAndSellStockWithTransactionFeeTest
src/test/java/com/freetymekiyan/algorithms/level/medium/BestTimeToBuyAndSellStockWithTransactionFeeTest.java:6
ClassBestTimeToBuySellStockWithCooldown
309. Best Time to Buy and Sell Stock with Cooldown <p> Say you have an array for which the ith element is the price of a given stock on day i. <p> Des
src/main/java/com/freetymekiyan/algorithms/level/medium/BestTimeToBuySellStockWithCooldown.java:19
ClassBestTimetoBuyandSellStock_shuna
Best Time to Buy and Sell Stock Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to
src/main/java/com/freetymekiyan/algorithms/level/easy/BestTimetoBuyandSellStock1.java:16
ClassBinaryIndexedTree
Binary Indexed Tree is represented as an array. Let the array be BITree[]. Each node of Binary Indexed Tree stores sum of some elements of given array
src/main/java/com/freetymekiyan/datastructures/BinaryIndexedTree.java:16
ClassBinaryIndexedTreeTest
src/test/java/com/freetymekiyan/datastructures/BinaryIndexedTreeTest.java:8
ClassBinarySearchTreeIterator
173. Binary Search Tree Iterator <p> Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a
src/main/java/com/freetymekiyan/algorithms/level/medium/BinarySearchTreeIterator.java:23
ClassBinaryTreeInOrderTraversal
94. Binary Tree Inorder Traversal <p> Given a binary tree, return the inorder traversal of its nodes' values. <p> For example: Given binary tree [1,nu
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeInOrderTraversal.java:28
ClassBinaryTreeInOrderTraversalTest
src/test/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeInOrderTraversalTest.java:11
ClassBinaryTreeLevelOrderTraversal
102. Binary Tree Level Order Traversal <p> Given a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, leve
src/main/java/com/freetymekiyan/algorithms/level/easy/BinaryTreeLevelOrderTraversal.java:35
ClassBinaryTreeLevelOrderTraversal2
107. Binary Tree Level Order Traversal II <p> Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to
src/main/java/com/freetymekiyan/algorithms/level/easy/BinaryTreeLevelOrderTraversal2.java:34
ClassBinaryTreeLongestPath
Given a binary tree, find the longest path from root to a leaf. The path can be arrow concatenated string like 1->2->3.
src/main/java/com/freetymekiyan/algorithms/other/BinaryTreeLongestPath.java:10
ClassBinaryTreeLongestPathTest
src/test/java/com/freetymekiyan/algorithms/other/BinaryTreeLongestPathTest.java:9
ClassBinaryTreeMaximumPathSum
Given a binary tree, find the maximum path sum. <p> The path may start and end at any node in the tree. <p> For example: Given the below binary tree,
src/main/java/com/freetymekiyan/algorithms/level/hard/BinaryTreeMaximumPathSum.java:18
ClassBinaryTreePaths
257. Binary Tree Paths <p> Given a binary tree, return all root-to-leaf paths. <p> For example, given the following binary tree: <p> | 1 | / \ |
src/main/java/com/freetymekiyan/algorithms/level/easy/BinaryTreePaths.java:29
ClassBinaryTreePostorderTraversal
145. Binary Tree Postorder Traversal <p> Given a binary tree, return the postorder traversal of its nodes' values. <p> Example: <p> Input: [1,null,2,3
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreePostorderTraversal.java:30
ClassBinaryTreePreorderTraversal
Given a binary tree, return the preorder traversal of its nodes' values. <p> For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. <p> N
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreePreorderTraversal.java:23
ClassBinaryTreeRigthSideView
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. <p> For
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeRigthSideView.java:26
ClassBinaryTreeToCircularDoublyLinkedList
Given a binary tree, convert it to a Circular Doubly Linked List. <p> The left and right pointers in nodes are to be used as previous and next pointer
src/main/java/com/freetymekiyan/algorithms/other/BinaryTreeToCircularDoublyLinkedList.java:18
ClassBinaryTreeToCircularDoublyLinkedListTest
src/test/java/com/freetymekiyan/algorithms/other/BinaryTreeToCircularDoublyLinkedListTest.java:9
ClassBinaryTreeUpsideDown
156. Binary Tree Upside Down <p> Given a binary tree where all the right nodes are either leaf nodes with a sibling (a left node that shares the same
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeUpsideDown.java:31
ClassBinaryTreeVerticalOrderTraversal
314. Binary Tree Vertical Order Traversal <p> Given a binary tree, return the vertical order traversal of its nodes' values. (ie, from top to bottom,
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeVerticalOrderTraversal.java:77
ClassBinaryTreeZigZag
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigZag.java:31
ClassBinaryTreeZigzagLevelOrderTraversal
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and
src/main/java/com/freetymekiyan/algorithms/level/medium/BinaryTreeZigzagLevelOrderTraversal.java:32
ClassBinaryWatch
401. Binary Watch <p> A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59)
src/main/java/com/freetymekiyan/algorithms/level/easy/BinaryWatch.java:37
ClassBitwiseAndOfNumbersRange
201. Bitwise AND of Numbers Range <p> Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclu
src/main/java/com/freetymekiyan/algorithms/level/medium/BitwiseAndOfNumbersRange.java:18
ClassBombEnemy
361. Bomb Enemy <p> Given a 2D grid, each cell is either a wall 'W', an enemy 'E' or empty '0' (the number zero), return the maximum enemies you can k
src/main/java/com/freetymekiyan/algorithms/level/medium/BombEnemy.java:24
ClassBrickWall
554. Brick Wall <p> There is a brick wall in front of you. The wall is rectangular and has several rows of bricks. The bricks have the same height but
src/main/java/com/freetymekiyan/algorithms/level/medium/BrickWall.java:44
ClassBstNode
Binary Search Tree node that contains an interval as value. Also has two children, left and right.
src/main/java/com/freetymekiyan/algorithms/level/hard/DataStreamAsDisjointIntervals.java:257
ClassBulbSwitcher
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every
src/main/java/com/freetymekiyan/algorithms/level/medium/BulbSwitcher.java:22
ClassBullsAndCows
299. Bulls and Cows <p> You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what
src/main/java/com/freetymekiyan/algorithms/level/easy/BullsAndCows.java:31
ClassBurstBalloons
312. Burst Balloons <p> Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked
src/main/java/com/freetymekiyan/algorithms/level/hard/BurstBalloons.java:29
ClassCanBePalindrome
Given a string, return whether the characters in the string can form a palindrome. Follow up, generate all possible combinations.
src/main/java/com/freetymekiyan/algorithms/other/CanBePalindrome.java:8
ClassCandy
There are N children standing in a line. Each child is assigned a rating value. You are giving candies to these children subjected to the following r
src/main/java/com/freetymekiyan/algorithms/level/hard/Candy.java:16
ClassCelebrity
Given: function: isFriend(a, b) Returns true iff b is treated as a friend by a group of persons, say, represented as an array
src/main/java/com/freetymekiyan/algorithms/other/Celebrity.java:9
ClassCell
src/main/java/com/freetymekiyan/algorithms/level/hard/TrappingRainWater2.java:97
ClassCharFrequencyOrderOfAString
Given a String, output the characters in the String according to its frequency. <p> For example, given "banana", the output should be “a 3, n 2, b 1”
src/main/java/com/freetymekiyan/algorithms/other/CharFrequencyOrderOfAString.java:11
ClassClimbingStairs
You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you c
src/main/java/com/freetymekiyan/algorithms/level/easy/ClimbingStairs.java:11
ClassCloneGraph
133. Clone Graph <p> Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. <p> OJ's undirected graph seriali
src/main/java/com/freetymekiyan/algorithms/level/medium/CloneGraph.java:39
ClassClosestBinarySearchTreeValue
270. Closest Binary Search Tree Value <p> Given a non-empty binary search tree and a target value, find the value in the BST that is closest to the ta
src/main/java/com/freetymekiyan/algorithms/level/easy/ClosestBinarySearchTreeValue.java:18
ClassClosestBinarySearchTreeValue2
272. Closest Binary Search Tree Value II <p> Given a non-empty binary search tree and a target value, find k values in the BST that are closest to the
src/main/java/com/freetymekiyan/algorithms/level/hard/ClosestBinarySearchTreeValue2.java:39
ClassClosestLeafInABinaryTree
742. Closest Leaf in a Binary Tree <p> Given a binary tree where every node has a unique value, and a target key k, find the value of the closest leaf
src/main/java/com/freetymekiyan/algorithms/level/medium/ClosestLeafInABinaryTree.java:62
ClassClosestLeafInABinaryTreeTest
src/test/java/com/freetymekiyan/algorithms/level/medium/ClosestLeafInABinaryTreeTest.java:10
ClassCodec
src/main/java/com/freetymekiyan/algorithms/level/medium/EncodeAndDecodeTinyURL.java:23
ClassCodec
src/main/java/com/freetymekiyan/algorithms/level/medium/EncodeAndDecodeStrings.java:50
ClassCodec
Unlike binary tree, binary search tree can be constructed with preorder + inorder traversal. So null node can be ignored, thus making the string more
src/main/java/com/freetymekiyan/algorithms/level/medium/SerializeAndDeserializeBst.java:34
ClassCoinChange
You are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you nee
src/main/java/com/freetymekiyan/algorithms/level/medium/CoinChange.java:23
ClassCombinationSum
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. <p> The same re
src/main/java/com/freetymekiyan/algorithms/level/medium/CombinationSum.java:27
ClassCombinationSum2
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. <p> Each
src/main/java/com/freetymekiyan/algorithms/level/medium/CombinationSum2.java:29
ClassCombinationSum3
216. Combination Sum III <p> Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used an
src/main/java/com/freetymekiyan/algorithms/level/medium/CombinationSum3.java:33
ClassCombinationSum4
377. Combination Sum IV <p> Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up t
src/main/java/com/freetymekiyan/algorithms/level/medium/CombinationSum4.java:41
ClassCombinationSum4Test
src/test/java/com/freetymekiyan/algorithms/level/medium/CombinationSum4Test.java:7
ClassCombinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. <p> For example, If n = 4 and k = 2, a solution is: | [ |
src/main/java/com/freetymekiyan/algorithms/level/medium/Combinations.java:25
ClassCompareVersionNumbers
Compare two version numbers version1 and version1. If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. <p> You may
src/main/java/com/freetymekiyan/algorithms/level/easy/CompareVersionNumbers.java:21
ClassConstructBTFromInPostOrder
Given inorder and postorder traversal of a tree, construct the binary tree. <p> Note: You may assume that duplicates do not exist in the tree. <p> Tag
src/main/java/com/freetymekiyan/algorithms/level/medium/ConstructBTFromInPostOrder.java:11
ClassConstructBTPreInOrder
105. Construct Binary Tree from Preorder and Inorder Traversal <p> Given preorder and inorder traversal of a tree, construct the binary tree <p> Note:
src/main/java/com/freetymekiyan/algorithms/level/medium/ConstructBTPreInOrder.java:18
ClassConstructBinaryTree
Construct Binary Tree from Inorder and Postorder Traversal Given inorder and postorder traversal of a tree, construct the binary tree. Tags: Tree Arra
src/main/java/com/freetymekiyan/algorithms/level/medium/ConstructBinaryTree.java:15
ClassContainerWithMostWater
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpo
src/main/java/com/freetymekiyan/algorithms/level/medium/ContainerWithMostWater.java:14
ClassContainsDuplicate
Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the arr
src/main/java/com/freetymekiyan/algorithms/level/easy/ContainsDuplicate.java:18
next →1–100 of 889, ranked by callers