├── .DS_Store ├── .idea ├── .gitignore ├── misc.xml ├── modules.xml ├── uiDesigner.xml └── vcs.xml ├── BitManipulation ├── AllDistinctSubsetsOfGivenSet.java ├── NoOfBitReqToChangeAtoB.java ├── Rounduptothepreviouspowerof2.java └── SieveOfEratosthenes.java ├── CONTRIBUTING.md ├── DataStructure-And-Algo.iml ├── Data_Structures ├── 9. Palindrome_Number.java ├── Counting_number_of_distinct_elements_in_an_array.cpp ├── Longest_substring_without_repeating_characters.cpp ├── Longest_substring_without_repeating_characters.java ├── longest palindromic substring.cpp ├── longest_substring_without_repeating_characters.kt └── remove_lettre_to_equalize_frequency.cpp ├── DynamicProgramming ├── Best_Time_to_buy_stock_with_fee.cpp ├── BooleanParenthesization.java ├── CoinChange.java ├── FibonacciNumberUsingBottomUpApproach.java ├── FibonacciUsingTopDown.java ├── GridUniquePathByGoogle.java ├── Knapsack.java ├── LongestCommonSubSequence.java ├── LongestIncreasingSubsequence ├── LongestPalindromicSubstring.java ├── MaxSumSubArray.java ├── MaximumLengthofPairChain.java ├── MinimumOperationsToTransformStrings.java ├── PalindromicPartitioning.java ├── PartitionToKEqualSumSubsets.java ├── RodCutting.cpp ├── Trapping-RainWater.java ├── UniquePaths.java ├── _14subsetSum.java ├── frogJump.java ├── knapsackDP.java └── sumOfNonAdjEle.java ├── Heap ├── ConnectNRopesInMinCost ├── ConnectNRopesInMinCost.java ├── Heap.java ├── Kth largest element in an array ├── Kth_Largest_Element.java ├── Merge K Sorted └── Sliding Window Maximum ├── IO ├── BufferedInputStream1.java ├── BufferedOutputStream1.java ├── ByteArrayInputStream1.java ├── ByteArrayOutputStream1.java ├── ByteOutputstream.java ├── DataStreamExample.java └── SequenceInputStream1.java ├── LinkedListPackage ├── CircularSinglyLinkedList.java ├── DoublyCircular.java ├── DoublyLinkedList.java ├── DuplicateInArray.java ├── DynamicList.java ├── MainLinkedList.java ├── MergeSort.java ├── MergeTwoSortedLinkedList.java ├── MyLinkedList.java ├── ReverseList.java ├── SinglyLinkedList.java └── middleElement_LL.java ├── LongestPalindromicSubsequence.cpp ├── Matrix ├── CircularMatrix.java ├── Matrix.java ├── MergeOverlappingSubIntervals.java ├── PascalTriangle.java ├── RotateMatrix.java ├── SearchElementInSortedMatrix.java ├── SetMatrixZero.java └── SpiralMatrix.java ├── README.md ├── SORTING AND SEARCHING ├── Binary_search.c ├── Bubble_sort.c ├── Count_sort.c ├── Heap_sort.c ├── Insertion sort list ├── Insertion_sort.c ├── Linear_search.c ├── Merge_sort.c ├── Quick_sort.c ├── Radix_sort.c ├── Selection_sort.c ├── SortingCrads.java └── readme ├── SortingAndSearching ├── .DS_Store ├── BinarySearch.java ├── BubbleSort.java ├── BucketSort.java ├── CombSort.java ├── CountSort.java ├── CyclicSort.class ├── CyclicSort.java ├── ExponentialSearch.java ├── HeapSort.java ├── InsertionSort.java ├── InterpolationSearch.java ├── JumpSearch.java ├── LinearSearch.java ├── MergeSort.java ├── MergeSortedArray.java ├── QuickSort.java ├── RadixSort.java ├── SearchAnElement.java ├── SelectionSort.java ├── ShellSort.java ├── Sort_0s_1s_2s.java ├── SublistSearch.java ├── TernarySearch.java └── Z_Algorithm.java ├── Tree ├── AVLTree.java ├── BinarySearchTree.java ├── BinaryTree.java ├── BinaryTreeImplementation.java ├── Binary_Search_Tree.java ├── LeftViewofBinaryTree.py ├── LowestCommonANcestor .java ├── LowestCommonAncestor.java ├── PairSumBST.java ├── RedBlackTree.java ├── Symmetric tree ├── Trie_Array.java └── vertical_order_traversal.cpp ├── Trie ├── Trie.java └── Trie_codestudio_ll.java ├── array ├── ArrayInsert.java ├── Array_deletion.java ├── AscendingOrder.java ├── CountEleWithStrictlySmallAndGreater.java ├── CountInversionsInArray.java ├── Count_reverse_pairs_493.java ├── CyclicallyRotate.java ├── DutchNationalFlagAlgo.java ├── Dutch_National_flag_algorithm.java ├── FIndMissingNumber.java ├── FindDuplicate.java ├── FourSum.java ├── FrequencySortArray.java ├── KadaneAlgo.java ├── KthSmallest.java ├── LargestSubArrayWith0Sum.java ├── LongestConsecutiveSequence.java ├── MajorityElement.java ├── MajorityElement2.java ├── MaxAndMin.java ├── MaxFreq.java ├── MergeArray.java ├── MergeSort.java ├── MinDistanceBtwnTwoNumbers.java ├── MinNoOfJump.java ├── MinOperationToMakeArrayAlternative.java ├── MinimalSum.java ├── MinimizeHeight.java ├── MoveNegativeNumber.java ├── NextLexicographic.java ├── NoOfSubArrayWithGivenProduct.java ├── PairOfSum.java ├── Pair_with_K_difference.java ├── Permutation_in_string.java ├── PlusOne.java ├── Pow_X_N.java ├── RecursiveArray.java ├── RemoveDuplicate2.java ├── RemovingMinNoOfMagicBeans.java ├── ReversePair.java ├── ReverseTheArray.java ├── RotateArrayByDElement2.java ├── RotateArrayByDElements.java ├── RotateArrayByK_Steps.java ├── SortAnArray.java ├── StockBuyAndSell.java ├── SubArrayWithGivenXorK.java ├── SubArraysSumEqualK.java ├── ThreeSum.java ├── Triangle ├── TripletZeroSum.java ├── TwoSum.java ├── UnionAndIntersection.java ├── UnionOfTwoArray.java ├── Valid Sudoku ├── Word Break ├── XOR_Queries_of_Array.java ├── basic │ ├── ArrayListImplement.java │ └── Pair.java ├── stars pattern │ ├── star7.java │ └── star8.java └── starsPattern │ ├── star1.java │ ├── star2.java │ ├── star3.java │ ├── star4.java │ ├── star5.java │ └── star6.java ├── cpp_codes ├── Balance_paranthesis.cpp ├── codechef even subset xor.cpp ├── disticnct_combination_repetition_allowed.cpp ├── leetcode : 78 : subset.cpp ├── leetcode-47-permutation2.cpp ├── leetcode-905-sortbyParity.cpp ├── longestIncPath.cpp ├── min_moves_to_make_equal_array.cpp ├── queue_push_pop.cpp ├── recursion │ └── sum_of_digits.cpp ├── square_root_BS.cpp ├── substring of binary.cpp └── topologicalSort.cpp ├── extra ├── Animal.java ├── Arraylist_doubt.java ├── Assertion.java ├── Bank.java ├── Bike8.java ├── IndexWhereLeftEqualRight.java ├── LambdaExp.java ├── Main.java ├── MyThread1.java ├── Portal.java ├── Problem1.java ├── RecursionQUe.java ├── RegexPractice.java ├── SecondLargest.java ├── Shape.java ├── StreamMain.java ├── SwapNodesinPairs.java ├── SwapWIthoutTemp.java ├── UserAbst.java ├── customException.java ├── input ├── inter.java ├── ioclass.java ├── isanagram.java ├── methodObject.java ├── mmt1.java ├── new1.java ├── oops.java ├── output ├── palindrome.java └── prac.java ├── graph ├── BellmanFord_Algorithm.java ├── BipartiteGraphBFS.java ├── BipartiteGraphDFS.java ├── CycleDetectionBFS.java ├── CycleDetectionDFS.java ├── CycleInDirectedGraphDFS.java ├── Graph.java ├── GraphWithList.java ├── TopologicalSortBFS.java ├── TopologicalSortDFS.java └── dijkstra_algorithm.java ├── hashing ├── HashTable.java ├── HashTableByOpenAddressing.cpp ├── MissingElementsOfaRange.cpp ├── TripletsZeroSum.java ├── TwoSumProblem.java └── UnionOfTwoArrays.java ├── out └── production │ └── DataStructure-And-Algo │ ├── .idea │ ├── .gitignore │ ├── misc.xml │ ├── modules.xml │ ├── uiDesigner.xml │ └── vcs.xml │ ├── BitManipulation │ ├── NoOfBitReqToChangeAtoB.class │ └── abc.class │ ├── DataStructure-And-Algo.iml │ ├── DynamicProgramming │ ├── FibonacciNumberUsingBottomUpApproach.class │ ├── FibonacciUsingTopDown.class │ ├── GridUniquePathByGoogle.class │ ├── Knapsack.class │ ├── LongestCommonSubSequence.class │ ├── MaxSumSubArray.class │ └── MinimumOperationsToTransformStrings.class │ ├── Heap │ ├── ConnectNRopesInMinCost │ ├── ConnectNRopesInMinCost.class │ ├── Heap.class │ └── Kth_Largest_Element.class │ ├── IO │ ├── BufferedInputStream1.class │ ├── BufferedOutputStream1.class │ ├── ByteArrayInputStream1.class │ ├── ByteArrayOutputStream1.class │ ├── ByteOutputstream.class │ ├── DataStreamExample.class │ └── SequenceInputStream1.class │ ├── LinkedListPackage │ ├── Cell.class │ ├── CircularSinglyLinkedList$ListNode.class │ ├── CircularSinglyLinkedList.class │ ├── DoublyLinkedList$ListNode.class │ ├── DoublyLinkedList.class │ ├── DuplicateInArray.class │ ├── DynamicList.class │ ├── List.class │ ├── MainLinkedList.class │ ├── MyLinkedList$Node.class │ ├── MyLinkedList.class │ ├── ReverseList$Node.class │ ├── ReverseList.class │ ├── SinglyLinkedList$ListNode.class │ └── SinglyLinkedList.class │ ├── Matrix │ ├── CelulaMatriz.class │ ├── CircularMatrix.class │ ├── Matrix.class │ ├── Matriz.class │ ├── MergeOverlappingSubIntervals.class │ ├── PascalTriangle.class │ ├── RotateMatrix.class │ ├── SearchElementInSortedMatrix.class │ └── SetMatrixZero.class │ ├── README.md │ ├── RecursiveFactorial.class │ ├── SortingAndSearching │ ├── BinarySearch.class │ ├── BubbleSort.class │ ├── BucketSort.class │ ├── CombSort.class │ ├── CountSort.class │ ├── ExponentialSearch.class │ ├── HeapSort.class │ ├── InsertionSort.class │ ├── InterpolationSearch.class │ ├── JumpSearch.class │ ├── MergeSort.class │ ├── MergeSortedArray.class │ ├── QuickSort.class │ ├── RadixSort.class │ ├── SearchAnElement.class │ ├── SelectionSort.class │ ├── ShellSort.class │ ├── Sort_0s_1s_2s.class │ ├── SublistSearch$Node.class │ └── SublistSearch.class │ ├── Tree │ ├── AVLTree.class │ ├── AVL_T$Node.class │ ├── AVL_T.class │ ├── BinarySearchTree$treeNode.class │ ├── BinarySearchTree.class │ ├── BinaryTree.class │ ├── TreeNode.class │ ├── Trie_Ar$Node.class │ ├── Trie_Ar.class │ └── Tries_Array.class │ ├── Trie │ ├── Trie$TrieNode.class │ ├── Trie.class │ ├── TrieNode.class │ ├── Trie_codestudio_ll$Trie.class │ └── Trie_codestudio_ll.class │ ├── array │ ├── ArrayInsert.class │ ├── Array_deletion.class │ ├── AscendingOrder.class │ ├── CountEleWithStrictlySmallAndGreater.class │ ├── CountInversionsInArray.class │ ├── Count_reverse_pairs_493.class │ ├── CyclicallyRotate.class │ ├── DutchNationalFlagAlgo.class │ ├── FIndMissingNumber.class │ ├── FindDuplicate.class │ ├── FourSum.class │ ├── FrequencySortArray.class │ ├── KadaneAlgo.class │ ├── KthSmallest.class │ ├── LargestSubArrayWith0Sum.class │ ├── LongestConsecutiveSequence.class │ ├── MajorityElement.class │ ├── MajorityElement2.class │ ├── MaxAndMin$Pair.class │ ├── MaxAndMin.class │ ├── MaxFreq.class │ ├── MergeArray.class │ ├── MergeSort.class │ ├── MinDistanceBtwnTwoNumbers.class │ ├── MinNoOfJump.class │ ├── MinOperationToMakeArrayAlternative.class │ ├── MinimalSum.class │ ├── MinimizeHeight.class │ ├── MoveNegativeNumber.class │ ├── NextLexicographic.class │ ├── NoOfSubArrayWithGivenProduct.class │ ├── PairOfSum.class │ ├── Pair_with_K_difference.class │ ├── Permutation_in_string.class │ ├── PlusOne.class │ ├── Pow_X_N.class │ ├── Practical.class │ ├── RemoveDuplicate2.class │ ├── RemovingMinNoOfMagicBeans.class │ ├── ReversePair.class │ ├── ReverseTheArray.class │ ├── RotateArrayByDElement2.class │ ├── RotateArrayByDElements$RotateArray.class │ ├── RotateArrayByDElements.class │ ├── RotateArrayByK_Steps.class │ ├── StockBuyAndSell.class │ ├── SubArrayWithGivenXorK.class │ ├── SubArraysSumEqualK.class │ ├── ThreeSum.class │ ├── TripletZeroSum.class │ ├── TwoSum.class │ ├── UnionAndIntersection.class │ ├── UnionOfTwoArray.class │ ├── XOR_Queries_of_Array.class │ ├── basic │ │ ├── ArrayListImplement.class │ │ └── Pair.class │ └── starsPattern │ │ ├── star1.class │ │ ├── star2.class │ │ ├── star3.class │ │ ├── star4.class │ │ ├── star5.class │ │ └── star6.class │ ├── extra │ ├── Animal.class │ ├── Arraylist_doubt.class │ ├── Assertion.class │ ├── BabyDog.class │ ├── Bank.class │ ├── Bike8.class │ ├── Dog.class │ ├── IndexWhereLeftEqualRight.class │ ├── LambdaExp$Add.class │ ├── LambdaExp$Display.class │ ├── LambdaExp.class │ ├── Main.class │ ├── MyThread1.class │ ├── Portal.class │ ├── Problem1.class │ ├── RecursionQUe.class │ ├── RegexPractice.class │ ├── SecondLargest.class │ ├── StreamMain.class │ ├── SwapWIthoutTemp.class │ ├── TestInheritance2.class │ ├── customException.class │ ├── input │ ├── ioclass.class │ ├── isanagram.class │ ├── methodObject.class │ ├── mmt1.class │ ├── new1.class │ ├── oops.class │ ├── output │ ├── palindrome.class │ └── prac.class │ ├── graph │ ├── BellmanFord_Algorithm$Edge.class │ ├── BellmanFord_Algorithm.class │ ├── BipartiteGraphBFS.class │ ├── BipartiteGraphDFS.class │ ├── CycleDetectionBFS$Node.class │ ├── CycleDetectionBFS.class │ ├── CycleDetectionDFS$Node.class │ ├── CycleDetectionDFS.class │ ├── CycleInDirectedGraphDFS.class │ ├── Graph.class │ ├── GraphWithList.class │ ├── ShortestPath.class │ ├── TopologicalSortBFS.class │ └── TopologicalSortDFS.class │ ├── hashing │ ├── HashTable$HashNode.class │ ├── HashTable.class │ ├── TripletsZeroSum.class │ ├── TwoSumProblem.class │ └── UnionOfTwoArrays.class │ ├── queue │ ├── CQueue.class │ ├── Deque.class │ ├── Examination.class │ ├── Examination_queue.class │ ├── MaxPQ.class │ ├── MyQueue$QueueNode.class │ ├── MyQueue.class │ ├── PQueue.class │ └── Priorities.class │ ├── recursion │ ├── AllXtoRightSide.class │ ├── CountPairs.class │ ├── FirstLastOccurrence.class │ ├── GridUniquePathGoogleQue.class │ ├── One.class │ ├── RecursivePalindrome.class │ ├── RemoveDuplicate.class │ ├── ReverseString.class │ ├── SortedOrNot.class │ ├── SubsetsOfArray.class │ └── TowerOfHanoi.class │ └── stack │ ├── MyStack$stackNode.class │ ├── MyStack.class │ ├── ReverseString.class │ ├── StackArray.class │ └── stackArrayapp.class ├── queue ├── CQueue.java ├── Deque.java ├── Examination_queue.java ├── MaxPQ.java ├── MyQueue.java ├── PQueue.java └── QueuesUsingTwoStack.cpp ├── recursion ├── AllXtoRightSide.java ├── CountPairs.java ├── FirstLastOccurrence.java ├── GridUniquePathGoogleQue.java ├── JosephusProblem.cpp ├── NQueens.java ├── One.java ├── Permutation_of_String.java ├── ProductOfNTerms.java ├── RecursiveFactorial.java ├── RecursiveFibonacci.java ├── RecursivePalindrome.java ├── RemoveDuplicate.java ├── ReverseString.java ├── SortedOrNot.java ├── SubsetsOfArray.java ├── SudokuSolver.cpp ├── SumOfNterms.java ├── TowerOfHanoi.java └── findCombination.cpp └── stack ├── LargestRectangleArea.java ├── MyStack.java ├── Palindrome Stack String.c ├── ReverseString.java ├── double_stack.c ├── infix to prefix.cpp ├── multiple_paranthrsis_using_stacks.c ├── parantheis_matching_using_stacks.c ├── stackArrayapp.java ├── stack_using_Linked_list.c └── stacks_operations.c /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/.DS_Store -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BitManipulation/NoOfBitReqToChangeAtoB.java: -------------------------------------------------------------------------------- 1 | package BitManipulation; 2 | // find the number of bits required to change to convent A to B 3 | 4 | public class NoOfBitReqToChangeAtoB { 5 | 6 | // count number of setbits in the result of a xor b 7 | public static int countSetBits(int n) { 8 | int count = 0; 9 | while (n != 0) { 10 | count++; 11 | n = n & (n - 1); 12 | } 13 | return count; 14 | } 15 | 16 | // Function that return count of 17 | // flipped number 18 | public static int FlippedCount(int a, int b) { 19 | // Return count of set bits in 20 | // a XOR b 21 | return countSetBits(a ^ b); 22 | } 23 | 24 | public static void main(String[] args) { 25 | int a = 0, b = 15; // in binary form a = 0 is 0000 and b = 15 is 1111 26 | 27 | System.out.println(FlippedCount(a, b)); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /BitManipulation/Rounduptothepreviouspowerof2.java: -------------------------------------------------------------------------------- 1 | package BitManipulation; 2 | 3 | class Main 4 | { 5 | // Compute a power of two less than or equal to `n` 6 | public static int findPreviousPowerOf2(int n) 7 | { 8 | // initialize result by 1 9 | int k = 1; 10 | 11 | // double `k` and divide `n` in half till it becomes 0 12 | while ((n >>= 1) != 0) { 13 | k = k << 1; // double `k` 14 | } 15 | 16 | return k; 17 | } 18 | 19 | public static void main(String[] args) 20 | { 21 | int n = 127; 22 | 23 | System.out.println("The previous power of 2 is " + findPreviousPowerOf2(n)); 24 | } 25 | } -------------------------------------------------------------------------------- /BitManipulation/SieveOfEratosthenes.java: -------------------------------------------------------------------------------- 1 | package BitManipulation; 2 | import java.util.Scanner; 3 | 4 | // Java program to print all primes smaller than or equal to 5 | // n using Sieve of Eratosthenes 6 | class SieveOfEratosthenes 7 | { 8 | void sieveOfEratosthenes(int n) 9 | { 10 | // Create a boolean array "prime[0..n]" and initialize 11 | // all entries it as true. A value in prime[i] will 12 | // finally be false if i is Not a prime, else true. 13 | boolean prime[] = new boolean[n+1]; 14 | for(int i=0;i<=n;i++) 15 | prime[i] = true; 16 | 17 | for(int p = 2; p*p <=n; p++) 18 | { 19 | // If prime[p] is not changed, then it is a prime 20 | if(prime[p] == true) 21 | { 22 | // Update all multiples of p 23 | for(int i = p*p; i <= n; i += p) 24 | prime[i] = false; 25 | } 26 | } 27 | 28 | // Print all prime numbers 29 | for(int i = 2; i <= n; i++) 30 | { 31 | if(prime[i] == true) 32 | System.out.print(i + " "); 33 | } 34 | } 35 | public static void main(String args[]) 36 | { 37 | try (Scanner sc = new Scanner(System.in)) { 38 | int n = sc.nextInt(); 39 | System.out.print("Following are the prime numbers "); 40 | System.out.println("Smaller than or equal to " + n); 41 | SieveOfEratosthenes g = new SieveOfEratosthenes(); 42 | g.sieveOfEratosthenes(n); 43 | } 44 | } 45 | } 46 | 47 | // This code has been contributed by Amit Khandelwal. 48 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Welcome to GitHub docs contributing guide 2 | 3 | Thank you for investing your time in contributing to our project! 4 | 5 | ## New contributor guide 6 | You can contribute any data structure problem. Give you file an appropriate name and put it in it's respective folder. 7 | **ONLY** new files will be entertained as an pull request. **DO NOT** edit any existing file (Changing just some lines in any existing file will be marked as Invalid or spam.) 8 | 9 | ## Getting started 10 | First of all, fork this project. 11 | After that, a clone of this project will show in your repository. 12 | Clone your project into your local machine using ```git clone``` command. 13 | After adding new files and successfully push the code in your github repo, generate a pull request from your forked repository. 14 | 15 | ## Issues 16 | #### Create a new issue if you want to edit any existing file. Other wise you can directly open an PR (pull request). 17 | 18 | **When you're finished with the changes, create a pull request, also known as a PR**. 19 | 20 | Fill the "Ready for review" template so that we can review your PR. This template helps reviewers understand your changes as well as the purpose of your pull request. 21 | Don't forget to link PR to issue if you are solving one. 22 | 23 | **After all of this, just wait for 1-2 days** 24 | ## Your PR is merged! 25 | ### Congratulations 🎉🎉✨. 26 | 27 | -------------------------------------------------------------------------------- /DataStructure-And-Algo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Data_Structures/9. Palindrome_Number.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | /* 9. Palindrome Number 4 | Easy 5 | 6 | Given an integer x, return true if x is palindrome integer. 7 | 8 | An integer is a palindrome when it reads the same backward as forward. 9 | 10 | For example, 121 is a palindrome while 123 is not. 11 | 12 | 13 | 14 | Example 1: 15 | 16 | Input: x = 121 17 | Output: true 18 | Explanation: 121 reads as 121 from left to right and from right to left. 19 | 20 | Example 2: 21 | 22 | Input: x = -121 23 | Output: false 24 | Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. 25 | 26 | Example 3: 27 | 28 | Input: x = 10 29 | Output: false 30 | Explanation: Reads 01 from right to left. Therefore it is not a palindrome. 31 | 32 | 33 | 34 | Constraints: 35 | 36 | -231 <= x <= 231 - 1 37 | 38 | */ 39 | 40 | class Solution { 41 | public boolean isPalindrome(int x) { 42 | 43 | 44 | int sum = 0; 45 | int rem; 46 | 47 | int temp = x; 48 | 49 | while (x > 0) { 50 | rem = x % 10; 51 | sum = (sum * 10) + rem; 52 | x /= 10; 53 | } 54 | 55 | if (temp == sum) 56 | return true; 57 | else 58 | return false; 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Data_Structures/longest palindromic substring.cpp: -------------------------------------------------------------------------------- 1 | //problem==5.longest palindromic substring 2 | 3 | class Solution { 4 | public: 5 | string longestPalindrome(string s) { 6 | if (s.length() <= 1) return s; 7 | 8 | for (int i = 0; i < s.length(); i++) { 9 | checkPalindrome(i-1, i+1, s); 10 | checkPalindrome(i-1, i, s); 11 | } 12 | return string(&s[mA], &s[mB+1]); 13 | } 14 | 15 | void checkPalindrome(int a, int b, string s) { 16 | while (b < s.length() && a >= 0 && s[b] == s[a]) { 17 | if (mB - mA + 1 < b-a+1) { 18 | mA = a; mB = b; 19 | } 20 | a--; b++; 21 | } 22 | } 23 | 24 | private: 25 | int mA; 26 | int mB; 27 | }; 28 | -------------------------------------------------------------------------------- /Data_Structures/longest_substring_without_repeating_characters.kt: -------------------------------------------------------------------------------- 1 | /* Given a string s, find the length of the longest substring without repeating characters. 2 | 3 | 4 | 5 | Example 1: 6 | 7 | Input: s = "abcabcbb" 8 | Output: 3 9 | Explanation: The answer is "abc", with the length of 3. 10 | Example 2: 11 | 12 | Input: s = "bbbbb" 13 | Output: 1 14 | Explanation: The answer is "b", with the length of 1. 15 | Example 3: 16 | 17 | Input: s = "pwwkew" 18 | Output: 3 19 | Explanation: The answer is "wke", with the length of 3. 20 | Notice that the answer must be a substring, "pwke" is a subsequence and not a substring. */ 21 | 22 | 23 | class Solution { 24 | fun lengthOfLongestSubstring(s: String): Int { 25 | val mm = HashMap() 26 | var ans = 0 27 | var last = -1 28 | for (i in s.indices) { 29 | last = Math.max(last, mm.getOrElse(s[i], {-1})) 30 | ans = Math.max(ans, i - last) 31 | mm[s[i]] = i 32 | } 33 | return ans 34 | } 35 | } -------------------------------------------------------------------------------- /DynamicProgramming/CoinChange.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | Class CoinChange{ 3 | public static void main(String[] args){ 4 | Scanner sc = new Scanner(System.in); 5 | int amount=sc.nextInt(); 6 | int n=sc.nextInt(); 7 | int[] coins=new int[n]; 8 | for(int i=0;i run i 0 ,1,2,3 21 | 22 | // 10c3 = 10x9x8/ 1x2x3 23 | 24 | // n-r+i --> 10 - 3 + 1 or 2 or 3 / 1 or 2 or 3 25 | for (int i = 1; i<= r; i++){ 26 | res = res * (N - r + i)/ i; 27 | } 28 | return (int) res; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /DynamicProgramming/LongestIncreasingSubsequence: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | Class LIS{ 3 | public static void main(String[] args){ 4 | Scanner sc = new Scanner(System.in); 5 | int n = sc.nextInt(); 6 | int[] nums = new int[n]; 7 | for(int i=0;i a[0] - b[0]); 7 | int n = pairs.length; 8 | int[] dp = new int[n]; 9 | dp[0]=1; 10 | int omax=1; 11 | for(int i=1;ipairs[j][1] && dp[j]>max){ 15 | max=dp[j]; 16 | } 17 | } 18 | dp[i]=1+max; 19 | if(dp[i]>omax)omax=dp[i]; 20 | } 21 | return omax; 22 | } 23 | public static void main(String []args){ 24 | int [][] pairs = new int [][]{{1,2},{2,3},{3,4}}; 25 | System.out.print(findLongestChain(pairs)); 26 | } 27 | } -------------------------------------------------------------------------------- /DynamicProgramming/RodCutting.cpp: -------------------------------------------------------------------------------- 1 | // Java program for above approach 2 | import java.io.*; 3 | 4 | class GFG { 5 | 6 | public static int cutRod(int prices[], int n) 7 | { 8 | 9 | int mat[][] = new int[n + 1][n + 1]; 10 | for (int i = 0; i <= n; i++) { 11 | for (int j = 0; j <= n; j++) { 12 | if (i == 0 || j == 0) { 13 | mat[i][j] = 0; 14 | } 15 | else { 16 | if (i == 1) { 17 | mat[i][j] = j * prices[i - 1]; 18 | } 19 | else { 20 | if (i > j) { 21 | mat[i][j] = mat[i - 1][j]; 22 | } 23 | else { 24 | mat[i][j] = Math.max( 25 | prices[i - 1] 26 | + mat[i][j - i], 27 | mat[i - 1][j]); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | 34 | return mat[n][n]; 35 | } 36 | public static void main(String[] args) 37 | { 38 | 39 | int prices[] 40 | = new int[] { 1, 5, 8, 9, 10, 17, 17, 20 }; 41 | int n = prices.length; 42 | 43 | System.out.println("Maximum obtained value is " 44 | + cutRod(prices, n)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /DynamicProgramming/Trapping-RainWater.java: -------------------------------------------------------------------------------- 1 | 2 | 3 | class Test { 4 | static int arr[]= new int[] { 0, 1, 0, 2, 1, 0, 1, 3, 2, 1, 2, 1 }; 5 | 6 | static int findWater(int n) 7 | { 8 | int left[] = new int[n]; 9 | 10 | int right[] = new int[n]; 11 | int water = 0; 12 | 13 | left[0] = arr[0]; 14 | for (int i = 1; i < n; i++) 15 | left[i] = Math.max(left[i - 1], arr[i]); 16 | 17 | 18 | right[n - 1] = arr[n - 1]; 19 | for (int i = n - 2; i >= 0; i--) 20 | right[i] = Math.max(right[i + 1], arr[i]); 21 | 22 | 23 | for (int i = 0; i < n; i++) 24 | water += Math.min(left[i], right[i]) - arr[i]; 25 | 26 | return water; 27 | } 28 | public static void main(String[] args) 29 | { 30 | 31 | System.out.println(findWater(arr.length)); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /DynamicProgramming/UniquePaths.java: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int uniquePaths(int m, int n) { 3 | 4 | int[][] cache = new int[m][n]; 5 | for(int row[]: cache) { 6 | Arrays.fill(row, -1); 7 | } 8 | 9 | return sol(m - 1, n - 1, cache); 10 | } 11 | 12 | private int sol(int r, int c, int[][] cache) { 13 | 14 | if(r == 0 && c == 0) { 15 | return 1; 16 | } 17 | 18 | if(r < 0 || c < 0) { 19 | return 0; 20 | } 21 | 22 | if(cache[r][c] != -1) { 23 | return cache[r][c]; 24 | } 25 | 26 | int up = sol(r - 1, c, cache); 27 | int left = sol(r, c - 1, cache); 28 | 29 | return cache[r][c] = up + left; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Heap/Kth largest element in an array: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public int findKthLargest(int[] nums, int k) { 3 | // Initialize an empty list 4 | PriorityQueue kNumbersMinHeap = new PriorityQueue((n1, n2) -> n1 - n2); 5 | 6 | // Add first k elements to the list 7 | for (int i = 0; i < k; i++) { 8 | kNumbersMinHeap.add(nums[i]); 9 | } 10 | 11 | // Loop through the remaining elements in the 'nums' array 12 | for (int i = k; i < nums.length; i++) { 13 | // Compare the current element with the minimum 14 | // element (root) of the min-heap 15 | if (nums[i] > kNumbersMinHeap.peek()) { 16 | // Remove the smallest element 17 | kNumbersMinHeap.poll(); 18 | // Add the current element 19 | kNumbersMinHeap.add(nums[i]); 20 | } 21 | } 22 | 23 | // The root of the heap has the Kth largest element 24 | return kNumbersMinHeap.peek(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Heap/Kth_Largest_Element.java: -------------------------------------------------------------------------------- 1 | package Heap; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Arrays; 5 | import java.util.Collections; 6 | 7 | class Kth_Largest_Element { 8 | public static void kLargest(Integer[] arr, int k) { 9 | Arrays.sort(arr, Collections.reverseOrder()); 10 | 11 | System.out.print(arr[k-1] + " "); 12 | } 13 | 14 | public static ArrayList kLargest(int[] arr, int k) { 15 | Integer[] obj_array = Arrays.stream(arr).boxed().toArray(Integer[]::new); 16 | Arrays.sort(obj_array, Collections.reverseOrder()); 17 | ArrayList list = new ArrayList<>(k); 18 | 19 | for (int i = 0; i < k; i++) 20 | list.add(obj_array[i]); 21 | 22 | return list; 23 | } 24 | 25 | public static void main(String[] args) { 26 | Integer arr[] = new Integer[]{1, 23, 12, 9, 30, 2, 50}; 27 | int k = 3; 28 | kLargest(arr, k); 29 | 30 | int[] prim_array = {1, 23, 12, 9, 30, 2, 50}; 31 | System.out.print(kLargest(prim_array, k)); 32 | } 33 | } -------------------------------------------------------------------------------- /Heap/Merge K Sorted: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public ListNode mergeKLists(ListNode[] lists) { 3 | PriorityQueue heap = new PriorityQueue<>((a, b) -> a.val - b.val); 4 | 5 | for(ListNode node : lists){ 6 | if(node != null) 7 | heap.add(node); 8 | } 9 | 10 | ListNode head = new ListNode(0); 11 | ListNode current = head; 12 | 13 | while(!heap.isEmpty()){ 14 | ListNode node = heap.poll(); 15 | current.next = node; 16 | current = current.next; 17 | 18 | if (node.next != null) { 19 | heap.add(node.next); 20 | } 21 | } 22 | 23 | return head.next; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /IO/BufferedInputStream1.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.FileInputStream; 5 | 6 | public class BufferedInputStream1 { 7 | public static void main(String args[]) { 8 | try { 9 | FileInputStream fin = new FileInputStream("/home/sourav/Desktop/output.txt"); 10 | BufferedInputStream bin = new BufferedInputStream(fin); 11 | int i; 12 | while ((i = bin.read()) != -1) { 13 | System.out.print((char) i); 14 | } 15 | bin.close(); 16 | fin.close(); 17 | } catch (Exception e) { 18 | System.out.println(e); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IO/BufferedOutputStream1.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.BufferedOutputStream; 4 | import java.io.FileOutputStream; 5 | 6 | public class BufferedOutputStream1 { 7 | public static void main(String args[]) throws Exception { 8 | FileOutputStream fout = new FileOutputStream("/home/sourav/Desktop/output.txt"); 9 | BufferedOutputStream bout = new BufferedOutputStream(fout); 10 | String s = "Welcome to sourav's world."; 11 | byte b[] = s.getBytes(); 12 | bout.write(b); 13 | bout.flush(); 14 | bout.close(); 15 | fout.close(); 16 | System.out.println("success"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IO/ByteArrayInputStream1.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.IOException; 5 | 6 | public class ByteArrayInputStream1 { 7 | public static void main(String[] args) throws IOException { 8 | byte[] buf = new byte[128]; 9 | for (byte i = 0; i < 127; i++) { 10 | buf[i] = i; 11 | } 12 | 13 | // Create the new byte array input stream 14 | ByteArrayInputStream byt = new ByteArrayInputStream(buf); 15 | int k = 0; 16 | while ((k = byt.read()) != -1) { 17 | //Conversion of a byte into character 18 | char ch = (char) k; 19 | System.out.println("ASCII value of Character is:" + k + "; Special character is: " + ch); 20 | } 21 | } 22 | } 23 | 24 | -------------------------------------------------------------------------------- /IO/ByteArrayOutputStream1.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.ByteArrayOutputStream; 4 | import java.io.FileOutputStream; 5 | 6 | public class ByteArrayOutputStream1 { 7 | public static void main(String args[]) throws Exception { 8 | FileOutputStream fout1 = new FileOutputStream("D:\\f1.txt"); 9 | FileOutputStream fout2 = new FileOutputStream("D:\\f2.txt"); 10 | 11 | ByteArrayOutputStream bout = new ByteArrayOutputStream(); 12 | bout.write(65); 13 | bout.writeTo(fout1); 14 | bout.writeTo(fout2); 15 | 16 | bout.flush(); 17 | bout.close();//has no effect 18 | System.out.println("Success..."); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /IO/ByteOutputstream.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.FileOutputStream; 4 | import java.io.IOException; 5 | 6 | public class ByteOutputstream { 7 | public static void main(String[] args) throws IOException { 8 | try { 9 | FileOutputStream fout = new FileOutputStream("/home/sourav/Desktop/output.txt"); 10 | String s = "my name is sourav \n"; 11 | byte b[] = s.getBytes();// converting string into byte array 12 | System.out.println("Byte value is : "); 13 | fout.write(83); 14 | fout.write(b); 15 | fout.close(); 16 | 17 | } catch (Exception e) { 18 | e.printStackTrace(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /IO/DataStreamExample.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.FileInputStream; 4 | 5 | public class DataStreamExample { 6 | public static void main(String args[]) { 7 | try { 8 | FileInputStream fin = new FileInputStream("/home/sourav/Desktop/output.txt"); 9 | int i = 0; 10 | while ((i = fin.read()) != -1) { 11 | System.out.print((char) i); 12 | } 13 | fin.close(); 14 | } catch (Exception e) { 15 | System.out.println(e); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /IO/SequenceInputStream1.java: -------------------------------------------------------------------------------- 1 | package IO; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileOutputStream; 5 | import java.io.SequenceInputStream; 6 | 7 | public class SequenceInputStream1 { 8 | public static void main(String args[]) throws Exception { 9 | FileOutputStream out1 = new FileOutputStream("/home/sourav/Desktop/testin.txt"); 10 | FileOutputStream out2 = new FileOutputStream("/home/sourav/Desktop/testout.txt"); 11 | FileInputStream input1 = new FileInputStream("/home/sourav/Desktop/testin.txt"); 12 | FileInputStream input2 = new FileInputStream("/home/sourav/Desktop/testout.txt"); 13 | 14 | FileOutputStream fout = new FileOutputStream("/home/sourav/Desktop/testout2.txt"); 15 | 16 | 17 | String out11 = "this is the first file that is created by me."; 18 | String out22 = "I will change the game. sooon"; 19 | byte b1[] = out11.getBytes(); 20 | byte b2[] = out22.getBytes(); 21 | out1.write(b1); 22 | out2.write(b2); 23 | SequenceInputStream inst = new SequenceInputStream(input1, input2); 24 | int j; 25 | while ((j = inst.read()) != -1) { 26 | System.out.print((char) j); 27 | fout.write((char) j); 28 | } 29 | inst.close(); 30 | input1.close(); 31 | input2.close(); 32 | fout.close(); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LinkedListPackage/DuplicateInArray.java: -------------------------------------------------------------------------------- 1 | package LinkedListPackage; 2 | 3 | public class DuplicateInArray { 4 | public static void main(String[] args) { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /LinkedListPackage/MainLinkedList.java: -------------------------------------------------------------------------------- 1 | package LinkedListPackage; 2 | 3 | public class MainLinkedList { 4 | public static void main(String[] args) { 5 | MyLinkedList ll = new MyLinkedList<>(); 6 | ll.add(3); 7 | ll.add(8); 8 | ll.add(6); 9 | ll.add(13); 10 | ll.addFirst(9); 11 | ll.addFirst(2); 12 | ll.deleteByKey(6); 13 | 14 | ll.print(); 15 | ll.getFirst(); 16 | ll.contains(8); 17 | 18 | ll.clearAll(); 19 | ll.add(5); 20 | ll.print(); 21 | // LinkedList linkedList = new LinkedList<>(); 22 | // linkedList.add(1); 23 | // linkedList.add(2); 24 | // linkedList.add(3); 25 | // linkedList.add(4); 26 | // System.out.println(linkedList.getLast()); 27 | // System.out.println(linkedList.lastIndexOf(2)); 28 | // int s = linkedList.size(); 29 | //// linkedList.addFirst(); 30 | // System.out.println(s); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /LinkedListPackage/middleElement_LL.java: -------------------------------------------------------------------------------- 1 | class Node 2 | { 3 | int num; 4 | Node next; 5 | // constructor of the class Node 6 | Node(int n) 7 | { 8 | this.num = n; 9 | this.next = null; 10 | } 11 | } 12 | public class middleElement_LL 13 | { 14 | public void findNode(Node n) 15 | { 16 | if(n == null) 17 | { 18 | return; 19 | } 20 | Node slow = n; 21 | Node fast = n; 22 | while(fast != null && fast.next != null) 23 | { 24 | // fast pointer is taking two steps at a time 25 | fast = fast.next.next; 26 | // slow pointer is taking one step at a time 27 | slow = slow.next; 28 | } 29 | System.out.println("The middle node of the linked list is: " + slow.num); 30 | } 31 | // main method 32 | public static void main(String argvs[]) 33 | { 34 | // head node of the linked list 35 | Node h = new Node(13); 36 | // remaining node of the linked list 37 | h.next = new Node(17); 38 | h.next.next = new Node(90); 39 | h.next.next.next = new Node(76); 40 | h.next.next.next.next = new Node(45); 41 | h.next.next.next.next.next = new Node(32); 42 | h.next.next.next.next.next.next = new Node(10); 43 | // creating an object of the class middleElement_LL 44 | middleElement_LL obj = new middleElement_LL(); 45 | // invoking the method findNode() 46 | obj.findNode(h); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /LongestPalindromicSubsequence.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int findLongestPalindrome(string X, int i, int j) 6 | { 7 | // Base condition 8 | if (i > j) { 9 | return 0; 10 | } 11 | 12 | if (i == j) { 13 | return 1; 14 | } 15 | 16 | if (X[i] == X[j]) 17 | { 18 | 19 | return findLongestPalindrome(X, i + 1, j - 1) + 2; 20 | } 21 | 22 | 23 | 24 | 25 | return max(findLongestPalindrome(X, i, j - 1), findLongestPalindrome(X, i + 1, j)); 26 | } 27 | 28 | int main() 29 | { 30 | string X = "ABBDCACB"; 31 | int n = X.length(); 32 | 33 | cout << "The length of the longest palindromic subsequence is " 34 | << findLongestPalindrome(X, 0, n - 1); 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Matrix/CircularMatrix.java: -------------------------------------------------------------------------------- 1 | package Matrix; 2 | 3 | class CircularMatrix { 4 | 5 | static int MAX = 100; 6 | 7 | static void spiralFill(int m, int n, int a[][]) { 8 | int val = 1; 9 | 10 | int k = 0, l = 0; 11 | while (k < m && l < n) { 12 | // rows */ 13 | for (int i = l; i < n; ++i) { 14 | a[k][i] = val++; 15 | } 16 | 17 | k++; 18 | 19 | for (int i = k; i < m; ++i) { 20 | a[i][n - 1] = val++; 21 | } 22 | n--; 23 | 24 | if (k < m) { 25 | for (int i = n - 1; i >= l; --i) { 26 | a[m - 1][i] = val++; 27 | } 28 | m--; 29 | } 30 | 31 | if (l < n) { 32 | for (int i = m - 1; i >= k; --i) { 33 | a[i][l] = val++; 34 | } 35 | l++; 36 | } 37 | } 38 | } 39 | 40 | public static void main(String[] args) { 41 | int m = 4, n = 4; 42 | int a[][] = new int[MAX][MAX]; 43 | spiralFill(m, n, a); 44 | for (int i = 0; i < m; i++) { 45 | for (int j = 0; j < n; j++) { 46 | System.out.print(a[i][j] + " "); 47 | } 48 | System.out.println(""); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /Matrix/SearchElementInSortedMatrix.java: -------------------------------------------------------------------------------- 1 | package Matrix; 2 | 3 | public class SearchElementInSortedMatrix { 4 | public static void main(String[] args) { 5 | int[][] arr = { 6 | {10, 20, 30, 40}, 7 | {15, 25, 35, 45}, 8 | {27, 29, 37, 48}, 9 | {32, 33, 39, 50} 10 | }; 11 | int n = 4; 12 | int x = 27; 13 | search(arr, n, x); 14 | } 15 | 16 | private static void search(int[][] arr, int n, int x) { 17 | int i = 0; 18 | int j = n - 1; // set index for top right element 19 | while (i < n && j >= 0) { 20 | if (arr[i][j] == x) { 21 | System.out.println("Found at " + i + ", " + j); 22 | return; 23 | } 24 | if (arr[i][j] > x) { 25 | j--; 26 | } else { // if arr[i][j] < x 27 | i++; 28 | } 29 | } 30 | System.out.println("Element not found"); 31 | 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /SORTING AND SEARCHING/Binary_search.c: -------------------------------------------------------------------------------- 1 | // C program to implement recursive Binary Search 2 | #include 3 | 4 | // A recursive binary search function. It returns 5 | // location of x in given array arr[l..r] is present, 6 | // otherwise -1 7 | int binarySearch(int arr[], int l, int r, int x) 8 | { 9 | if (r >= l) { 10 | int mid = l + (r - l) / 2; 11 | 12 | // If the element is present at the middle 13 | // itself 14 | if (arr[mid] == x) 15 | return mid; 16 | 17 | // If element is smaller than mid, then 18 | // it can only be present in left subarray 19 | if (arr[mid] > x) 20 | return binarySearch(arr, l, mid - 1, x); 21 | 22 | // Else the element can only be present 23 | // in right subarray 24 | return binarySearch(arr, mid + 1, r, x); 25 | } 26 | return -1; 27 | } 28 | 29 | int main(void) 30 | { 31 | int i, n, x; 32 | printf("Enter the number of elements in the array : "); 33 | scanf("%d",&n); 34 | int arr[n]; 35 | printf("Enter the elements in the array : "); 36 | for(i = 0;i 4 | 5 | void swap(int* xp, int* yp)// function to swap elements 6 | { 7 | int temp = *xp; 8 | *xp = *yp; 9 | *yp = temp; 10 | } 11 | 12 | //Implementation of bubble sort 13 | void bubbleSort(int arr[], int n) 14 | { 15 | int i, j; 16 | for (i = 0; i < n - 1; i++){ 17 | for (j = 0; j < n - i - 1; j++){ 18 | if (arr[j] > arr[j + 1]) 19 | swap(&arr[j], &arr[j + 1]); 20 | } 21 | } 22 | } 23 | 24 | /* Function to print an array */ 25 | void printArray(int arr[], int size) 26 | { 27 | int i; 28 | for (i = 0; i < size; i++) 29 | printf("%d ", arr[i]); 30 | printf("\n"); 31 | } 32 | 33 | // Driver program to test above functions 34 | int main() 35 | { 36 | 37 | int i, n; 38 | printf("Enter the number of elements in the array : "); 39 | scanf("%d",&n); 40 | int arr[n]; 41 | printf("Enter the elements in the array : "); 42 | for(i = 0;i 3 | #include 4 | 5 | /* Function to sort an array using insertion sort*/ 6 | 7 | void insertionSort(int arr[], int n) 8 | { 9 | int i, key, j; 10 | for (i = 1; i < n; i++) { 11 | key = arr[i]; 12 | j = i - 1; 13 | 14 | /* Move elements of arr[0..i-1], that are 15 | greater than key, to one position ahead 16 | of their current position */ 17 | while (j >= 0 && arr[j] > key) { 18 | arr[j + 1] = arr[j]; 19 | j = j - 1; 20 | } 21 | arr[j + 1] = key; 22 | } 23 | } 24 | /*Function to Print Array*/ 25 | 26 | void printArray(int arr[], int n) 27 | { 28 | int i; 29 | for (i = 0; i < n; i++) 30 | printf("%d ", arr[i]); 31 | printf("\n"); 32 | } 33 | 34 | /* Driver program to test insertion sort */ 35 | int main() 36 | { 37 | int i, n; 38 | printf("Enter the number of elements in the array : "); 39 | scanf("%d",&n); 40 | int arr[n]; 41 | printf("Enter the elements in the array : "); 42 | for(i = 0;i 4 | int search(int arr[], int N, int x) 5 | { 6 | int i; 7 | for (i = 0; i < N; i++) 8 | if (arr[i] == x) 9 | return i; 10 | return -1; 11 | } 12 | 13 | /* Function to print an array */ 14 | 15 | void printArray(int arr[], int size) 16 | { 17 | int i; 18 | for (i = 0; i < size; i++) 19 | printf("%d ", arr[i]); 20 | printf("\n"); 21 | } 22 | 23 | // Driver's code 24 | int main(void) 25 | { 26 | int i, n, x; 27 | printf("Enter the number of elements in the array : "); 28 | scanf("%d",&n); 29 | int arr[n]; 30 | printf("Enter the elements in the array : "); 31 | for(i = 0;i arr[j + 1]) { 14 | int temp = arr[j]; 15 | arr[j] = arr[j + 1]; 16 | arr[j + 1] = temp; 17 | swap = true; 18 | } 19 | } 20 | 21 | // if j loop did not swap any number than its mean array is already sorted, 22 | // so we don't need to execute code further 23 | if (!swap) { 24 | break; 25 | } 26 | } 27 | } 28 | 29 | public static void main(String[] args) { 30 | int arr[] = {3, 33, 6, 4, 1, 8, 2, 6, 9}; 31 | bubbleSort(arr, 0); 32 | System.out.println(Arrays.toString(arr)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /SortingAndSearching/CombSort.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | class CombSort { 4 | public static void main(String args[]) { 5 | CombSort ob = new CombSort(); 6 | int array[] = {7, 5, 2, 49, 4, -24, 31, -3, 0, 38}; 7 | 8 | ob.sort(array); 9 | 10 | System.out.println("sorted arrayay"); 11 | 12 | for (int i = 0; i < array.length; ++i) 13 | System.out.print(array[i] + " "); 14 | 15 | } 16 | 17 | int getNextGap(int gap) { 18 | gap = (gap * 10) / 13; 19 | if (gap < 1) 20 | return 1; 21 | return gap; 22 | } 23 | 24 | void sort(int array[]) { 25 | int n = array.length; 26 | 27 | int gap = n; 28 | 29 | boolean isSwapped = true; 30 | 31 | while (gap != 1 || isSwapped == true) { 32 | gap = getNextGap(gap); 33 | 34 | isSwapped = false; 35 | 36 | for (int i = 0; i < n - gap; i++) { 37 | if (array[i] > array[i + gap]) { 38 | int temp = array[i]; 39 | array[i] = array[i + gap]; 40 | array[i + gap] = temp; 41 | 42 | isSwapped = true; 43 | } 44 | } 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /SortingAndSearching/CyclicSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/SortingAndSearching/CyclicSort.class -------------------------------------------------------------------------------- /SortingAndSearching/CyclicSort.java: -------------------------------------------------------------------------------- 1 | import java.util.Arrays; 2 | 3 | public class CyclicSort { 4 | public static void main(String[] args) { 5 | int[] a= {5,4,3,2,1}; 6 | sort(a); 7 | System.out.println(Arrays.toString(a)); 8 | } 9 | static void sort(int[] arr){ 10 | int i=0; 11 | while(i0&& arr[correctIndex]!=arr[i]){ 14 | //Then we swap the numbers till we don't get the number at the correct index 15 | int temp=arr[correctIndex]; 16 | arr[correctIndex]=arr[i]; 17 | arr[i]=temp; 18 | } 19 | else { 20 | i++; 21 | } 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SortingAndSearching/InsertionSort.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | import java.util.Arrays; 4 | 5 | public class InsertionSort { 6 | 7 | public static void insertionSort(int[] arr, int currIndex) { 8 | 9 | if (currIndex == arr.length) { 10 | return; 11 | } 12 | int a = currIndex; 13 | for (int i = currIndex - 1; i >= 0; i--) { 14 | if (arr[a] < arr[i]) { 15 | // int temp = arr[a]; 16 | // arr[a] = arr[i]; 17 | // arr[i] = temp; 18 | arr[a] = arr[a] + arr[i]; 19 | arr[i] = arr[a] - arr[i]; 20 | arr[a] = arr[a] - arr[i]; 21 | a--; 22 | } else { 23 | break; 24 | } 25 | } 26 | 27 | insertionSort(arr, currIndex + 1); 28 | } 29 | 30 | public static void main(String[] args) { 31 | int[] arr = {33, 55, 2, 67, 34, 15, 76, 35}; 32 | insertionSort(arr, 0); 33 | System.out.println(Arrays.toString(arr)); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /SortingAndSearching/JumpSearch.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | public class JumpSearch { 4 | 5 | public static int jumpSearch(int arr[], int x) { 6 | int n = arr.length; 7 | // Finding block size to be jumped example -> root of length of array 8 | int step = (int) Math.floor(Math.sqrt(n)); 9 | int prevStep = 0; 10 | while (arr[step - 1] < x) { 11 | prevStep = step; 12 | step = step + step; 13 | if (prevStep >= n) { 14 | return -1; 15 | } 16 | } 17 | while (arr[prevStep] < x) { 18 | prevStep++; 19 | if (prevStep == Math.min(step, n)) { 20 | return -1; 21 | } 22 | if (arr[prevStep] == x) { 23 | return prevStep; 24 | } 25 | } 26 | return -1; 27 | } 28 | 29 | // Driver program to test function 30 | public static void main(String[] args) { 31 | int arr[] = {0, 1, 1, 2, 3, 5, 8, 13, 21, 32 | 34, 55, 89, 144, 233, 377, 610}; 33 | int x = 2; 34 | 35 | // Find the index of 'x' using Jump Search 36 | int index = jumpSearch(arr, x); 37 | 38 | // Print the index where 'x' is located 39 | System.out.println("\nNumber " + x + 40 | " is at index " + index); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SortingAndSearching/LinearSearch.java: -------------------------------------------------------------------------------- 1 | // Linear Search in Java 2 | 3 | class LinearSearch { 4 | public static int linearSearch(int array[], int x) { 5 | int n = array.length; 6 | 7 | // Going through array sequencially 8 | for (int i = 0; i < n; i++) { 9 | if (array[i] == x) 10 | return i; 11 | } 12 | return -1; 13 | } 14 | 15 | public static void main(String args[]) { 16 | int array[] = { 2, 4, 0, 1, 9 }; 17 | int x = 1; 18 | 19 | int result = linearSearch(array, x); 20 | 21 | if (result == -1) 22 | System.out.print("Element not found"); 23 | else 24 | System.out.print("Element found at index: " + result); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /SortingAndSearching/MergeSortedArray.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | import java.util.Arrays; 4 | 5 | public class MergeSortedArray { 6 | 7 | public static int[] merge(int[] arr1, int[] arr2, int size1, int size2) { 8 | int[] result = new int[size1 + size2]; 9 | // initialize i, j, k to traverse array 10 | int i = 0; 11 | int j = 0; 12 | int k = 0; 13 | 14 | while (i < size1 && j < size2) { // boundary condition 15 | if (arr1[i] <= arr2[j]) { 16 | result[k] = arr1[i]; 17 | i++; 18 | } else { 19 | result[k] = arr2[j]; 20 | j++; 21 | } 22 | k++; 23 | } 24 | // either arr1 get exhausted or arr2 get exhausted 25 | 26 | while (i < size1) { 27 | result[k] = arr1[i]; 28 | i++; 29 | k++; 30 | } 31 | while (j < size2) { 32 | result[k] = arr1[j]; 33 | j++; 34 | k++; 35 | } 36 | return result; 37 | } 38 | 39 | public static void main(String[] args) { 40 | 41 | int[] arr1 = {4, 6, 12, 15, 18, 20}; 42 | int[] arr2 = {1, 3, 7, 11, 13, 16, 19}; 43 | int[] result = merge(arr1, arr2, arr1.length, arr2.length); 44 | System.out.println(Arrays.toString(result)); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /SortingAndSearching/QuickSort.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | import java.util.Arrays; 4 | 5 | public class QuickSort { 6 | 7 | public static void quickSort(int[] arr, int l, int r) { 8 | 9 | if (l < r) { 10 | int pi = partition(arr, l, r); 11 | quickSort(arr, l, pi - 1); 12 | quickSort(arr, pi + 1, r); 13 | } 14 | } 15 | 16 | private static int partition(int[] arr, int l, int r) { 17 | int pivot = arr[r]; 18 | int i = l - 1; 19 | for (int j = l; j < r; j++) { 20 | if (arr[j] <= pivot) { 21 | i++; 22 | swap(arr, i, j); 23 | } 24 | } 25 | swap(arr, i + 1, r); 26 | 27 | // we are returning i+1 which means pivot value index 28 | return i + 1; 29 | } 30 | 31 | private static void swap(int[] arr, int i, int j) { 32 | // arr[i] = arr[i]+ arr[j]; 33 | // arr[j] = arr[i] - arr[j]; 34 | // arr[i] = arr[i] - arr[j]; 35 | int temp = arr[i]; 36 | arr[i] = arr[j]; 37 | arr[j] = temp; 38 | } 39 | 40 | public static void main(String[] args) { 41 | int[] arr = {5, 4, 3, 2, 1}; 42 | quickSort(arr, 0, 4); 43 | System.out.println(Arrays.toString(arr)); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /SortingAndSearching/SearchAnElement.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | public class SearchAnElement { 4 | public static void main(String[] args) { 5 | int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; 6 | int start = 0; 7 | int end = arr.length - 1; 8 | int key = 8; 9 | searching(arr, start, end, key); 10 | } 11 | 12 | static void searching(int[] arr, int i, int j, int key) { 13 | boolean notFound = true; 14 | int countAttempt = 0; 15 | try { 16 | while (notFound) { 17 | // check what to print -- i or j by comparing with key value 18 | countAttempt++; 19 | if (arr[i] == key) { 20 | System.out.println("Element found at Index: " + i); 21 | System.out.println("Attempt taken : " + countAttempt); 22 | notFound = false; 23 | } else if (arr[j] == key) { 24 | System.out.println("Element found at Index: " + j); 25 | System.out.println("Attempt taken : " + countAttempt); 26 | notFound = false; 27 | } 28 | i = i + 1; 29 | j = j - 1; 30 | } 31 | } catch (Exception e) { 32 | System.out.println("Element not found"); 33 | } 34 | } 35 | } 36 | 37 | -------------------------------------------------------------------------------- /SortingAndSearching/ShellSort.java: -------------------------------------------------------------------------------- 1 | package SortingAndSearching; 2 | 3 | import java.util.Arrays; 4 | 5 | public class ShellSort { 6 | 7 | public static void main(String[] args) { 8 | int[] data = {9, 8, 3, 7, 5, 6, 4, 1}; 9 | int size = data.length; 10 | ShellSort ss = new ShellSort(); 11 | ss.shellSort(data, size); 12 | System.out.println("Sorted Array in Ascending Order: "); 13 | System.out.println(Arrays.toString(data)); 14 | } 15 | 16 | void shellSort(int[] arr, int n) { 17 | for (int gap = n / 2; gap > 0; gap /= 2) { 18 | for (int i = gap; i < n; i += 1) { 19 | int temp = arr[i]; 20 | 21 | int j; 22 | for (j = i; j >= gap && arr[j - gap] > temp; j -= gap) { // j >= gap means 3 >= 2 ... 23 | // we execute this statement if j-gap value is greater than j value 24 | arr[j] = arr[j - gap]; 25 | } 26 | // if arr[j - gap] is not greater than temp than execute arr[j] = temp 27 | // j is decreasing by j - gap in every iteration so j will we as small as possible, 28 | // now we will store temp at j 29 | arr[j] = temp; 30 | } 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Tree/LowestCommonAncestor.java: -------------------------------------------------------------------------------- 1 | package Tree; 2 | 3 | public class TreeNode { 4 | int val; 5 | TreeNode left; 6 | TreeNode right; 7 | 8 | TreeNode(int x) { 9 | val = x; 10 | } 11 | } 12 | 13 | public class Solution { 14 | public TreeNode lowestCommonAncestor(TreeNode root, TreeNode p, TreeNode q) { 15 | if (root == null || root == p || root == q) { 16 | return root; 17 | } 18 | 19 | TreeNode left = lowestCommonAncestor(root.left, p, q); 20 | TreeNode right = lowestCommonAncestor(root.right, p, q); 21 | 22 | if (left != null && right != null) { 23 | return root; 24 | } 25 | 26 | return left != null ? left : right; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Tree/Symmetric tree: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean isSymmetric(TreeNode root) { 3 | if (root == null) { 4 | return true; 5 | } 6 | return isMirror(root.left, root.right); 7 | } 8 | 9 | private boolean isMirror(TreeNode node1, TreeNode node2) { 10 | if (node1 == null && node2 == null) { 11 | return true; 12 | } 13 | if (node1 == null || node2 == null) { 14 | return false; 15 | } 16 | return node1.val == node2.val && isMirror(node1.left, node2.right) && isMirror(node1.right, node2.left); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /array/ArrayInsert.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class ArrayInsert { 4 | public static void main(String args[]) { 5 | int arr[] = new int[5]; 6 | 7 | insertAtEnd(arr, 2); 8 | insertAtEnd(arr, 3); 9 | insertAtEnd(arr, 4); 10 | insertAtEnd(arr, 5); 11 | 12 | printArray(arr); 13 | 14 | insertAtStart(arr, 1); 15 | 16 | printArray(arr); 17 | insertAtPos(arr, 2, 20); 18 | printArray(arr); 19 | 20 | } 21 | static int count = 0; 22 | 23 | //insert array element at end 24 | static void insertAtEnd(int arr[], int val) { 25 | arr[count++] = val; 26 | } 27 | 28 | //insert array element at start 29 | 30 | static void insertAtStart(int arr[], int val) { 31 | for (int i = count; i > 0; i--) { 32 | arr[i] = arr[i - 1]; 33 | } 34 | arr[0] = val; 35 | } 36 | 37 | //insert element at given position 38 | static void insertAtPos(int arr[], int pos, int val) { 39 | for (int i = count; i > pos; i--) { 40 | arr[i] = arr[i - 1]; 41 | } 42 | arr[pos] = val; 43 | } 44 | 45 | 46 | static void printArray(int arr[]) { 47 | for (int i = 0; i < arr.length; i++) 48 | System.out.print(arr[i] + " "); 49 | System.out.println(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /array/CountEleWithStrictlySmallAndGreater.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class CountEleWithStrictlySmallAndGreater { 4 | public static void main(String[] args) { 5 | int[] arr = {11,7,2,15}; 6 | 7 | System.out.println(countElements(arr)); 8 | } 9 | public static int countElements(int[] nums) { 10 | int min = Integer.MAX_VALUE; 11 | int max = Integer.MIN_VALUE; 12 | for (int i = 0; i < nums.length; ++i) { 13 | min = Math.min(min, nums[i]); 14 | max = Math.max(max, nums[i]); 15 | } 16 | int count = 0; 17 | for (int i = 0; i < nums.length; ++i) { 18 | if (nums[i] > min && nums[i] < max) { 19 | count++; 20 | } 21 | } 22 | return count; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /array/Count_reverse_pairs_493.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | /* 6 | Count Reverse Pairs 7 | Problem Statement: Given an array of numbers, you need to return the count of reverse pairs. Reverse Pairs are those pairs where i2*arr[j]. 8 | 9 | Examples: 10 | 11 | Example 1: 12 | 13 | Input: N = 5, array[] = {1,3,2,3,1) 14 | 15 | Output: 2 16 | 17 | Explanation: The pairs are (3, 1) and (3, 1) as from both the pairs the condition arr[i] > 2*arr[j] is satisfied. 18 | 19 | */ 20 | public class Count_reverse_pairs_493 { 21 | public static void main(String[] args) { 22 | int[] arr = {1,3,2,3,1}; 23 | System.out.println(reversePairs(arr)); 24 | } 25 | static int reversePairs(int[] nums){ 26 | return mergeSort(nums, 0, nums.length-1); 27 | } 28 | 29 | private static int mergeSort(int[] nums, int s, int e){ 30 | if(s>=e) return 0; 31 | int mid = s + (e-s)/2; 32 | int cnt = mergeSort(nums, s, mid) + mergeSort(nums, mid+1, e); 33 | for(int i = s, j = mid+1; i<=mid; i++){ 34 | while(j<=e && nums[i]/2.0 > nums[j]) j++; 35 | cnt += j-(mid+1); 36 | } 37 | Arrays.sort(nums, s, e+1); 38 | return cnt; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /array/CyclicallyRotate.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | public class CyclicallyRotate { 8 | public static void main(String[] args) { 9 | Integer[] arr = {1, 2, 4, 5, 6, 9, 3, 9}; 10 | 11 | printRotatedArray(arr); 12 | } 13 | 14 | private static void printRotatedArray(Integer[] arr) { 15 | List list = Arrays.asList(arr); 16 | 17 | List newlist = new LinkedList<>(list); 18 | int lastelement = arr[arr.length - 1]; 19 | newlist.add(0, lastelement); 20 | newlist.remove(arr.length); 21 | 22 | System.out.println(newlist); 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /array/Dutch_National_flag_algorithm.java: -------------------------------------------------------------------------------- 1 | public class Solution { 2 | public static void main(String[] args){ 3 | int[] nums = {0,2,1,2,0,1,1,2}; 4 | sortColors(nums); 5 | } 6 | public void sortColors(int[] nums) { 7 | int lo = 0; 8 | int hi = nums.length - 1; 9 | int mid = 0; 10 | int temp; 11 | while (mid <= hi) { 12 | switch (nums[mid]) { 13 | case 0: { 14 | temp = nums[lo]; 15 | nums[lo] = nums[mid]; 16 | nums[mid] = temp; 17 | lo++; 18 | mid++; 19 | break; 20 | } 21 | case 1: 22 | mid++; 23 | break; 24 | case 2: { 25 | temp = nums[mid]; 26 | nums[mid] = nums[hi]; 27 | nums[hi] = temp; 28 | hi--; 29 | break; 30 | } 31 | } 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /array/FIndMissingNumber.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class FIndMissingNumber { 4 | public static void main(String[] args) { 5 | int[] arr = {1, 2, 3, 4, 5, 6, 8, 9, 10, 11}; 6 | findNumber(arr); 7 | } 8 | 9 | private static void findNumber(int[] arr) { 10 | for (int i = 0; i < arr.length - 1; i++) { 11 | if (arr[i + 1] - arr[i] != 1) { 12 | System.out.println(arr[i] + 1); 13 | break; 14 | } else if (arr[i + 1] - arr[i] == 1) { 15 | if (i == arr.length - 2) { 16 | System.out.println("Noting is missing"); 17 | break; 18 | } 19 | } 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /array/FrequencySortArray.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | public class FrequencySortArray { 4 | public static void main(String[] args) { 5 | int [] arr = {-1, 6, 4,6,2,7,4,2,1,4,5}; 6 | int[] ans = freqSort(arr); 7 | System.out.println(ans.toString()); 8 | } 9 | private static int[] freqSort(int[] arr){ 10 | int n = arr.length; 11 | 12 | return arr; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /array/MajorityElement.java: -------------------------------------------------------------------------------- 1 | package array; 2 | /* 3 | 169. Majority Element 4 | Given an array nums of size n, return the majority element. 5 | 6 | The majority element is the element that appears more than [n / 2] times. 7 | You may assume that the majority element always exists in the array. 8 | 9 | Example 1: 10 | 11 | Input: nums = [3,2,3] 12 | Output: 3 13 | Example 2: 14 | 15 | Input: nums = [2,2,1,1,1,2,2] 16 | Output: 2 17 | */ 18 | public class MajorityElement { 19 | public static void main(String[] args) { 20 | int [] num = {2,2,1,1,1,2,2}; 21 | int ans = majorityElement(num); 22 | System.out.println("Majority element is : " + ans); 23 | } 24 | private static int majorityElement(int[] num) { 25 | 26 | int major=num[0], count = 1; 27 | for(int i=1; i x) { 18 | end--; 19 | } else if (arr[start] + arr[end] < x) { 20 | start++; 21 | } else { 22 | System.out.println(arr[start] + " " + arr[end]); 23 | start++; 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /array/Pow_X_N.java: -------------------------------------------------------------------------------- 1 | package array; 2 | /* 3 | Implement Pow(x,n) | X raised to the power N 4 | Problem Statement: Given a double x and integer n, calculate x raised to power n. Basically Implement pow(x, n). 5 | 6 | Examples: 7 | 8 | Example 1: 9 | 10 | Input: x = 2.00000, n = 10 11 | 12 | Output: 1024.00000 13 | 14 | Explanation: You need to calculate 2.00000 raised to 10 which gives ans 1024.00000 15 | 16 | */ 17 | public class Pow_X_N { 18 | public static void main(String[] args) { 19 | double x = 2.00000; 20 | int n = 10; 21 | double ans = myPow(x,n); 22 | System.out.println(ans); 23 | } 24 | 25 | static double myPow(double x, int n){ 26 | double ans = 1.0; 27 | long nn = n; //duplicate n(power) because we are going to modify it (nn/2) 28 | if(nn<0) { // if the power is negative than make it + by multiplying with -1 29 | nn = -1 * nn; 30 | } 31 | 32 | while (nn > 0){ 33 | if (nn % 2 == 1){ //if the power is odd 34 | ans = ans * x; 35 | nn = nn-1; 36 | }else{ // if the power is even 37 | x = x * x; 38 | nn = nn / 2; 39 | } 40 | } 41 | 42 | if( n < 0){ // if the power was a negative number 43 | ans = 1 / ans; 44 | } 45 | return ans; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /array/RecursiveArray.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.time.LocalDateTime; 4 | import java.util.Scanner; 5 | 6 | class Practical { 7 | public static void main(String[] args) { 8 | LocalDateTime t1 = LocalDateTime.now(); 9 | System.out.println(t1); 10 | System.out.println("Mihir501"); 11 | System.out.println("Practical\n"); 12 | 13 | Scanner input = new Scanner(System.in); 14 | int product = 1; 15 | System.out.print("Enter five integers: "); 16 | int[] list = new int[5]; 17 | for (int i = 0; i < list.length; i++) { 18 | list[i] = input.nextInt(); 19 | product *= list[i]; 20 | } 21 | System.out.println("The Product of elements is " + product); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /array/RotateArrayByDElement2.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | public class RotateArrayByDElement2 { 6 | public static void main(String[] args) { 7 | int[] arr = {1, 2, 3, 4, 5, 6, 7}; 8 | int n = arr.length; 9 | int d = 2; 10 | leftRotate(arr, d); 11 | printArray(arr); 12 | System.out.println(); 13 | System.out.println(Arrays.toString(arr)); 14 | 15 | } 16 | 17 | private static void printArray(int[] arr) { 18 | for (int n : arr) System.out.print(n + " "); 19 | } 20 | 21 | private static void leftRotate(int[] arr, int d) { 22 | int n = arr.length; 23 | if (d == 0) return; 24 | d = d % n; 25 | reverseArray(arr, 0, d - 1); 26 | reverseArray(arr, d, n - 1); 27 | reverseArray(arr, 0, n - 1); 28 | } 29 | 30 | private static void reverseArray(int[] arr, int start, int end) { 31 | int temp; 32 | while (start < end) { 33 | temp = arr[start]; 34 | arr[start] = arr[end]; 35 | arr[end] = temp; 36 | start++; 37 | end--; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /array/RotateArrayByDElements.java: -------------------------------------------------------------------------------- 1 | package array; 2 | // Java program to rotate an array by 3 | // d elements 4 | 5 | public class RotateArrayByDElements { 6 | static class RotateArray { 7 | static void leftRotateByOne(int[] arr) { 8 | int i, temp; 9 | temp = arr[0]; 10 | for (i = 0; i < 7 - 1; i++) 11 | arr[i] = arr[i + 1]; 12 | arr[arr.length - 1] = temp; 13 | } 14 | 15 | // Driver program to test above functions 16 | public static void main(String[] args) { 17 | RotateArray rotate = new RotateArray(); 18 | int[] arr = {1, 2, 3, 4, 5, 6, 7}; 19 | rotate.leftRotate(arr); 20 | rotate.printArray(arr); 21 | } 22 | 23 | /*Function to left rotate arr[] of size n by d*/ 24 | void leftRotate(int[] arr) { 25 | for (int i = 0; i < 2; i++) 26 | leftRotateByOne(arr); 27 | } 28 | 29 | /* utility function to print an array */ 30 | void printArray(int[] arr) { 31 | for (int j : arr) System.out.print(j + " "); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /array/RotateArrayByK_Steps.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.Arrays; 4 | 5 | /* 6 | 189. Rotate Array LEETCODE 7 | 8 | Given an array, rotate the array to the right by k steps, where k is non-negative. 9 | Example 1: 10 | 11 | Input: nums = [1,2,3,4,5,6,7], k = 3 12 | Output: [5,6,7,1,2,3,4] 13 | 14 | */ 15 | public class RotateArrayByK_Steps { 16 | public static void main(String[] args) { 17 | int arr[] = {1,2,3,4,5,6,7}; 18 | int k = 3; 19 | System.out.println("before array : "+ Arrays.toString(arr)); 20 | rotate(arr, k); 21 | System.out.println("After rotating :" + Arrays.toString(arr)); 22 | } 23 | 24 | public static void rotate(int[] nums, int k) { 25 | k %= nums.length; 26 | 27 | reverse(nums, 0, nums.length -1); 28 | reverse(nums, 0, k-1); 29 | reverse(nums, k, nums.length -1); 30 | } 31 | 32 | public static void reverse(int [] arr, int start, int end){ 33 | while(start 7654321 46 | 2) rotate array by k steps from start 47 | 7654321 --> 567 4321 48 | 3) rotate array from k to last index 49 | 5674321 --> 567 1234 50 | */ 51 | -------------------------------------------------------------------------------- /array/SortAnArray.java: -------------------------------------------------------------------------------- 1 | public class SortAnArray { 2 | public int[] sortArray(int[] nums) { 3 | mergeSort(nums, 0, nums.length - 1); 4 | return nums; 5 | } 6 | 7 | private void mergeSort(int[] nums, int left, int right) { 8 | if (left >= right) { 9 | return; 10 | } 11 | 12 | int mid = left + (right - left) / 2; 13 | mergeSort(nums, left, mid); 14 | mergeSort(nums, mid + 1, right); 15 | merge(nums, left, mid, right); 16 | } 17 | 18 | private void merge(int[] nums, int left, int mid, int right) { 19 | int[] temp = new int[right - left + 1]; 20 | int i = left, j = mid + 1, k = 0; 21 | 22 | while (i <= mid && j <= right) { 23 | temp[k++] = nums[i] <= nums[j] ? nums[i++] : nums[j++]; 24 | } 25 | 26 | while (i <= mid) { 27 | temp[k++] = nums[i++]; 28 | } 29 | 30 | while (j <= right) { 31 | temp[k++] = nums[j++]; 32 | } 33 | 34 | System.arraycopy(temp, 0, nums, left, temp.length); 35 | } 36 | } -------------------------------------------------------------------------------- /array/StockBuyAndSell.java: -------------------------------------------------------------------------------- 1 | package array; 2 | /* 3 | Stock Buy And Sell 4 | Problem Statement: You are given an array of prices where prices[i] is the price of a given stock on an ith day. 5 | 6 | You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the 7 | future to sell that stock. Return the maximum profit you can achieve from this transaction. 8 | If you cannot achieve any profit, return 0. 9 | */ 10 | public class StockBuyAndSell { 11 | public static void main(String[] args) { 12 | int[] prices = {7, 1, 5, 3, 6, 4}; 13 | int profit = profit(prices); 14 | System.out.println("Profit is : "+profit); 15 | } 16 | static int profit(int[] arr){ 17 | int n = arr.length; 18 | int maxProfit = 0; 19 | int minPrice = Integer.MAX_VALUE; 20 | for (int i=0; i maxProfit){ 24 | maxProfit = arr[i] - minPrice; 25 | } 26 | } 27 | return maxProfit; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /array/SubArrayWithGivenXorK.java: -------------------------------------------------------------------------------- 1 | package array; 2 | 3 | import java.util.*; 4 | 5 | public class SubArrayWithGivenXorK { 6 | public static void main(String[] args) { 7 | int[] arr = {4, 2, 2, 6, 4}; 8 | int k = 6; 9 | System.out.println(xorCount(arr, k)); 10 | } 11 | private static int xorCount(int[] arr, int k){ 12 | int n = arr.length; 13 | int current_xor = 0; 14 | int count =0; 15 | Map prefix = new HashMap<>(); 16 | for (int i=0; i> triangle) { 3 | 4 | int n = triangle.size(); 5 | int []prev = new int [n]; 6 | 7 | for(int i=n-1;i>=0;i--){ 8 | int []cur = new int [n]; 9 | for(int j=i;j>=0;j--){ // Note Condition of "J"can be other way too. 10 | if(i==n-1){ 11 | cur[j] = triangle.get(i).get(j); 12 | continue; 13 | } 14 | int down = (int)(1e9); 15 | int diagonal = (int)(1e9); 16 | if(i+1 firstList = Arrays.asList(arr1); 12 | List secondList = Arrays.asList(arr2); 13 | 14 | Set set = new HashSet<>(); 15 | set.addAll(firstList); 16 | set.addAll(secondList); 17 | 18 | Integer[] union = {}; 19 | union = set.toArray(union); 20 | 21 | System.out.println("union array : "); 22 | System.out.println(Arrays.toString(union)); 23 | } 24 | 25 | // main method 26 | public static void main(String[] args) { 27 | Integer[] arr1 = {1, 2, 4, 5, 6}; 28 | Integer[] arr2 = {2, 3, 5, 7, 9}; 29 | 30 | printUnion(arr1, arr2); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /array/Valid Sudoku: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean isValidSudoku(char[][] board) { 3 | for (int i = 0; i < 9; i++) { 4 | for (int j = 0; j < 9; j++) { 5 | if (board[i][j] != '.') { // only check non-empty cells 6 | if (!isValid(i, j, board, board[i][j])) { 7 | return false; 8 | } 9 | } 10 | } 11 | } 12 | return true; 13 | } 14 | 15 | public boolean isValid(int row, int col, char[][] board, char c) { 16 | for (int i = 0; i < 9; i++) { 17 | // Check the row 18 | if (i != col && board[row][i] == c) { 19 | return false; 20 | } 21 | // Check the column 22 | if (i != row && board[i][col] == c) { 23 | return false; 24 | } 25 | // Check the 3x3 subgrid 26 | int subgridRow = 3 * (row / 3) + i / 3; 27 | int subgridCol = 3 * (col / 3) + i % 3; 28 | if ((subgridRow != row || subgridCol != col) && board[subgridRow][subgridCol] == c) { 29 | return false; 30 | } 31 | } 32 | return true; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /array/Word Break: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public boolean wordBreak(String s, List wordDict) { 3 | // if we found word break for whole string, return true 4 | if(s.isEmpty()) return true; 5 | 6 | for(String word: wordDict){ 7 | int n = word.length(); 8 | 9 | if(s.length() >= n){ 10 | 11 | // if word is prefix of s, then break s and look for word break in remaining string 12 | if (s.startsWith(word)) { 13 | boolean b = wordBreak(s.substring(n), wordDict); 14 | if(b) return b; 15 | } 16 | } 17 | } 18 | return false; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /array/basic/ArrayListImplement.java: -------------------------------------------------------------------------------- 1 | package array.basic; 2 | 3 | import java.util.ArrayList; 4 | 5 | public class ArrayListImplement { 6 | public static void main(String[] args) { 7 | ArrayList fruits = new ArrayList<>(); 8 | 9 | fruits.add("apple"); 10 | fruits.add("mango"); 11 | System.out.println(fruits); 12 | 13 | ArrayList marks = new ArrayList(); 14 | marks.add(1); 15 | marks.add(3); 16 | 17 | Pair p = new Pair<>(5, "sourav"); 18 | Pair p1 = new Pair<>("Aman", 5); 19 | p.getDescription(); 20 | p1.getDescription(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /array/basic/Pair.java: -------------------------------------------------------------------------------- 1 | package array.basic; 2 | 3 | public class Pair { 4 | X x; 5 | Y y; 6 | 7 | public Pair(X x, Y y) { 8 | this.x = x; 9 | this.y = y; 10 | } 11 | 12 | public void getDescription() { 13 | System.out.println(x + " and " + y); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /array/stars pattern/star7.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | 3 | public class star7 { 4 | public static void main(String[] args) { 5 | Scanner scanner = new Scanner(System.in); 6 | System.out.println("Please provide number of rows to print... "); 7 | int myrows = scanner.nextInt(); 8 | System.out.println("\nThe star pattern is... "); 9 | for (int m = 1; m <= myrows; m++) { 10 | for (int n = 1; n < m; n++) { 11 | System.out.print(" "); 12 | } 13 | for (int p = m; p <= myrows; p++) { 14 | System.out.print("* "); 15 | } 16 | System.out.println(); 17 | } 18 | for (int m = myrows - 1; m >= 1; m--) { 19 | for (int n = 1; n < m; n++) { 20 | System.out.print(" "); 21 | } 22 | for (int p = m; p <= myrows; p++) { 23 | System.out.print("* "); 24 | } 25 | System.out.println(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /array/stars pattern/star8.java: -------------------------------------------------------------------------------- 1 | import java.util.Scanner; 2 | public class star8 { 3 | 4 | public static void main(String[] args) 5 | { 6 | Scanner sc = new Scanner(System.in); 7 | System.out.println("Enter the number of rows: "); 8 | 9 | int rows = sc.nextInt(); 10 | for (int i=rows; i>= 1 ; i--) 11 | { 12 | for (int j = i; j < rows ; j++) { 13 | System.out.print(" "); 14 | } 15 | for (int k = 1; k <= (2*i -1) ;k++) { 16 | if( k==1 || i == rows || k==(2*i-1)) { 17 | System.out.print("*"); 18 | } 19 | else { 20 | System.out.print(" "); 21 | } 22 | } 23 | System.out.println(""); 24 | } 25 | sc.close(); 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /array/starsPattern/star1.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | public class star1 { 4 | public static void main(String[] args) { 5 | for (int i = 0; i <= 5; i++) { 6 | for (int j = 0; j <= i; j++) { 7 | System.out.print("* "); 8 | } 9 | System.out.println(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /array/starsPattern/star2.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | public class star2 { 4 | public static void main(String[] args) { 5 | for (int i = 5; i >= 0; i--) { 6 | for (int j = 0; j < i; j++) { 7 | System.out.print("* "); 8 | } 9 | System.out.println(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /array/starsPattern/star3.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | public class star3 { 4 | public static void main(String[] args) { 5 | for (int i = 0; i <= 4; i++) { 6 | for (int j = 0; j <= i; j++) { 7 | System.out.print("* "); 8 | } 9 | System.out.println(); 10 | } // complexity = O(n2) 11 | for (int a = 0; a <= 4; a++) { 12 | for (int b = 4; b > a; b--) { 13 | System.out.print("* "); 14 | } 15 | System.out.println(); 16 | } // complexity = O(n2) 17 | } 18 | 19 | // total complexity = n2 + n2 = 2(n^2) 20 | } 21 | -------------------------------------------------------------------------------- /array/starsPattern/star4.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | import java.util.Scanner; 4 | 5 | public class star4 { 6 | public static void main(String[] args) { 7 | int n; 8 | Scanner sc = new Scanner(System.in); 9 | System.out.println("Enter any number: "); 10 | n = sc.nextInt(); 11 | 12 | for (int i = 0; i < n; i++) { // O(n) 13 | 14 | for (int j = n; j > i + 1; j--) { // O(n) 15 | System.out.print(" "); 16 | } // + 17 | 18 | for (int a = 0; a <= i; a++) { // O(n) 19 | System.out.print("*"); 20 | } 21 | System.out.println(); 22 | } 23 | } 24 | // time complexity - 2(n^2) 25 | } 26 | -------------------------------------------------------------------------------- /array/starsPattern/star5.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | import java.util.Scanner; 4 | 5 | public class star5 { 6 | public static void main(String[] args) { 7 | int n; 8 | Scanner sc = new Scanner(System.in); 9 | System.out.println("Enter any Number: "); 10 | n = sc.nextInt(); 11 | for (int i = 0; i < n; i++) { 12 | for (int a = n; a > i + 1; a--) { 13 | System.out.print(" "); 14 | } 15 | for (int b = 0; b <= i; b++) { 16 | System.out.print(" *"); 17 | } 18 | System.out.println(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /array/starsPattern/star6.java: -------------------------------------------------------------------------------- 1 | package array.starsPattern; 2 | 3 | public class star6 { 4 | public static void main(String[] args) { 5 | for (int i = 0; i < 58; i++) { 6 | for (int j = 0; j <= i; j++) { 7 | System.out.print((char) (65 + j) + " "); 8 | } 9 | System.out.println(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /cpp_codes/Balance_paranthesis.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | string isBalanced(string s); 4 | 5 | unordered_map symbols = {{'[',-1},{'{',-2},{'(',-3}} 6 | 7 | string isBalanced(string s){ 8 | stack st; 9 | for(auto bracket : s){ 10 | if(symbols[bracket] < 0){ 11 | st.push(bracket); 12 | } 13 | else{ 14 | if(st.empty()) return "No"; 15 | char top = st.top(); 16 | st.pop(); 17 | if(symbols[top] + symbols[bracket] !=0) return "No"; 18 | } 19 | 20 | 21 | } 22 | if(st.empty()) return "Yes"; 23 | else return "No"; 24 | } 25 | 26 | 27 | int main(){ 28 | int t; 29 | cin>>t; 30 | while(t--){ 31 | string s; 32 | cin>>s; 33 | auto ans = isBalanced(s); 34 | cout<< ans< 3 | using namespace std; 4 | 5 | #define ll long long 6 | #define vi vector 7 | #define vll vector 8 | #define pll pair 9 | #define pb push_back 10 | #define endl '\n' 11 | 12 | signed main() 13 | { 14 | vll temp; 15 | for (int i = 0; i < 17; i++) 16 | { 17 | for (int j = i + 1; j < 18; j++) 18 | { 19 | for (int k = j + 1; k < 19; k++) 20 | { 21 | for (int l = k + 1; l < 20; l++) 22 | { 23 | ll val = (1 << l) + (1 << k) + (1 << j) + (1 << i); 24 | temp.pb(val); 25 | } 26 | if (temp.size() == 1000) 27 | { 28 | break; 29 | } 30 | } 31 | if (temp.size() == 1000) 32 | { 33 | break; 34 | } 35 | } 36 | if (temp.size() == 1000) 37 | { 38 | break; 39 | } 40 | } 41 | 42 | int tc = 0, tt = 1; 43 | cin >> tt; 44 | while (tc++ < tt) 45 | { 46 | ll n; 47 | cin >> n; 48 | for (int i = 0; i < n; i++) 49 | { 50 | cout << temp[i] << " "; 51 | } 52 | cout << endl; 53 | } 54 | 55 | return 0; 56 | } 57 | -------------------------------------------------------------------------------- /cpp_codes/leetcode : 78 : subset.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | void subsets(int index, vector &v, vector> &ans, vector &nums, int n) 4 | { 5 | if(index >= n) 6 | { 7 | ans.push_back(v); 8 | return; 9 | 10 | } 11 | 12 | v.push_back(nums[index]); 13 | subsets(index+1,v,ans,nums,n); 14 | v.pop_back(); 15 | 16 | subsets(index+1,v,ans,nums,n); 17 | } 18 | 19 | vector> subsets(vector& nums) { 20 | vector> ans; 21 | vector v; 22 | 23 | int n = nums.size(); 24 | 25 | subsets(0,v,ans,nums,n); 26 | 27 | return ans; 28 | } 29 | }; -------------------------------------------------------------------------------- /cpp_codes/leetcode-47-permutation2.cpp: -------------------------------------------------------------------------------- 1 | class Solution { 2 | public: 3 | vector> permuteUnique(vector& nums) { 4 | vector> ans; 5 | vector v; 6 | 7 | sort(nums.begin(),nums.end()); 8 | 9 | do{ 10 | for(int i=0;i sortArrayByParity(vector& nums) { 4 | vector v; 5 | 6 | for(int i=0;i 2 | using namespace std; 3 | const int N = 1e5+10; 4 | 5 | vector g[N]; 6 | bool visited[N]; 7 | 8 | vector cc; 9 | vector current_cc; 10 | 11 | void dfs(int vertex){ 12 | 13 | visited[vertex] = true; 14 | current_cc.push_back(vertex); 15 | 16 | for(int child : g[vertex]){ 17 | 18 | if(visited[child] == true) 19 | continue; 20 | dfs(child); 21 | } 22 | } 23 | 24 | 25 | 26 | int main(){ 27 | int n,e; 28 | cin>>n>>e; 29 | 30 | for(int i=0;i>x>>y; 33 | g[x].push_back(y); 34 | g[y].push_back(x); 35 | } 36 | 37 | 38 | int ct = 0; 39 | for(int i=1;i<=e;i++){ 40 | if(visited[i] == true) 41 | continue; 42 | 43 | current_cc.clear(); 44 | dfs(i); 45 | cc.push_back(current_cc); 46 | ct++; 47 | } 48 | 49 | cout<& nums) { 4 | sort(nums.begin(),nums.end()); 5 | int ans = 0; 6 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | // function prototype for display_queue utility 6 | void display_queue(queue q); 7 | 8 | int main() { 9 | 10 | // create a queue of string 11 | queue animals; 12 | 13 | cout << "Initial Queue: "; 14 | display_queue(animals); 15 | 16 | // push element into the queue 17 | animals.push("Cat"); 18 | animals.push("Dog"); 19 | animals.push("Fox"); 20 | 21 | cout << "Queue after push: "; 22 | display_queue(animals); 23 | 24 | // remove element from queue 25 | animals.pop(); 26 | 27 | cout << "Queue after pop: "; 28 | display_queue(animals); 29 | 30 | return 0; 31 | } 32 | 33 | // utility function to display queue 34 | void display_queue(queue q) { 35 | while(!q.empty()) { 36 | cout << q.front() << ", "; 37 | q.pop(); 38 | } 39 | 40 | cout << endl; 41 | } -------------------------------------------------------------------------------- /cpp_codes/recursion/sum_of_digits.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int sumOfDigits(int n) { 4 | if(n==0)return 0; 5 | return sumOfDigits(n/10)+n%10; 6 | } 7 | int main() { 8 | int n; 9 | cin >> n; 10 | cout << sumOfDigits(n) << endl; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /cpp_codes/square_root_BS.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main(){ 5 | int x; 6 | cin>>x; 7 | int l = 1, h = x; 8 | long long mid; 9 | int ans = 0; 10 | 11 | while(l <= h){ 12 | mid = (l+h)/2; 13 | if((mid*mid) <= x){ 14 | ans = mid; 15 | l = mid + 1; 16 | } 17 | else{ 18 | h = mid - 1; 19 | } 20 | } 21 | cout< 2 | using namespace std; 3 | 4 | vector sub; 5 | void subString(string s, int n) 6 | { 7 | 8 | for (int i = 0; i < n; i++) 9 | for (int len = 1; len <= n - i; len++) 10 | sub.push_back(substr(i, len)); 11 | } 12 | 13 | int main(){ 14 | int tc; 15 | cin>>tc; 16 | 17 | while(tc--){ 18 | string s; 19 | cin>>s; 20 | subString(s,s.length()); 21 | 22 | if(sub.find("11") || sub.find("10")){ 23 | cout<<"Yes"< 2 | using namespace std; 3 | 4 | vector topo; 5 | 6 | void topologicalSort(int n, vector adj[]) 7 | { 8 | queue q; 9 | vector indegree(n,0); 10 | 11 | for(int i=0;i adj[10]; 48 | int n = 6; 49 | 50 | adj[5].push_back(0); 51 | adj[5].push_back(2); 52 | adj[2].push_back(3); 53 | adj[3].push_back(1); 54 | adj[4].push_back(1); 55 | adj[4].push_back(0); 56 | 57 | topologicalSort(n,adj); 58 | 59 | for(int i=0;i al = new ArrayList<>(5); 10 | 11 | System.out.println(al);// list store null 12 | 13 | int [] arr = new int[5]; 14 | System.out.println(arr[2]); // array store 0 15 | 16 | TreeSet t = new TreeSet<>(); 17 | t.add(6); 18 | t.add(1); 19 | t.add(6); 20 | t.add(9); 21 | t.add(2); 22 | 23 | System.out.println(t); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /extra/Assertion.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class Assertion { 4 | /* 5 | * @param args 6 | */ 7 | public static void main(String[] args) { 8 | // debugging without Assertion 9 | int a = 0; 10 | while (true){ 11 | if (a>1){ 12 | System.out.println("code working correctly"); 13 | break; 14 | } 15 | assert false : "something wrong!! "+ a+" should be greater than 1"; 16 | // System.out.println("something wrong!!"); 17 | break; 18 | } 19 | 20 | int x = -8; 21 | assert (x>0): "Asserting internal invariants"; 22 | // System.out.println("Assertion error"); 23 | assertionExample(5); 24 | } 25 | 26 | // pre condition 27 | public static void assertionExample(int a){ 28 | assert a>0 && a<=100; 29 | int b = a+2; //method logic 30 | 31 | 32 | assert b>a;// post condition 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extra/Bank.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class Bank { 4 | private int amount = 100000; 5 | private String name = "sourav"; 6 | 7 | 8 | public String getName(){ 9 | return name; 10 | } 11 | 12 | 13 | private void setName(String n){ 14 | name = n; 15 | } 16 | // getter 17 | public int getAmount(){ 18 | return amount; 19 | } 20 | 21 | 22 | // setter 23 | private void setAmount(int x){ 24 | amount = x; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /extra/Bike8.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Random; 4 | 5 | class Bike8 { 6 | public static String st = "sourav"; 7 | 8 | static { 9 | System.out.println("instance initializer block invoked"); 10 | } 11 | 12 | static { 13 | System.out.println("static instance initializer block invoked"); 14 | } 15 | 16 | Bike8(String st) { 17 | Bike8.st = st; 18 | System.out.println("constructor is invoked = " + st); 19 | } 20 | 21 | static void print() { 22 | System.out.println("bike 8 method"); 23 | } 24 | 25 | public static void main(String[] args) { 26 | new Bike8(st); 27 | print(); 28 | 29 | Random r = new Random(); 30 | System.out.println(r.nextInt(11)); 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /extra/IndexWhereLeftEqualRight.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class IndexWhereLeftEqualRight { 4 | public static void main(String[] args) { 5 | int[] a = {2, 4, 3, 1, 5}; 6 | 7 | int sumOFLeft; 8 | int i = 1; 9 | int sumOfRight; 10 | while (i < a.length - 2) { 11 | sumOFLeft = 0; 12 | sumOfRight = 0; 13 | for (int j = i + 1; j <= a.length - 1; j++) { 14 | sumOfRight += a[j]; 15 | } 16 | for (int k = i - 1; k >= 0; k--) { 17 | sumOFLeft += a[k]; 18 | } 19 | if (sumOFLeft == sumOfRight) { 20 | System.out.println(i); 21 | break; 22 | } else { 23 | i++; 24 | } 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /extra/LambdaExp.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Arrays; 4 | 5 | public class LambdaExp { 6 | public interface Add{ 7 | public int add(int a, int b); 8 | } 9 | public static int doAdd(int a, int b) { 10 | return a + b; 11 | } 12 | 13 | public interface Display{ 14 | public int show(String s1, String s2); 15 | } 16 | 17 | public static void main(String[] args) { 18 | Add add = LambdaExp::doAdd; 19 | 20 | // #2 21 | String[] arr = {"delhi", "chd", "haryana","punjab", "hp"}; 22 | Arrays.stream(arr).forEach(System.out::println); 23 | Display dp = String::indexOf; 24 | System.out.println(dp); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extra/Main.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.*; 4 | import java.io.*; 5 | 6 | public class Main { 7 | public static int processArray(ArrayList list) { 8 | for(int i=0; i 46 && n % 10 == 3){ 11 | list.set(i, -1); 12 | } 13 | else if(n > 46){ 14 | list.set(i, -3); 15 | }else if(n % 10 == 3){ 16 | list.set(i, -9); 17 | } 18 | } 19 | return list.size(); 20 | } 21 | 22 | public static void main (String[] args) { 23 | ArrayList arrayList = new ArrayList(); 24 | Scanner in = new Scanner(System.in); 25 | while(in.hasNextInt()) { 26 | int num = in.nextInt(); 27 | if (num < 0) 28 | break; 29 | arrayList.add(new Integer(num)); 30 | } 31 | int new_length = processArray(arrayList); 32 | for(int i=0; i= n) { 29 | return; 30 | } 31 | System.out.print(arr[i] + " "); 32 | printArray(arr, i + 1, n); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extra/RegexPractice.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Scanner; 4 | import java.util.regex.Matcher; 5 | import java.util.regex.Pattern; 6 | 7 | public class RegexPractice { 8 | public static void main(String[] args) { 9 | Scanner sc = new Scanner(System.in); 10 | while (true) { 11 | System.out.println("Enter regex pattern:"); 12 | Pattern pattern = Pattern.compile(sc.nextLine()); 13 | System.out.println("Enter text:"); 14 | Matcher matcher = pattern.matcher(sc.nextLine()); 15 | boolean found = false; 16 | while (matcher.find()) { 17 | System.out.println("I found the text " + matcher.group() + " starting at index " + 18 | matcher.start() + " and ending at index " + matcher.end()); 19 | found = true; 20 | } 21 | if (!found) { 22 | System.out.println("No match found."); 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /extra/SecondLargest.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Arrays; 4 | 5 | public class SecondLargest { 6 | public static void main(String[] args) { 7 | int[] arr = {1, 5, 3, 13, 3, 78, 2, 8}; 8 | Arrays.sort(arr); 9 | 10 | for (int i = 0; i < arr.length - 1; i++) { 11 | if (arr[i] == arr[i + 1]) { 12 | System.out.println("same " + arr[i]); 13 | } 14 | } 15 | System.out.println(arr[arr.length - 2]); 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /extra/Shape.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public abstract class Shape { 4 | 5 | public abstract void circle(); 6 | // abstract void square(); 7 | // abstract void rect(); 8 | 9 | public void print(){ 10 | System.out.println("dfjdsofjsj"); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /extra/SwapNodesinPairs.java: -------------------------------------------------------------------------------- 1 | // leetcode 24. Swap Nodes in Pairs solution 2 | public class Swap { 3 | 4 | public ListNode swapPairs(ListNode head) { 5 | ListNode dummy= new ListNode(0); 6 | ListNode curr=head, prev=dummy; 7 | dummy.next=head; 8 | while(curr!=null && curr.next!=null){ 9 | prev.next=curr.next; 10 | curr.next=curr.next.next; 11 | prev.next.next=curr; 12 | curr=curr.next; 13 | prev=prev.next.next; 14 | } 15 | return dummy.next; 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /extra/SwapWIthoutTemp.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class SwapWIthoutTemp { 4 | public static void main(String[] args) { 5 | // String a = "Love"; 6 | // String b = "You"; 7 | // System.out.println("before swap : " + a +" "+ b); 8 | // 1st way 9 | // a = a+ b; 10 | // System.out.println(a); 11 | // b = a.substring(0, a.length() - b.length()); 12 | // System.out.println(b); 13 | // a = a.substring(b.length()); 14 | // System.out.println(a); 15 | 16 | // 2nd way with Math 17 | // int x = 4; 18 | // int y = 6; 19 | // 20 | // System.out.println("before swap:" + "x = "+ x + " y = " +y); 21 | // x = x * y; 22 | // y = x / y; 23 | // x = x / y; 24 | // System.out.println("now x = "+ x +" y = "+ y); 25 | 26 | 27 | // 3rd way using bitwise operators 28 | int x = 10; 29 | int y = 5; 30 | 31 | System.out.println("Before swap: x = " 32 | + x + ", y = " + y); 33 | // Code to swap 'x' (1010) and 'y' (0101) 34 | x = x ^ y; // x now becomes 15 (1111) 35 | y = x ^ y; // y becomes 10 (1010) 36 | x = x ^ y; // x becomes 5 (0101) 37 | 38 | System.out.println("After swap: x = " 39 | + x + ", y = " + y); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /extra/UserAbst.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class UserAbst { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /extra/customException.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class customException { 4 | 5 | // public static void aMethod() throws Exception{ 6 | // try { 7 | // throw new Exception(); 8 | // }finally { 9 | // System.out.println("Finally"); 10 | // } 11 | // } 12 | public static void main(String[] args) throws Exception { 13 | 14 | // try{ 15 | // aMethod(); 16 | // }catch (Exception e ){ 17 | // System.out.println("exception"); 18 | // } 19 | // System.out.println("finished"); 20 | // try { 21 | // badMethod(); 22 | // System.out.println("A"); 23 | // }catch (RuntimeException exception){ 24 | // System.out.println("B"); 25 | // }catch (Exception ex1){ 26 | // System.out.println("C"); 27 | // }finally { 28 | // System.out.println("D"); 29 | // } 30 | // System.out.println("E"); 31 | // } 32 | // public static void badMethod(){ 33 | // throw new RuntimeException(); 34 | 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /extra/input: -------------------------------------------------------------------------------- 1 | this is a input file -------------------------------------------------------------------------------- /extra/inter.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public interface inter { 4 | public void circle(); 5 | 6 | public void print(); 7 | } 8 | -------------------------------------------------------------------------------- /extra/ioclass.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.FileOutputStream; 5 | import java.io.IOException; 6 | 7 | public class ioclass { 8 | 9 | public static void main(String[] args) throws IOException { 10 | System.out.println("simple message"); 11 | System.err.println("error message"); 12 | 13 | 14 | FileInputStream in = null; 15 | FileOutputStream out = null; 16 | try { 17 | in = new FileInputStream("input.txt"); 18 | out = new FileOutputStream("output.txt"); 19 | int c; 20 | while ((c = in.read()) != -1) { 21 | out.write(c); 22 | } 23 | } finally { 24 | if (in != null) { 25 | in.close(); 26 | } 27 | if (out != null) { 28 | out.close(); 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /extra/isanagram.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class isanagram { 4 | public static void main(String[] args) { 5 | String s1 = "abc"; 6 | String s2 = "cba"; 7 | String s3 = "bac"; 8 | 9 | // String out = checkAnagram(s1,s2,s3); 10 | // System.out.println(out); 11 | } 12 | 13 | // static String checkAnagram(String s1, String s2, String s3){ 14 | // int[] f1 = new int[26]; 15 | // 16 | // } 17 | } 18 | -------------------------------------------------------------------------------- /extra/methodObject.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class methodObject { 4 | public static void main(String[] args) { 5 | methodObject obj = new methodObject(); 6 | obj.print(); 7 | } 8 | public void print(){ 9 | System.out.println("method print"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /extra/mmt1.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Scanner; 4 | 5 | public class mmt1 { 6 | public static void main(String[] args) { 7 | Scanner sc = new Scanner(System.in); 8 | int t = sc.nextInt(); 9 | while(t-->0){ 10 | long n = sc.nextLong(); 11 | int out = solve1(n); 12 | System.out.println(out); 13 | } 14 | } 15 | 16 | public static int solve1(long n){ 17 | int c = 0; 18 | int arr[] = {1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111 }; 19 | 20 | 21 | while(n > 0){ 22 | int len = String.valueOf(n).length(); 23 | System.out.println(n +" "+ len); 24 | if(n < arr[len-1]){ 25 | n = n - arr[len-2]; 26 | c = c + len-1; 27 | }else{ 28 | n = n - arr[len-1]; 29 | c = c + len; 30 | } 31 | } 32 | return c; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /extra/oops.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | public class oops { 4 | 5 | int interest; 6 | int abc = 10; 7 | public oops (int x){ 8 | interest = x; 9 | abc = x; 10 | } 11 | public static void main(String[] args) { 12 | oops obj = new oops(50); 13 | System.out.println("my size is " + obj.interest); 14 | 15 | obj.SBI(); 16 | obj.PNB(); 17 | System.out.println(obj.abc); 18 | } 19 | 20 | public void SBI(){ 21 | oops obj = new oops(8); 22 | System.out.println("our bank interest is " + obj.interest); 23 | } 24 | public void PNB(){ 25 | oops obj = new oops(10); 26 | System.out.println("our bank interest is " + obj.interest); 27 | } 28 | } 29 | 30 | // () parenthesis .... {} curley braces......[] square bracket 31 | -------------------------------------------------------------------------------- /extra/output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/extra/output -------------------------------------------------------------------------------- /extra/palindrome.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Scanner; 4 | 5 | public class palindrome { 6 | public static void main(String[] args) { 7 | Scanner sc = new Scanner(System.in); 8 | int n = sc.nextInt(); 9 | while(n-->0){ 10 | int num = sc.nextInt(); 11 | String out = sovle(num); 12 | System.out.println(out); 13 | } 14 | } 15 | 16 | public static String sovle(int n){ 17 | long min = 1; 18 | long max = 9; 19 | for(long i=2; i<=n; i++){ 20 | min = min * 10; 21 | max = (max * 10) + 9; 22 | } 23 | 24 | while(min % 7 != 0){ 25 | min++; 26 | } 27 | for(long i = min; i<= max; i+=7){ 28 | if(isPalindrome(i) == 1 && i%7 == 0){ 29 | return String.valueOf(i); 30 | } 31 | } 32 | return ""; 33 | } 34 | 35 | static long isPalindrome(long n) { 36 | long rev = 0; 37 | for (long i = n; i > 0; i /= 10){ 38 | rev = rev * 10 + i % 10; 39 | } 40 | return(n == rev) ? 1 : 0; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /extra/prac.java: -------------------------------------------------------------------------------- 1 | package extra; 2 | 3 | import java.util.Arrays; 4 | 5 | public class prac { 6 | public static void main(String[] args) { 7 | // String str = "sourav"; 8 | // 9 | // System.out.println(str.charAt(0)); // 1st 10 | // 11 | // char[] arr = str.toCharArray(); // 2nd 12 | // System.out.println(Arrays.toString(arr)); 13 | // 14 | // 15 | // System.out.println(str.substring(0,2) +" "+ str.substring(4,str.length())); // 3rd 16 | // 17 | // String half = str.substring(0,3); 18 | // System.out.println(half); 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | String str = "geeks for geek is for geeks"; 27 | String key = "for"; 28 | 29 | 30 | 31 | boolean check = str.contains("for"); 32 | System.out.println(check); 33 | 34 | // String key = "for"; 35 | // 36 | // System.out.println(findChar(str, key)); 37 | 38 | 39 | 40 | 41 | } 42 | 43 | public static boolean findChar(String str, char c){ 44 | for(int i=0; i< str.length(); i++){ 45 | if(str.charAt(i) == c){ 46 | return true; 47 | } 48 | } 49 | 50 | return false; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /graph/Graph.java: -------------------------------------------------------------------------------- 1 | package graph; 2 | 3 | public class Graph { 4 | 5 | private int[][] adjMatrix; 6 | private int V; // vertices in graph 7 | private int E; // number of edges in graph 8 | 9 | public Graph(int nodes) { 10 | this.V = nodes; 11 | this.E = 0; 12 | this.adjMatrix = new int[nodes][nodes]; 13 | } 14 | 15 | public static void main(String[] args) { 16 | Graph g = new Graph(4); 17 | g.addEdge(0, 1); 18 | g.addEdge(1, 2); 19 | g.addEdge(2, 3); 20 | g.addEdge(3, 0); 21 | System.out.println(g); 22 | } 23 | 24 | public String toString() { 25 | StringBuilder sb = new StringBuilder(); 26 | sb.append(V + " vertices, " + E + " edges " + "\n"); 27 | for (int v = 0; v < V; v++) { 28 | sb.append(v + " : "); 29 | for (int w : adjMatrix[v]) { 30 | sb.append(w + " "); 31 | } 32 | sb.append("\n"); 33 | } 34 | 35 | return sb.toString(); 36 | } 37 | 38 | public void addEdge(int u, int v) { 39 | this.adjMatrix[u][v] = 1; 40 | this.adjMatrix[v][u] = 1;// because it is an undirected array 41 | E++; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /hashing/MissingElementsOfaRange.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void printMissing(int arr[], int n, int low,int high) 4 | { 5 | sort(arr, arr + n); 6 | int* ptr = lower_bound(arr, arr + n, low); 7 | int index = ptr - arr; 8 | int i = index, x = low; 9 | while (i < n && x <= high) { 10 | if (arr[i] != x) 11 | cout << x << " "; 12 | else 13 | i++; 14 | x++; 15 | } 16 | while (x <= high) 17 | cout << x++ << " "; 18 | } 19 | int main() 20 | { 21 | int arr[] = { 1, 3, 5, 4 }; 22 | int n = sizeof(arr) / sizeof(arr[0]); 23 | int low = 1, high = 10; 24 | printMissing(arr, n, low, high); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /hashing/TwoSumProblem.java: -------------------------------------------------------------------------------- 1 | package hashing; 2 | 3 | import java.util.Arrays; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class TwoSumProblem { 8 | public static void main(String[] args) { 9 | int[] number = {2, 6, 5, 8, 11}; 10 | int target = 16; 11 | System.out.println(Arrays.toString(twoSum(number, target))); 12 | } 13 | 14 | private static int[] twoSum(int[] arr, int target) { 15 | int[] result = new int[2]; 16 | Map map = new HashMap<>(); 17 | for (int i = 0; i < arr.length; i++) { 18 | if (map.containsKey(target - arr[i])) { 19 | result[0] = map.get(target - arr[i]); // map.get(6) is returning 1 because we put the number as key and index as value in map 20 | result[1] = i; 21 | return result; 22 | } 23 | map.put(arr[i], i); 24 | }// end of for 25 | return result; 26 | }//end of method 27 | } 28 | -------------------------------------------------------------------------------- /hashing/UnionOfTwoArrays.java: -------------------------------------------------------------------------------- 1 | package hashing; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class UnionOfTwoArrays { 7 | public static void main(String[] args) { 8 | int[] a = {1, 2, 3, 5}; 9 | int[] b = {3, 5, 6, 7}; 10 | 11 | Map map = Union(a, b); 12 | for (Integer name : map.keySet()) { 13 | System.out.print(name + " "); 14 | } 15 | } 16 | 17 | private static Map Union(int[] a, int[] b) { 18 | Map mp = new HashMap(); 19 | 20 | // Inserting array elements in mp 21 | for (int i = 0; i < a.length; i++) { 22 | mp.put(a[i], i); 23 | } 24 | for (int i = 0; i < b.length; i++) { 25 | mp.put(b[i], i); 26 | } 27 | return mp; 28 | } 29 | 30 | private static int maxlength(int[] a, int[] b) { 31 | int a1 = a.length; 32 | int b1 = b.length; 33 | return Math.max(a1, b1); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/BitManipulation/NoOfBitReqToChangeAtoB.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/BitManipulation/NoOfBitReqToChangeAtoB.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/BitManipulation/abc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/BitManipulation/abc.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DataStructure-And-Algo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/FibonacciNumberUsingBottomUpApproach.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/FibonacciNumberUsingBottomUpApproach.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/FibonacciUsingTopDown.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/FibonacciUsingTopDown.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/GridUniquePathByGoogle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/GridUniquePathByGoogle.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/Knapsack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/Knapsack.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/LongestCommonSubSequence.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/LongestCommonSubSequence.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/MaxSumSubArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/MaxSumSubArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/DynamicProgramming/MinimumOperationsToTransformStrings.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/DynamicProgramming/MinimumOperationsToTransformStrings.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Heap/ConnectNRopesInMinCost.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Heap/ConnectNRopesInMinCost.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Heap/Heap.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Heap/Heap.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Heap/Kth_Largest_Element.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Heap/Kth_Largest_Element.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/BufferedInputStream1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/BufferedInputStream1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/BufferedOutputStream1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/BufferedOutputStream1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/ByteArrayInputStream1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/ByteArrayInputStream1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/ByteArrayOutputStream1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/ByteArrayOutputStream1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/ByteOutputstream.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/ByteOutputstream.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/DataStreamExample.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/DataStreamExample.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/IO/SequenceInputStream1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/IO/SequenceInputStream1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/Cell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/Cell.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/CircularSinglyLinkedList$ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/CircularSinglyLinkedList$ListNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/CircularSinglyLinkedList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/CircularSinglyLinkedList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/DoublyLinkedList$ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/DoublyLinkedList$ListNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/DoublyLinkedList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/DoublyLinkedList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/DuplicateInArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/DuplicateInArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/DynamicList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/DynamicList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/List.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/List.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/MainLinkedList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/MainLinkedList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/MyLinkedList$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/MyLinkedList$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/MyLinkedList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/MyLinkedList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/ReverseList$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/ReverseList$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/ReverseList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/ReverseList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/SinglyLinkedList$ListNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/SinglyLinkedList$ListNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/LinkedListPackage/SinglyLinkedList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/LinkedListPackage/SinglyLinkedList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/CelulaMatriz.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/CelulaMatriz.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/CircularMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/CircularMatrix.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/Matrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/Matrix.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/Matriz.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/Matriz.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/MergeOverlappingSubIntervals.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/MergeOverlappingSubIntervals.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/PascalTriangle.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/PascalTriangle.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/RotateMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/RotateMatrix.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/SearchElementInSortedMatrix.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/SearchElementInSortedMatrix.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Matrix/SetMatrixZero.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Matrix/SetMatrixZero.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/RecursiveFactorial.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/RecursiveFactorial.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/BinarySearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/BinarySearch.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/BubbleSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/BubbleSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/BucketSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/BucketSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/CombSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/CombSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/CountSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/CountSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/ExponentialSearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/ExponentialSearch.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/HeapSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/HeapSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/InsertionSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/InsertionSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/InterpolationSearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/InterpolationSearch.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/JumpSearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/JumpSearch.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/MergeSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/MergeSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/MergeSortedArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/MergeSortedArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/QuickSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/QuickSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/RadixSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/RadixSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/SearchAnElement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/SearchAnElement.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/SelectionSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/SelectionSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/ShellSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/ShellSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/Sort_0s_1s_2s.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/Sort_0s_1s_2s.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/SublistSearch$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/SublistSearch$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/SortingAndSearching/SublistSearch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/SortingAndSearching/SublistSearch.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/AVLTree.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/AVLTree.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/AVL_T$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/AVL_T$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/AVL_T.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/AVL_T.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/BinarySearchTree$treeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/BinarySearchTree$treeNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/BinarySearchTree.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/BinarySearchTree.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/BinaryTree.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/BinaryTree.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/TreeNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/TreeNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/Trie_Ar$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/Trie_Ar$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/Trie_Ar.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/Trie_Ar.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Tree/Tries_Array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Tree/Tries_Array.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Trie/Trie$TrieNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Trie/Trie$TrieNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Trie/Trie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Trie/Trie.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Trie/TrieNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Trie/TrieNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Trie/Trie_codestudio_ll$Trie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Trie/Trie_codestudio_ll$Trie.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/Trie/Trie_codestudio_ll.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/Trie/Trie_codestudio_ll.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/ArrayInsert.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/ArrayInsert.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Array_deletion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Array_deletion.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/AscendingOrder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/AscendingOrder.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/CountEleWithStrictlySmallAndGreater.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/CountEleWithStrictlySmallAndGreater.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/CountInversionsInArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/CountInversionsInArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Count_reverse_pairs_493.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Count_reverse_pairs_493.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/CyclicallyRotate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/CyclicallyRotate.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/DutchNationalFlagAlgo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/DutchNationalFlagAlgo.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/FIndMissingNumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/FIndMissingNumber.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/FindDuplicate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/FindDuplicate.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/FourSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/FourSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/FrequencySortArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/FrequencySortArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/KadaneAlgo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/KadaneAlgo.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/KthSmallest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/KthSmallest.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/LargestSubArrayWith0Sum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/LargestSubArrayWith0Sum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/LongestConsecutiveSequence.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/LongestConsecutiveSequence.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MajorityElement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MajorityElement.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MajorityElement2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MajorityElement2.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MaxAndMin$Pair.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MaxAndMin$Pair.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MaxAndMin.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MaxAndMin.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MaxFreq.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MaxFreq.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MergeArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MergeArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MergeSort.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MergeSort.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MinDistanceBtwnTwoNumbers.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MinDistanceBtwnTwoNumbers.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MinNoOfJump.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MinNoOfJump.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MinOperationToMakeArrayAlternative.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MinOperationToMakeArrayAlternative.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MinimalSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MinimalSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MinimizeHeight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MinimizeHeight.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/MoveNegativeNumber.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/MoveNegativeNumber.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/NextLexicographic.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/NextLexicographic.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/NoOfSubArrayWithGivenProduct.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/NoOfSubArrayWithGivenProduct.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/PairOfSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/PairOfSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Pair_with_K_difference.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Pair_with_K_difference.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Permutation_in_string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Permutation_in_string.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/PlusOne.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/PlusOne.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Pow_X_N.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Pow_X_N.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/Practical.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/Practical.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RemoveDuplicate2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RemoveDuplicate2.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RemovingMinNoOfMagicBeans.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RemovingMinNoOfMagicBeans.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/ReversePair.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/ReversePair.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/ReverseTheArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/ReverseTheArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RotateArrayByDElement2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RotateArrayByDElement2.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RotateArrayByDElements$RotateArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RotateArrayByDElements$RotateArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RotateArrayByDElements.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RotateArrayByDElements.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/RotateArrayByK_Steps.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/RotateArrayByK_Steps.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/StockBuyAndSell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/StockBuyAndSell.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/SubArrayWithGivenXorK.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/SubArrayWithGivenXorK.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/SubArraysSumEqualK.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/SubArraysSumEqualK.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/ThreeSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/ThreeSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/TripletZeroSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/TripletZeroSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/TwoSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/TwoSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/UnionAndIntersection.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/UnionAndIntersection.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/UnionOfTwoArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/UnionOfTwoArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/XOR_Queries_of_Array.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/XOR_Queries_of_Array.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/basic/ArrayListImplement.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/basic/ArrayListImplement.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/basic/Pair.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/basic/Pair.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star2.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star3.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star4.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star4.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star5.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star5.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/array/starsPattern/star6.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/array/starsPattern/star6.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Animal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Animal.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Arraylist_doubt.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Arraylist_doubt.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Assertion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Assertion.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/BabyDog.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/BabyDog.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Bank.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Bank.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Bike8.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Bike8.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Dog.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Dog.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/IndexWhereLeftEqualRight.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/IndexWhereLeftEqualRight.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/LambdaExp$Add.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/LambdaExp$Add.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/LambdaExp$Display.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/LambdaExp$Display.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/LambdaExp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/LambdaExp.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Main.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Main.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/MyThread1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/MyThread1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Portal.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Portal.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/Problem1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/Problem1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/RecursionQUe.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/RecursionQUe.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/RegexPractice.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/RegexPractice.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/SecondLargest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/SecondLargest.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/StreamMain.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/StreamMain.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/SwapWIthoutTemp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/SwapWIthoutTemp.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/TestInheritance2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/TestInheritance2.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/customException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/customException.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/input: -------------------------------------------------------------------------------- 1 | this is a input file -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/ioclass.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/ioclass.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/isanagram.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/isanagram.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/methodObject.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/methodObject.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/mmt1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/mmt1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/new1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/new1.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/oops.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/oops.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/output: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/output -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/palindrome.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/palindrome.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/extra/prac.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/extra/prac.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/BellmanFord_Algorithm$Edge.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/BellmanFord_Algorithm$Edge.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/BellmanFord_Algorithm.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/BellmanFord_Algorithm.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/BipartiteGraphBFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/BipartiteGraphBFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/BipartiteGraphDFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/BipartiteGraphDFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/CycleDetectionBFS$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/CycleDetectionBFS$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/CycleDetectionBFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/CycleDetectionBFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/CycleDetectionDFS$Node.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/CycleDetectionDFS$Node.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/CycleDetectionDFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/CycleDetectionDFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/CycleInDirectedGraphDFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/CycleInDirectedGraphDFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/Graph.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/Graph.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/GraphWithList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/GraphWithList.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/ShortestPath.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/ShortestPath.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/TopologicalSortBFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/TopologicalSortBFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/graph/TopologicalSortDFS.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/graph/TopologicalSortDFS.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/hashing/HashTable$HashNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/hashing/HashTable$HashNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/hashing/HashTable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/hashing/HashTable.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/hashing/TripletsZeroSum.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/hashing/TripletsZeroSum.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/hashing/TwoSumProblem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/hashing/TwoSumProblem.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/hashing/UnionOfTwoArrays.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/hashing/UnionOfTwoArrays.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/CQueue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/CQueue.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/Deque.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/Deque.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/Examination.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/Examination.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/Examination_queue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/Examination_queue.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/MaxPQ.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/MaxPQ.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/MyQueue$QueueNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/MyQueue$QueueNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/MyQueue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/MyQueue.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/PQueue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/PQueue.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/queue/Priorities.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/queue/Priorities.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/AllXtoRightSide.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/AllXtoRightSide.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/CountPairs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/CountPairs.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/FirstLastOccurrence.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/FirstLastOccurrence.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/GridUniquePathGoogleQue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/GridUniquePathGoogleQue.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/One.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/One.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/RecursivePalindrome.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/RecursivePalindrome.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/RemoveDuplicate.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/RemoveDuplicate.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/ReverseString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/ReverseString.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/SortedOrNot.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/SortedOrNot.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/SubsetsOfArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/SubsetsOfArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/recursion/TowerOfHanoi.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/recursion/TowerOfHanoi.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/stack/MyStack$stackNode.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/stack/MyStack$stackNode.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/stack/MyStack.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/stack/MyStack.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/stack/ReverseString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/stack/ReverseString.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/stack/StackArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/stack/StackArray.class -------------------------------------------------------------------------------- /out/production/DataStructure-And-Algo/stack/stackArrayapp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sourav2002/DataStructure-And-Algo/0724a47cf21b774bab9ce4b3446f3f28d2f3cd30/out/production/DataStructure-And-Algo/stack/stackArrayapp.class -------------------------------------------------------------------------------- /queue/PQueue.java: -------------------------------------------------------------------------------- 1 | package queue; 2 | 3 | public class PQueue { 4 | int SIZE = 5; // Size of Priority Queue 5 | int front, rear; 6 | int items[] = new int[SIZE]; 7 | 8 | PQueue() { 9 | front = -1; 10 | rear = -1; 11 | } 12 | 13 | 14 | } 15 | -------------------------------------------------------------------------------- /recursion/AllXtoRightSide.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | public class AllXtoRightSide { 4 | public static void allXtoRightSide(String st, int index, int count, String newSt) { 5 | if (index == st.length()) { 6 | for (int i = 0; i < count; i++) { 7 | newSt += 'x'; 8 | } 9 | System.out.print(newSt); 10 | return; 11 | } 12 | 13 | char currCh = st.charAt(index); 14 | if (currCh == 'x') { 15 | count++; 16 | allXtoRightSide(st, index + 1, count, newSt); 17 | } else { 18 | newSt += currCh; 19 | allXtoRightSide(st, index + 1, count, newSt); 20 | } 21 | } 22 | 23 | public static void main(String[] args) { 24 | String st = "adxjlxxjxsjldxj"; 25 | String newSt = ""; 26 | int startIndex = 0; 27 | int count = 0; 28 | allXtoRightSide(st, startIndex, count, newSt); 29 | 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /recursion/FirstLastOccurrence.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | // time complexity is O(n) because we traversed the full length of string 4 | public class FirstLastOccurrence { 5 | 6 | static int first = -1; 7 | static int last = -1; 8 | 9 | public static void firstLastOccurrence(String st, char ch, int index) { 10 | if (index == st.length()) { 11 | System.out.println("First Occurrence of " + ch + " is at " + first + " and last occurrence is at " + last); 12 | return; 13 | } 14 | if (st.charAt(index) == ch) { 15 | if (first == -1) { 16 | first = index; 17 | } else { 18 | last = index; 19 | } 20 | } 21 | firstLastOccurrence(st, ch, index + 1); 22 | } 23 | 24 | public static void main(String[] args) { 25 | String st = "asbggadsava"; 26 | firstLastOccurrence(st, 'a', 0); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /recursion/GridUniquePathGoogleQue.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | import java.util.Arrays; 4 | 5 | public class GridUniquePathGoogleQue { 6 | public static void main(String[] args) { 7 | int[][] path = {{1, 2, 3}, {3, 4, 8}}; 8 | Arrays.stream(path).map(Arrays::toString) 9 | .forEach(System.out::println); 10 | int ans = countPath(0, 0, path.length, path[0].length); 11 | System.out.println(ans); 12 | } 13 | 14 | private static int countPath(int i, int j, int n, int m) { 15 | if (i == (n - 1) && j == (m - 1)) return 1; 16 | if (i >= n || j >= m) return 0; 17 | else return countPath(i + 1, j, n, m) + countPath(i, j + 1, n, m); // using recursion f 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /recursion/JosephusProblem.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | void Josh(vector person, int k, int index) 6 | { 7 | if (person.size() == 1) { 8 | cout << person[0] << endl; 9 | return; 10 | } 11 | index = ((index + k) % person.size()); 12 | person.erase(person.begin() + index); 13 | Josh(person, k, index); 14 | } 15 | 16 | int main() 17 | { 18 | int n = 14; 19 | int k = 2; 20 | k--; 21 | int index= 0; 22 | vector person; 23 | for (int i = 1; i <= n; i++) { 24 | person.push_back(i); 25 | } 26 | Josh(person, k, index); 27 | } 28 | -------------------------------------------------------------------------------- /recursion/One.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | public class One { 4 | 5 | static int factorial(int n) { 6 | if (n == 0) 7 | return 1; 8 | else 9 | return (n * factorial(n - 1)); 10 | } 11 | 12 | public static void main(String args[]) { 13 | int i, fact = 1; 14 | int number = 4; 15 | fact = factorial(number); 16 | System.out.println("Factorial of " + number + " is: " + fact); 17 | } 18 | 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /recursion/ProductOfNTerms.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Prod{ 4 | public static int help(int n){ 5 | if(n == 1)return n; 6 | return n * help(n - 1); 7 | } 8 | public static void main(String[] args){ 9 | Scanner s = new Scanner(System.in); 10 | int n = s.nextInt(); 11 | System.out.println("Product of "+n+" terms: "+help(n)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /recursion/RecursiveFactorial.java: -------------------------------------------------------------------------------- 1 | public class RecursiveFactorial { 2 | 3 | public static int factorial(int n) { 4 | int resp; 5 | System.out.println("fat (" + n + ")"); 6 | resp = (n == 1) ? 1 : n * factorial(n - 1); 7 | System.out.println("fat n(" + n + "): " + resp); 8 | return resp; 9 | } 10 | 11 | public static void main(String[] args) { 12 | int n = Integer.parseInt(args[0]); 13 | System.out.println("RECURSIVE FACTORIAL(" + n + "): " + factorial(n)); 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /recursion/RecursiveFibonacci.java: -------------------------------------------------------------------------------- 1 | public class RecursiveFibonacci { 2 | public static int fibRecursion(int count) { 3 | if (count == 0) { 4 | return 0; 5 | } // Oth fibonacci is 0 6 | 7 | if (count == 1 || count == 2) { 8 | return 1; 9 | } // 1st and 2nd Fibonacci are 1 and 1 only 10 | 11 | // calling function recursively for nth Fibonacci 12 | return fibRecursion(count - 1) + fibRecursion(count - 2); 13 | } 14 | 15 | public static void main(String args[]) { 16 | int fib_len = 9; 17 | 18 | System.out.print("Fibonacci Series of " + fib_len + " numbers is: \n"); 19 | 20 | for (int i = 0; i < fib_len; i++) { 21 | System.out.print(fibRecursion(i) + " "); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /recursion/RemoveDuplicate.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | import java.util.Scanner; 4 | 5 | public class RemoveDuplicate { 6 | public static void removeDuplicate(String str) { 7 | 8 | } 9 | 10 | public static void main(String[] args) { 11 | Scanner sc = new Scanner(System.in); 12 | System.out.println("Enter a string : "); 13 | String st = sc.nextLine(); 14 | removeDuplicate(st); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /recursion/ReverseString.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | // time complexity is O(n) because we are calling reverse function till the length of string i.e n 4 | public class ReverseString { 5 | 6 | public static void reverseString(String st, int index) { 7 | 8 | System.out.print(st.charAt(index)); 9 | if (index == 0) { 10 | return; 11 | } 12 | reverseString(st, index - 1); 13 | 14 | } 15 | 16 | public static void main(String[] args) { 17 | String st = "sourav"; 18 | reverseString(st, st.length() - 1); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /recursion/SortedOrNot.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | public class SortedOrNot { 4 | public static boolean sorted(int arr[], int index) { 5 | if (index == arr.length - 1) { 6 | return true; 7 | } 8 | if (arr[index] < arr[index + 1]) { 9 | return sorted(arr, index + 1); 10 | } else { 11 | return false; 12 | } 13 | } 14 | 15 | public static void main(String[] args) { 16 | int[] arr = {3, 4, 5, 6, 7, 9}; 17 | System.out.println(sorted(arr, 0)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /recursion/SubsetsOfArray.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class SubsetsOfArray { 7 | static ArrayList> ans = new ArrayList<>(); 8 | public static void main(String[] args) { 9 | int[] arr = {1,2,3}; 10 | final ArrayList list = new ArrayList<>(); 11 | 12 | printSubsets(0, list, arr); 13 | // System.out.println(ok); 14 | } 15 | 16 | public static void printSubsets(int i, ArrayList list, int[] arr){ 17 | if(i == arr.length) { 18 | System.out.println(list); 19 | // ans.add(list); 20 | return; 21 | } 22 | 23 | list.add(arr[i]); 24 | printSubsets(i+1, list,arr); 25 | list.remove(list.size()-1); 26 | printSubsets(i+1, list,arr); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /recursion/SumOfNterms.java: -------------------------------------------------------------------------------- 1 | import java.util.*; 2 | 3 | class Sum{ 4 | public static int help(int n){ 5 | if(n == 0)return n; 6 | return n + help(n - 1); 7 | } 8 | public static void main(String[] args){ 9 | Scanner s = new Scanner(System.in); 10 | int n = s.nextInt(); 11 | System.out.println("Sum of "+n+" terms: "+help(n)); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /recursion/TowerOfHanoi.java: -------------------------------------------------------------------------------- 1 | package recursion; 2 | 3 | // time complexity is O(2^n) because we called two recursive function 4 | public class TowerOfHanoi { 5 | 6 | public static void towerOfHanoi(int n, String src, String helper, String dest) { 7 | if (n == 1) { 8 | System.out.println("Transfer disk " + n + " from " + src + " to " + dest); 9 | return; 10 | } 11 | towerOfHanoi(n - 1, src, dest, helper); 12 | System.out.println("Transfer disk " + n + " from " + src + " to " + dest); 13 | towerOfHanoi(n - 1, helper, src, dest); 14 | } 15 | 16 | public static void main(String[] args) { 17 | int n = 3; 18 | towerOfHanoi(n, "S", "H", "D"); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /recursion/findCombination.cpp: -------------------------------------------------------------------------------- 1 | // Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. 2 | 3 | // Each number in candidates may only be used once in the combination. 4 | 5 | // Note: The solution set must not contain duplicate combinations. 6 | 7 | 8 | class Solution { 9 | public: 10 | void findcombination(int index, int target, vector &arr, vector> &ans,vector &v) 11 | { 12 | if(target == 0) 13 | { 14 | ans.push_back(v); 15 | return; 16 | } 17 | 18 | for(int i=index;iindex && arr[i] == arr[i-1]) continue; 21 | if(arr[i] > target) break; 22 | v.push_back(arr[i]); 23 | findcombination(i+1,target-arr[i],arr,ans,v); 24 | v.pop_back(); 25 | } 26 | 27 | } 28 | 29 | vector> combinationSum2(vector& candidates, int target) { 30 | sort(candidates.begin(),candidates.end()); 31 | vector> ans; 32 | vector v; 33 | 34 | findcombination(0,target,candidates,ans,v); 35 | return ans; 36 | } 37 | }; -------------------------------------------------------------------------------- /stack/LargestRectangleArea.java: -------------------------------------------------------------------------------- 1 | // Problem Statement: 2 | // Given an array of integers representing the heights of bars in a histogram, find the area of the largest rectangle in the histogram. 3 | package stack; 4 | import java.util.Stack; 5 | 6 | public class LargestRectangleArea { 7 | public int largestRectangleArea(int[] heights) { 8 | int n = heights.length; 9 | Stack stack = new Stack<>(); 10 | int maxArea = 0; 11 | int i = 0; 12 | 13 | while (i < n) { 14 | while (!stack.isEmpty() && heights[i] < heights[stack.peek()]) { 15 | int height = heights[stack.pop()]; 16 | int width = i - stack.peek() - 1; 17 | maxArea = Math.max(maxArea, height * width); 18 | } 19 | stack.push(i++); 20 | } 21 | 22 | while (!stack.isEmpty()) { 23 | int height = heights[stack.pop()]; 24 | int width = n - stack.peek() - 1; 25 | maxArea = Math.max(maxArea, height * width); 26 | } 27 | 28 | return maxArea; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /stack/ReverseString.java: -------------------------------------------------------------------------------- 1 | package stack; 2 | 3 | import java.util.Scanner; 4 | 5 | public class ReverseString { 6 | 7 | public static String reverse(String str) { 8 | MyStack myStack = new MyStack<>(); 9 | char[] chars = str.toCharArray(); 10 | 11 | for (char c : chars) { 12 | myStack.push(c); 13 | } 14 | for (int j = 0; j < str.length(); j++) { 15 | chars[j] = myStack.pop(); 16 | } 17 | return new String(chars); 18 | } 19 | 20 | public static void main(String[] args) { 21 | Scanner sc = new Scanner(System.in); 22 | String str = sc.nextLine(); 23 | System.out.println("Before reverse : " + str); 24 | 25 | System.out.println("After reverse : " + reverse(str)); 26 | } 27 | } 28 | --------------------------------------------------------------------------------