Published On Sep 23, 2024
Question link:- https://leetcode.com/problems/find-th...
we are given two arrays with positive integers arr1 and arr2.
A prefix of a positive integer is an integer formed by one or more of its digits, starting from its leftmost digit. For example, 123 is a prefix of the integer 12345, while 234 is not.
A common prefix of two integers a and b is an integer c, such that c is a prefix of both a and b. For example, 5655359 and 56554 have a common prefix 565 while 1223 and 43456 do not have a common prefix.
You need to find the length of the longest common prefix between all pairs of integers (x, y) such that x belongs to arr1 and y belongs to arr2.
Return the length of the longest common prefix among all pairs. If no common prefix exists among them, return 0.
My Approach:- I am keeping it very simple, storing all the values of first array as a string in a trie, and then one by one searching the length of prefix available in Trie, for each words and keep maximum length encountered as a common prefix in trie.
counting Sort :-
• Sort an Array in O(n) |Counting Sort ...
DSA Algorithms :-
• Topological sorting in Hindi | Topolo...
Design HLD:-
• Design E-commerce website | Design Am...
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
#interviewpreparation #interview_ds_algo #hinglish