Welcome, & thanks for contributing. Once unpublished, this post will become invisible to the public and only accessible to seanpgallivan. Minimum Adjacent Swaps to Reach the Kth Smallest Number, LeetCode 1851. Time Complexity of this method is O(nLogn).Thanks to Gaurav Ahirwar for suggesting this method.Another Efficient Solution :Approach :1). Example 2: Input: nums = [-3,-2,-1,0,0,1,2] Output: 3 Explanation: There are 2 positive integers and 3 negative integers. Once suspended, seanpgallivan will not be able to comment or publish posts until their suspension is removed. Maximum Subarray. Median of Two Sorted Arrays 5. We're a place where coders share, stay up-to-date and grow their careers. 1775 Equal Sum Arrays With Minimum Number of Operations, LeetCode 1778. Maximize Number of Nice Divisors, LeetCode 1810. The maximum count among them is 4. Hello Programmers/Coders, Today we are going to share solutions to the Programming problems of LeetCode Solutions in C++, Java, & Python. Short story taking place on a toroidal planet or moon involving flying. This is part of a series of Leetcode solution explanations (index). Unflagging seanpgallivan will restore default visibility to their posts. This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. For further actions, you may consider blocking this person and/or reporting abuse. The idea is to define the size of our buckets such that the maximum gap will necessarily be larger than a single bucket. Two Sum Leetcode Solution is a Leetcode easy level problem. 1), Solution: Short Encoding of Words (ver. And since we only need to make one comparison per pair of buckets with consecutive numbers, and as there are only a maximum of 2 * N buckets, the comparisons will only take O(N) time, as well. Number of Restricted Paths From First to Last Node, LeetCode 1787. If you liked this solution or found it useful, please like this post and/or upvote my solution post on Leetcode's forums. Binary Tree Level Order Traversal- LeetCode Solutions Binary Tree Level Order Traversal Solution in C++: I find it helpful to use Set as a conceptual model instead. Made with love and Ruby on Rails. 00 . Fledgling software developer; the struggle is a Rational Approximation. Once suspended, seanpgallivan will not be able to comment or publish posts until their suspension is removed. I could solve this by brute force but I am not able to understand its editorial. You are also given an integer k. Create the maximum number of length k <= m + n from digits of the two numbers. We provide Chinese and English versions for coders around the world. We hope you apply to work at Forem, the team building DEV (this website) . join us by using the given follow link below. How can I access environment variables in Python? Since the answer can be a huge number, return it modulo 10^9 + 7. LintCode has the most interview problems covering Google, Facebook, Linkedin, Amazon, Microsoft and so on. How to handle a hobby that makes income in US. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Maximum Score of a Good Subarray, LeetCode 1794. For further actions, you may consider blocking this person and/or reporting abuse. Over one million developers have joined DEV in order to ensure they stay up-to-date on modern best practices. Maximum XOR for Each Query, LeetCode 1830. Now, check if the maximum difference is between ith and maximum element, store it in variable diff. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. Return the maximum performance of this team. Order Now. Second Largest Digit in a String, LeetCode 1797. Put call objects in TreeMap, with key = the call's start time and value = Call object TreeMap<Integer, Call> treemap HashMap<Call, Integer> dp //caches max possible volume for a given call earliestCall = tm.firstKey (); return dfs (earliest) function dfs (Call call) { if dp.get (call) != null return dp.get (call) Median of Two Sorted Arrays LeetCode 5. That is, performance = (2 + 10 + 5) * min(5, 4, 7) = 68. n = 6, speed = [2,10,3,1,5,8], efficiency = [5,4,3,9,7,2], k = 4. Most upvoted and relevant comments will be first. In this post, we are going to solve the 1. I find it helpful to use Set as a conceptual model instead. Loop through the whole array of elements and increase the value at the starting point by 1 and similarly decrease the value after ending point by 1. How do I align things in the following tabular environment? Example 3: Input: nums = [5,20,66,1314] Output: 4 Explanation: There are 4 positive integers and 0 negative integers. If you are not able to solve any problem, then you can take help from our Blog/website. Implement Trie II (Prefix Tree), LeetCode 1805. Space Complexity: O(1) for storage of each element. (Jump to: Problem Description || Code: JavaScript | Python | Java | C++). You signed in with another tab or window. For this problem, we don't need to actually sort every element, which would take longer than O(N) time. With you every step of your journey. Does Python have a ternary conditional operator? You may assume that each input would have exactly one solution, and you may not use the same element twice. Intial dp [0] = 0, as we make profit = 0 at time = 0. LeetCode 3. Maximize Score After N Operations, LeetCode 1800. Since the index numbers between speed and efficiency correspond to each other, we shouldn't just sort efficiency, however. If seanpgallivan is not suspended, they can still re-publish their posts from their dashboard. Search. 2), Solution: Minimum Remove to Make Valid Parentheses, Solution: Find the Most Competitive Subsequence, Solution: Longest Word in Dictionary through Deleting, Solution: Shortest Unsorted Continuous Subarray, Solution: Intersection of Two Linked Lists, Solution: Average of Levels in Binary Tree, Solution: Short Encoding of Words (ver. 2), Solution: Minimum Remove to Make Valid Parentheses, Solution: Find the Most Competitive Subsequence, Solution: Longest Word in Dictionary through Deleting, Solution: Shortest Unsorted Continuous Subarray, Solution: Intersection of Two Linked Lists, Solution: Average of Levels in Binary Tree, Solution: Short Encoding of Words (ver. You're going to want to catch up on this comment thread! If you choose a job that ends at time X you will be able to start another job that starts at time X. Largest Merge Of Two Strings, LeetCode 1760. Explanation: In first example, the order of customers according to their demand is: From this, it can easily be concluded that only customer 5 and customer 1 can be satisfied for total demand of 1 + 2 = 3. They can still re-publish the post if they are not suspended. Imagine trying to sort a deck of cards; it would only take once through the deck to sort it entirely into 13 "buckets", one for each value. 3. Once we have all events in sorted order, we can trace the number of guests at any time keeping track of guests that have arrived, but not exited.Consider the above example. To review, open the file in an editor that reveals hidden Unicode characters. In " Average Salary Excluding the Minimum and Maximum Salary" given a salary array.each element in array represents the salary of different employees. Return the maximum performance of this team. Keep track of maxFreq which is basically a pointer to the largest key in stacks. Once the truck is full (T == 0), or once the iteration is done, we should return ans. This tutorial is only for Educational and Learning purpose. Count Pairs With XOR in a Range, LeetCode 1804. code of conduct because it is harassing, offensive or spammy. You are given two integer arrays nums1 and nums2 of lengths m and n respectively. Add Two Numbers 3. The MinPriorityQueue() npm is easier to use, but not as efficient. DEV Community A constructive and inclusive social network for software developers. 160 Solution: Out of Boundary Paths 161 Solution: Redundant Connection This is part of a series of Leetcode solution explanations ( index ). abandoned texas island; haplogroup h1c and alzheimer's disease; pennsylvania revolutionary war soldiers; luiafk potions not working; where is the depop refund button; idealistic person traits. Finding the Users Active Minutes, LeetCode 1818. By using our site, you In this Leetcode Create Maximum Number problem solution You are given two integer arrays nums1 and nums2 of lengths m and n respectively. Read N Characters Given Read4, LeetCode 158. Also, we should remember to modulo 1e9+7 before we return best. Made with love and Ruby on Rails. . The maximum count among them is 3. Number of Different Subsequences GCDs, LeetCode 1820. Solution: Vertical Order Traversal of a Binary Tree, Solution: Count Ways to Make Array With Product, Solution: Smallest String With A Given Numeric Value, Solution: Concatenation of Consecutive Binary Numbers, Solution: Minimum Operations to Make a Subsequence, Solution: Find Kth Largest XOR Coordinate Value, Solution: Change Minimum Characters to Satisfy One of Three Conditions, Solution: Shortest Distance to a Character, Solution: Number of Steps to Reduce a Number to Zero, Solution: Maximum Score From Removing Substrings (ver. Fledgling software developer; the struggle is a Rational Approximation. Minimum Absolute Sum Difference, LeetCode 1819. Let's build a solution to the problem step by step:- The first thing that comes to our mind is that whenever we try to get the third largest element, it will be much easier if the elements were in a sorted order i.e in ascending order from lowest to highest. How can I remove a key from a Python dictionary? Is it suspicious or odd to stand by the gate of a GA airport watching the planes? Lowest Common Ancestor of a Binary Tree, LeetCode 238. (Jump to: Problem Description || Solution Idea). Next n lines contain two integers for each customer denoting total number of bags of size a and size b that customer requires. We should add the number of boxes added multiplied by the units per box to our answer (ans), and decrease T by the same number of boxes. Cannot retrieve contributors at this time. Lowest Common Ancestor of a Binary Tree II, LeetCode 1650. Longest Substring Without Repeating Characters LeetCode 4. Input: startTime = [1,2,3,3], endTime = [3,4,5,6], profit = [50,10,40,70] Output: 120 Explanation: The subset chosen is the first and fourth job. Welcome to SO and thank you for giving an answer. Can alternatively describe it as O(n) for storage of n elements. Given the size of the packets a and b, the total quantity of rice available d and the number of customers n, find out maximum number of customers that can be satisfied with the given quantity of rice. 2 hours ago. 1 n 2 x 105. Templates let you quickly answer FAQs or store snippets for re-use. rev2023.3.3.43278. By using our site, you The idea is to consider all events (all arrivals and exits) in sorted order. Maximum Ascending Subarray Sum, LeetCode 1801. Problem Statement. You want to perform the following query. DEV Community A constructive and inclusive social network for software developers. Check if Binary String Has at Most One Segment of Ones, LeetCode 1785. Solution2 . Built on Forem the open source software that powers DEV and other inclusive communities. Then we can iterate through B and at each step, we should add as many of the boxes as we can, until we reach the truck size (T). Does Python have a string 'contains' substring method? Longest Palindromic Substring 6. Two Sum Leetcode Solution Leetcode Solution. Are you sure you want to create this branch? but feel free to use all these solutions that are present on the blog. Given an integer array nums, return the maximum difference between two successive elements in its sorted form. Out of 14 testcases the solution worked on 7 (including all the open ones and a bunch of closed ones), and didn't work on the remaining 7 (all closed). The trick to this problem, like many best product of x and y problems, is to find a way to iterate through one of the values in order, then evaluate the other value for each combination and take the best result. The relative order of the digits from the same array must be preserved. Queries on Number of Points Inside a Circle, LeetCode 1829. At Each Problem with Successful submission with all Test Cases Passed, you will get a score or marks and LeetCode Coins. Once unsuspended, seanpgallivan will be able to comment and publish posts again. Built on Forem the open source software that powers DEV and other inclusive communities. Sum of Beauty of All Substrings, LeetCode 1784. Minimum Degree of a Connected Trio in a Graph, LeetCode 1764. Largest Submatrix With Rearrangements, LeetCode 1751. Sliding Window Maximum (LeetCode) Given an array nums, there is a sliding window of size k which is moving from the very left of the array to . This way, we can eliminate the slowest engineer from our pool every time we add an engineer over the k limit. Display the total number of customers that can be satisfied and the index of customers that can be satisfied. This problem 1. If the array contains less than two elements, return 0. Longest Substring Without Repeating Characters 4. Time Complexity : O(max(departure time))Auxiliary Space : O(max(departure time))Thanks to Harshit Saini for suggesting this method.Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above. An Efficient Solution is to use sorting n O(nLogn) time. Most upvoted and relevant comments will be first. 1), Solution: Short Encoding of Words (ver. 160 Solution: Out of Boundary Paths 161 Solution: Redundant Connection ZigZag Conversion LeetCode 7. maximum value from ith to last element. It will become hidden in your post, but will still be visible via the comment's permalink. Below is a Simple Method to solve this problem. and this approach takes him to write this page. Check if the Sentence Is Pangram, LeetCode 1835. However, I was looking through other submissions and found a linear time solution, but I've . Maximum Sum Circular Subarray - LeetCode Solutions LeetCode Solutions Preface Style Guide Problems Problems 1. (Jump to: Solution Idea || Code: JavaScript | Python | Java | C++). For example, if 53 is pushed twice, the first copy will be saved to Stack 1, the second copy to Stack 2. Two Sum - Leetcode Solution. Are you sure you want to hide this comment? Add Two Numbers LeetCode 3. Find the time at which there are maximum guests in the party. Search in Rotated Sorted Array II, LeetCode 124. 3rd query: nums = [0,1], k = 2 since 0 XOR 1 XOR 2 = 3. And after solving maximum problems, you will be getting stars. Zhongli4869. If seanpgallivan is not suspended, they can still re-publish their posts from their dashboard. Here is what you can do to flag seanpgallivan: seanpgallivan consistently posts content that violates DEV Community's In this post, you will find the solution for the Maximum Subarray in C++, Java & Python-LeetCode problem. 1) Traverse all intervals and find min and max time (time at which first guest arrives and time at which last guest leaves) 2) Create a count array of size 'max - min + 1'. Find Median from Data Stream, Leetcode 297. Maximum Average Pass Ratio, LeetCode 1793. 4th query: nums = [2], k = 5 since 2 XOR 5 = 7. Note: This problem 1. We are going to solve the problem using Priority Queue or Heap Data structure ( Max Heap ). (Jump to: Problem Description || Solution Idea). 66. Once unsuspended, seanpgallivan will be able to comment and publish posts again. 157 more parts. https://neetcode.io/ - A better way to prepare for Coding Interviews Twitter: https://twitter.com/neetcode1 Discord: https://discord.gg/ddjKRXPqtk S. Minimum Limit of Balls in a Bag, LeetCode 1761. . dp [time] = profit means that within the first time duration, we cam make at most profit money. Remove Duplicates from Sorted Array, LeetCode 30. Then, once we reach the end of our buckets array, we can simply return ans. Templates let you quickly answer FAQs or store snippets for re-use. Given a number of widgets available and a list of customer orders, what is the maximum number of orders the manufacturer can fulfill in full? Once unsuspended, seanpgallivan will be able to comment and publish posts again. The sizes a and b are decided by staff as per the demand. You can choose any boxes to put on the truck as long as the number of boxes does not exceed truckSize. Longest Substring Without Repeating Characters, LeetCode 5. This would be a better answer if you explained how the code you provided answers the question. Read N Characters Given Read4 II - Call multiple times, LeetCode 236. Made with love and Ruby on Rails. nums1 and nums2 represent the digits of two numbers.You are also given an integer k. Create the maximum number of length k <= m + n from digits of the two numbers.The relative order of the digits from the same array must be preserved. In this Leetcode Create Maximum Number problem solution You are given two integer arrays nums1 and nums2 of lengths m and n respectively. 1. Solution: Vertical Order Traversal of a Binary Tree, Solution: Count Ways to Make Array With Product, Solution: Smallest String With A Given Numeric Value, Solution: Concatenation of Consecutive Binary Numbers, Solution: Minimum Operations to Make a Subsequence, Solution: Find Kth Largest XOR Coordinate Value, Solution: Change Minimum Characters to Satisfy One of Three Conditions, Solution: Shortest Distance to a Character, Solution: Number of Steps to Reduce a Number to Zero, Solution: Maximum Score From Removing Substrings (ver. michael grant actor . Return an array of the k digits representing the answer. Maximum Product of Splitted Binary Tree LeetCode Solution - Given the root of a binary tree, split the binary tree into two subtrees by removing one edge such that the product of the sums of the subtrees is maximized.. Return the maximum product of the sums of the two subtrees.Since the answer may be too large, return it modulo 10 9 + 7. You are assigned to put some amount of boxes onto one truck. At each stop, we should also find the product of totalSpeed and the current minimum efficiency and update the best result if necessary. Register or Sign in. Cannot retrieve contributors at this time. Python / Modern C++ Solutions of All 2493 LeetCode Problems (Weekly Update) - LeetCode-Solutions/orders-with-maximum-quantity-above-average.sql at master . Therefore, sort the customers according to the increasing order of demand so that maximum number of customers can be satisfied. Complete the function filledOrders in the editor below. 2), Solution: Minimum Remove to Make Valid Parentheses, Solution: Find the Most Competitive Subsequence, Solution: Longest Word in Dictionary through Deleting, Solution: Shortest Unsorted Continuous Subarray, Solution: Intersection of Two Linked Lists, Solution: Average of Levels in Binary Tree, Solution: Short Encoding of Words (ver. This is part of a series of Leetcode solution explanations (index). That would mean that our answer could then be found by comparing the highest value in each bucket with the lowest value in the next occupied bucket. Therefore, sort the customers according to the increasing order of demand so that maximum number of customers can be satisfied. Once unpublished, this post will become invisible to the public and only accessible to seanpgallivan. Identify those arcade games from a 1983 Brazilian music video. Remove Duplicates From an Unsorted Linked List, LeetCode 1839. Start traversing array in reverse order. What we need to do is to find a way to group together numbers in such a way as to allow us to check the larger gaps between consecutive numbers. (Jump to: Problem Description || Solution Idea). Binary Tree Maximum Path Sum, LeetCode 153. Minimum Interval to Include Each Query, . Let's see the solution. Most upvoted and relevant comments will be first. Premium. 157 more parts. Note that the implementation doesnt create a single sorted list of all events, rather it individually sorts arr[] and dep[] arrays, and then uses merge process of merge sort to process them together as a single sorted array. code of conduct because it is harassing, offensive or spammy. 1), Solution: The K Weakest Rows in a Matrix (ver. Shortest Path in a Hidden Grid, LeetCode 1779. Examples: Constraints: 1 <= <= k <= n <= 10^5 speed.length == n efficiency.length == n 1 <= speed [i] <= 10^5 Bulk update symbol size units from mm to map units in rule-based symbology. To keep track of the sorted order of speeds of the engineers in our available pool, we can use a min priority queue (sppq) or min heap (spheap) structure. Else return it. (Not sure if I covered all edge cases.). 1), Solution: The K Weakest Rows in a Matrix (ver. Library implementations of Sorting algorithms, Maximum sum of at most two non-overlapping intervals in a list of Intervals | Interval Scheduling Problem, Find Non-overlapping intervals among a given set of intervals, Check if any two intervals intersects among a given set of intervals, Check if any K ranges overlap at any point, Maximum number of operations required such that no pairs from a Matrix overlap, Maximum rods to put horizontally such that no two rods overlap on X coordinate, Maximum prefix sum which is equal to suffix sum such that prefix and suffix do not overlap, Minimum time at which at least K out of N circles expanding 1 unit per second overlap, Find time required to reach point N from point 0 according to given rules. Dot Product of Two Sparse Vectors, LeetCode 1644. Number of Orders in the Backlog, LeetCode 1802. Input: The first line of input contains two integers n and d; next line contains two integers a and b. It will become hidden in your post, but will still be visible via the comment's permalink. class Solution { A widget manufacturer is facing unexpectedly high demand for its new product,. Store the maximum value of element till ith element i.e. Ryan Carniato and Dan Abramov discuss the evolution of React! 1st query: nums = [2,3,4,7], k = 5 since 2 XOR 3 XOR 4 XOR 7 XOR 5 = 7. Consider adding an explanation to help future visitors learn important elements of your solution, so they can apply this info to their own coding issues. Count Nice Pairs in an Array, LeetCode 1815. Evaluate the Bracket Pairs of a String, LeetCode 1808. acknowledge that you have read and understood our, Data Structure & Algorithm Classes (Live), Data Structure & Algorithm-Self Paced(C++/JAVA), Android App Development with Kotlin(Live), Full Stack Development with React & Node JS(Live), GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Sort an array of 0s, 1s and 2s | Dutch National Flag problem, Sort numbers stored on different machines, Sort an array according to count of set bits, Sort even-placed elements in increasing and odd-placed in decreasing order, Inversion count in Array using Merge Sort, Find the Minimum length Unsorted Subarray, sorting which makes the complete array sorted, Sort n numbers in range from 0 to n^2 1 in linear time, Sort an array according to the order defined by another array, Find the point where maximum intervals overlap, Find a permutation that causes worst case of Merge Sort, Sort Vector of Pairs in ascending order in C++, Minimum swaps to make two arrays consisting unique elements identical, Permute two arrays such that sum of every pair is greater or equal to K, Bucket Sort To Sort an Array with Negative Numbers, Sort a Matrix in all way increasing order, Convert an Array to reduced form using Vector of pairs, Check if it is possible to sort an array with conditional swapping of adjacent allowed, Find Surpasser Count of each element in array, Count minimum number of subsets (or subsequences) with consecutive numbers, Choose k array elements such that difference of maximum and minimum is minimized, K-th smallest element after removing some integers from natural numbers, Maximum difference between frequency of two elements such that element having greater frequency is also greater, Minimum swaps to reach permuted array with at most 2 positions left swaps allowed, Find whether it is possible to make array elements same using one external number, Sort an array after applying the given equation, Print array of strings in sorted order without copying one string into another. very good point about the sorting; didn't even think of that. Input: nums = [0,1,2,2,5,7], maximumBit = 3, vector getMaximumXor(vector& nums, int maximumBit) {, for (int i = nums.size() - 1; i >= 0; i--) {. Output: Print the maximum number of customers that can be satisfied and in the next line print the space-separated indexes of satisfied customers. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type. document.getElementById( "ak_js_1" ).setAttribute( "value", ( new Date() ).getTime() ); Your email address will not be published. acknowledge that you have read and understood our, Data Structure & Algorithm Classes (Live), Data Structure & Algorithm-Self Paced(C++/JAVA), Android App Development with Kotlin(Live), Full Stack Development with React & Node JS(Live), GATE CS Original Papers and Official Keys, ISRO CS Original Papers and Official Keys, ISRO CS Syllabus for Scientist/Engineer Exam, Introduction to Greedy Algorithm Data Structures and Algorithm Tutorials, Greedy Algorithms (General Structure and Applications), Difference between Greedy Algorithm and Divide and Conquer Algorithm, Comparison among Greedy, Divide and Conquer and Dynamic Programming algorithm, Activity Selection Problem | Greedy Algo-1, Maximize array sum after K negations using Sorting, Minimum sum of absolute difference of pairs of two arrays, Minimum increment/decrement to make array non-Increasing, Sum of Areas of Rectangles possible for an array, Largest lexicographic array with at-most K consecutive swaps, Partition into two subsets of lengths K and (N k) such that the difference of sums is maximum, Program for First Fit algorithm in Memory Management, Program for Best Fit algorithm in Memory Management, Program for Worst Fit algorithm in Memory Management, Program for Shortest Job First (or SJF) CPU Scheduling | Set 1 (Non- preemptive), Job Scheduling with two jobs allowed at a time, Prims Algorithm for Minimum Spanning Tree (MST), Dials Algorithm (Optimized Dijkstra for small range weights), Number of single cycle components in an undirected graph, Greedy Approximate Algorithm for Set Cover Problem, Bin Packing Problem (Minimize number of used Bins), Graph Coloring | Set 2 (Greedy Algorithm), Greedy Approximate Algorithm for K Centers Problem, Approximate solution for Travelling Salesman Problem using MST, Greedy Algorithm to find Minimum number of Coins, Buy Maximum Stocks if i stocks can be bought on i-th day, Find the minimum and maximum amount to buy all N candies, Find maximum equal sum of every three stacks, Divide cuboid into cubes such that sum of volumes is maximum, Maximum number of customers that can be satisfied with given quantity, Minimum rotations to unlock a circular lock, Minimum rooms for m events of n batches with given schedule, Minimum cost to make array size 1 by removing larger of pairs, Minimum cost for acquiring all coins with k extra coins allowed with every coin, Minimum increment by k operations to make all elements equal, Find minimum number of currency notes and values that sum to given amount, Smallest subset with sum greater than all other elements, Maximum trains for which stoppage can be provided, Minimum Fibonacci terms with sum equal to K, Divide 1 to n into two groups with minimum sum difference, Minimum difference between groups of size two, Minimum Number of Platforms Required for a Railway/Bus Station, Minimum initial vertices to traverse whole matrix with given conditions, Largest palindromic number by permuting digits, Find smallest number with given number of digits and sum of digits, Lexicographically largest subsequence such that every character occurs at least k times, Maximum elements that can be made equal with k updates, Minimize Cash Flow among a given set of friends who have borrowed money from each other, Minimum cost to process m tasks where switching costs, Find minimum time to finish all jobs with given constraints, Minimize the maximum difference between the heights, Minimum edges to reverse to make path from a source to a destination, Find the Largest Cube formed by Deleting minimum Digits from a number, Rearrange characters in a String such that no two adjacent characters are same, Rearrange a string so that all same characters become d distance away.