Sort the Jumbled Numbers | 2 Approaches | Leetcode 2191 | codestorywithMIK
Whatsapp Community Link : https://www.whatsapp.com/channel/0029...
This is the 40th Video of our Playlist "Strings : Popular Interview Problems" by codestorywithMIK
In this video we will try to solve a very good String Problem : Sort the Jumbled Numbers | 2 Approaches | Leetcode 2191 | codestorywithMIK
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Sort the Jumbled Numbers | 2 Approaches | Leetcode 2191 | codestorywithMIK
Company Tags : Will update soon
My solutions on Github(C++ & JAVA) - https://github.com/MAZHARMIK/Intervie...
Leetcode Link : https://leetcode.com/problems/sort-th...
My DP Concepts Playlist : • Roadmap for DP | How to Start DP ? | ...
My Graph Concepts Playlist : • Graph Concepts & Qns - 1 : Graph will...
My Recursion Concepts Playlist : • Introduction | Recursion Concepts And...
My GitHub Repo for interview preparation : https://github.com/MAZHARMIK/Intervie...
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Subscribe to my channel : / @codestorywithmik
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
Summary :
Approach 1: Converting to String
Time Complexity: O(n * d + n * log n)
Converting each number to a string and mapping digits takes O(n * d) time.
Sorting the vector of pairs takes O(n * log n) time.
Space Complexity: O(n + d)
Requires space for the vector of pairs (O(n)) and temporary strings (O(d)).
Explanation: This approach converts each number to its string representation, maps each digit using the provided mapping array, and converts the mapped string back to an integer. It then sorts the mapped numbers while maintaining the original indices, and constructs the result array based on the sorted order.
Approach 2: Without Converting to String
Time Complexity: O(n * d + n * log n)
Mapping digits directly and forming the mapped number takes O(n * d) time.
Sorting the vector of pairs takes O(n * log n) time.
Space Complexity: O(n)
Requires space for the vector of pairs (O(n)).
Explanation: This approach directly maps each digit of the number without converting the number to a string. It processes each digit, forms the mapped number, and stores it along with the original index. The mapped numbers are then sorted, and the result array is constructed based on the sorted order.
✨ Timelines✨
00:00 - Introduction
3:31 - Approach-1
10:20 - Coding Approach-1
16:53 - Approach-2
23:41 - Coding Approach-2
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #newyear2024