Comments (1)
It DOES NOT have to be this way. It is done this way for optimization. You can verify by commenting out those 3 lines at top and it will still work.
He is doing sort of binary search on input1, so he make sure input1 is smaller one. If both are of similar length and is not much different in length it doesn't matter. But think about skewed case when one is of length 10 vs another of length 10000. Then obviously, the median will be median of 5005th and 5006th element. If you pick longer one as first and do binary search it will take many more steps to reach final answer than if you chose smaller one for doing binary search.
from interview.
Related Issues (20)
- FenwickTree.java is not working properly.
- Time complexity for johnson's algorithm
- Interview
- Array given as test case is not sorted HOT 1
- MaxSumForNonAdjacentElements doesnt give correct result if first element of array is negative
- it should remove the allnodes.get(0).key
- Big O complexity of NumberOfPathsInMxNMatrix.java HOT 1
- shouldDeleteCurrentNode should also check if the current node is not having other word isEndOfWord as true.
- Fix the variable name in matrix multiplication problem
- countDownLatch.countDown() should be inside execute function
- Index access out of range in regex expression matching implementation.
- The project uses Gradle 2.11 which is incompatible with IDEA running on Java 10 or newer.
- MedianOfTwoSortedArrayOfDifferentLength.java Incorrect test case
- Edit Distance Recursive solution HOT 5
- Small improvement to the power of 2 loop
- how to add item from the search selection which item name is brown sugar and 1 KG from bigbasket
- Egg Dropping Puzzle & min jumps to reach the end
- Where do companies pull technical software developer interview questions from?
- What are all the common software development technical online assessments companies use?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from interview.