Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedrovgs/Algorithms
Solutions for some common algorithm problems written in Java.
https://github.com/pedrovgs/Algorithms
Last synced: 3 months ago
JSON representation
Solutions for some common algorithm problems written in Java.
- Host: GitHub
- URL: https://github.com/pedrovgs/Algorithms
- Owner: pedrovgs
- License: apache-2.0
- Created: 2014-11-09T14:32:33.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2023-06-24T04:38:33.000Z (over 1 year ago)
- Last Synced: 2024-05-18T03:34:06.076Z (6 months ago)
- Language: Java
- Homepage:
- Size: 478 KB
- Stars: 2,785
- Watchers: 194
- Forks: 797
- Open Issues: 28
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.txt
Awesome Lists containing this project
README
Algorithms [![QA check](https://github.com/pedrovgs/Algorithms/actions/workflows/check.yml/badge.svg)](https://github.com/pedrovgs/Algorithms/actions/workflows/check.yml)
==========This repository contains my solution for common algorithms. I've created this repository to learn about algorithms and improve solutions to common computer science problems. I'll try to add more solutions if I have time. :)
Each solution has a Java program and is tested. Some problems contain multiple solutions with different implementations.
You can check the solution executing tests inside tests directory. Some problems were resolved using TDD.
Problems
--------### Trees
* [Binary tree by level](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem13/BinaryTreeByLevel.java)
* [Binary tree pre order](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem14/BinaryTreePreOrder.java)
* [Binary tree in order](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem15/BinaryTreeInOrder.java)
* [Binary tree post order](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem16/BinaryTreePostOrder.java)
* [Are binary trees equals?](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem17/BinaryTreeEquals.java)
* [Is binary search tree](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem18/IsBST.java)
* [Binary tree depth](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem19/BinaryTreeDepth.java)
* [Lowest common ancestor](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem21/LowestCommonAncestor.java)
* [Sorted array to BST](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem24/SortedArrayToBST.java)
* [AVL tree median](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem36/AvlTreeMedian.java)
* [Path calculator](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem37/PathCalculator.java)
* [Path to every leaf](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem38/PathToEveryLeaf.java)
* [Is tree balanced](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem65/IsTreeBalanced.java)
* [Generate list with nodes by level](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem66/TreeToListByLevel.java)### Linked List
* [Reverse linked list](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem22/ReverseLinkedList.java)
* [Remove duplicates](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem57/RemoveListDuplicatedElements.java)
* [Find kth element](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem58/FindKthElement.java)
* [Delete list node](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem59/DeleteListNode.java)
* [Partition list](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem60/PartitionList.java)
* [Sum lists](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem61/SumLists.java)
* [PalindromeList](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem62/PalindromeList.java)
* [Get element in the middle of the list](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem64/GetTheElementInTheMiddleOfTheList.java)### Strings
* [Int to String](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem11/IntToString.java)
* [Remove comments from file](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem23/RemoveComments.java)
* [Reverse sentence](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem27/ReverseSentence.java)
* [Contains](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem32/Contains.java)
* [Simple regular expression](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem33/SimpleRegularExpression.java)
* [Dot regular expression](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem34/DotRegularExpression.java)
* [Asterisk regular expression](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem35/AsteriskRegularExpression.java)
* [Unique chars](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem50/UniqueChars.java)
* [Reverse string](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem51/ReverseString.java)
* [Compress string](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem53/CompressString.java)
* [Is rotation using substring](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem56/IsRotationUsingIsSubstring.java)### Binary Numbers and bits operators
* [Is binary number even?](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem68/IsEven.java)
* [Sum binary numbers](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem3/SumBinaryNumbers.java)
* [Count the number of bits equals to 1](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem1/BitsCounter.java)
* [Merge binary numbers](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem67/MergeBinaryNumbers.java)
* [Count the number of different bits](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem69/BitsToTransform.java)
* [Reverse binary number order](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem70/ReverseOrderOfBinaryNumber.java)
* [Reverse binary number](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem71/ReverseBinaryNumber.java)### Math Operations
* [Square root](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem4/SquareRoot.java)
* [Divide using subtraction](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem5/DivideUsingSubtraction.java)
* [Multiplication without multiply](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem20/MultiplicationWithoutMultiply.java)
* [Find sums](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem28/FindSums.java)
* [ScientificNotation](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem30/ScientificNotation.java)
* [Vector scalar product](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem2/VectorScalarProduct.java)
* [Subtract adding](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem73/SubtractAdding.java)### Sequences
* [Fibonacci numbers](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem7/FibonacciNumbers.java)
* [Factorial](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem9/Factorial.java)### Arrays
* [Merge sorted arrays](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem6/MergeSortedArrays.java)
* [Split array in positive and negative numbers](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem8/SplitArray.java)
* [Remove duplicated elements](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem10/RemoveDuplicates.java)
* [Move zeros in array](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem12/MoveZerosInArray.java)
* [Find longest consecutive sequence](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem31/FindLongestConsecutiveSequence.java)
* [Multiply array elements](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem39/MultiplyArrayElements.java)
* [Move elements to position](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem40/MoveElementsToPositions.java)
* [Replace spaces](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem52/ReplaceSpaces.java)
* [Rotate matrix](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem54/RotateMatrix.java)
* [Rewrite row and columns with zero](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem55/RewriteRowAndColumnsWithZeros.java)
* [Find the missing number](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem72/FindTheMissingNumber.java)### Sorting Algorithms
* [Bubble Sort](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem74/BubbleSort.java)
* [Selection Sort](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem75/SelectionSort.java)
* [Insertion Sort](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem76/InsertionSort.java)
* [Merge Sort](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem79/MergeSort.java)
* [Quick Sort](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem80/QuickSort.java)### Misc
* [Anagrams](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem25/Anagrams.java)
* [Palindromes](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem26/Palindromes.java)
* [Are anagrams?](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem29/AreAnagrams.java)
* [Constant complexity order stack](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem63/ConstantComplexityOrderStack.java)
* [Hello world without semicolon](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem77/HelloWorldWithoutSemicolon.java)
* [Autoboxing trick](https://github.com/pedrovgs/Algorithms/blob/master/src/main/java/com/github/pedrovgs/problem78/AutoBoxingTrick.java)Developed By
------------* Pedro Vicente Gómez Sánchez -
License
-------Copyright 2014 Pedro Vicente Gómez Sánchez
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.