Комментарии:
Thank you guys for these amazing resources. It does make me feel less competent and ready but we can only learn hey.
ОтветитьHii
ОтветитьMy Code :
nums = input('Enter Numbers ').split()
numlst = []
for i in nums:
k =int(i)
numlst.append(k)
for n in range(len(numlst)):
cns = 8-numlst[n]
if cns in numlst:
print('Yes')
break
else :
if n == len(numlst)-1 :
print('No')
great video. thanks
Ответить2016: 2 sum
2022: solve the travelling salesman problem in polynomial time 😭
can anyone explain to me the condition in if statement ... thanks
ОтветитьAwesome. Thanks for this, is really helpful. You could use a Bloom Filter instead of the hash set to save on space complexity(O(1)) as per you only need to know if the complement is NOT in the list.
Ответить👍
ОтветитьNice to know I would have failed in the first 30 seconds...
ОтветитьAre they trying to send message to the candidates to feel more comfortable while having the Coding interview? And encourage them to ask questions if they are not clear what they are going to solve?
ОтветитьI have a long way to go... But this is a motivation
ОтветитьReally helpful video. This reminds me of the classic Two Sum problem on LeetCode. Since we are told a pair of numbers equals a target sum, we can say that x + y = target. And solving for y (complement of x), we see that y = target - x. Therefore, we can just walk through the input sequence and for every element, insert it into a hash set while performing a lookup in the hash set to see if for a given `x` value (arr[i]) we can find a `y` that satisfies x + y = target.
ОтветитьAnd binary had confirmed with asking decimals !
ОтветитьFirst pair you change to no 9 to 7 and give command to no and yes then click 9 error will appear
ОтветитьActually, the find() method for sets has a logarithmic lookup time, which would make the complexity O(n log n) instead of liniar.
ОтветитьHallo Google I am india for student the following URL and to join to google jobs for student......
ОтветитьThank You very much
Ответитьa small problem with empty data: data.size() is unsigned int, after minus one, it will become extremely big, you have to convert it to int first.
Ответитьinteresting, i was thinking since it is sorted to start checking at the end, skipping numbers which are too large and when you get to number that is <= 8, you would start doing binary search looking for the complement with the rest of the array (the beginning part) but that would still be n log n I think
ОтветитьWhat if we use if -else loop to get output
ОтветитьFor this problem specifically, since there will only be an addition of two number, all you need to do is to subtract one elements of the arrays from 8. If the result matches one of the remaining elements then the number you subtract from and the result will be the pair of two number that sums up to 8. You will only have to do this four times or the number of elements you have in an array.
ОтветитьStrange question: What is the size of whiteboard in feet? 3x2?
Ответить`+data[hi]`… AND… You've just invoke undefined behavior.
EDIT: Wait nevermind. My bad. Implicit conv… Well technically it's still UB. Just way earlier. Signed overflow is still ub (granted if you that large a vector you might want to rethink something. (also infinite loop but that's cheating). Still why use an int where you get a `std::vector<int>::size_type` smh. And that while loop confuses me. (Besides being potentially wrong) I'm way too sleep deprived for that amount of questions. iterators wouldn't kill either. (So many whys)
Fix is obviously don't pass keep a `std::numeric_limits<int>::max() + 2ULL` sized vector to the function…
Or don't have so many implicit conversations.
The answer in itself is fine though. (I'm just over sensitive to potential UB)
I did this problem on leetcode when i was like 12yo
ОтветитьNice mam or sir ✓
ОтветитьI love the acting from the guy pretending to be looking for the answer. Thankfully for him he is an engineer and not an actor XD
ОтветитьIn the loop we can subtract the value like :-( sum - value ) and then find the output in before Position. if it found it return true and if not then false. In this case we not need to store any data.
ОтветитьIt's useful for me❤️
ОтветитьI have a lot do .now .I need hard thanks Googler ,its very motivating
Ответитьwaw at it's very good. I need additional information
ОтветитьThis is the math of common sense 😂
ОтветитьI don't think He would take such a long amount of time
its just a matter of 2 min for someone who is a intermediate even
LOL
he is pretending to be slow
LOL
Well The Question goes like this I suppose:
lets say
(python 3)
lst = [1,2,3,4,5,6]
for i1 in lst:
i2 = 8 - i1
if i2 in lst:
print(i1, i2)
we get the pairs
Hello 🤗, I am a student studying in class 11 with arts stream. I am thinking that can I be a part of Google if I am arts stream student. My aim is to get job in Google. Can I get it or not? Please respond 🤗🤗 ..i want to know. Which degree will be best for me to get job in Google. Actually, I am a student from India. From class 6 my aim is to be a part of Google. This present year, I had passed out class 10 board exams. Before getting results my choice was to choose Science stream but I had opted Arts because science marks was poor. In other subjects like English I scored 81% and in social science I scored 89%. My mood was totally bad that I can't get job in IT companies 😣. But I have seen that the people who are working in Google have said that anyone from any stream can get job in Google, but you must have creative skills and many more. I just asking one question please reply can I get job in Google?
Hope you will reply sir.
it seems like a competitive programming problem
Ответитьanother checking possibility to reduce time complexity:
if the asked sum is even and
the adding numbers should be (even and even) or (odd and odd)
if the asked is odd
the adding numbers should be (even and odd)
Did commerce students get job in Google
ОтветитьSince comp.find is logarithmic and you are repeating this for every value in data, then the actual time complexity of the function is O(N*logN). Why did they say it was linear?
ОтветитьWhat I realized from interview questions is that mostly they based on data structure and algorithm. Personal thought though.
Ответить1st problem I did in LeetCode TwoSum problem
ОтветитьCan i use Hindi language for communicate with Google recruiter
Ответить1x2+3+3=8 excluding √
1x2+4+2=8
Oh okay 😊👍👍😂👌.
ОтветитьEdge case: negative integers
ОтветитьOMG! i can only do sorting!!! even odd!
ОтветитьCould someone be so kind of give me feedback please?
const findPair = (nums, target) => {
let result = [];
const tempArr = nums.filter(num => num < target);
tempArr.forEach(num => {
let dif = target - num;
let r = tempArr.find(n => n === dif);
if (r) {
if (num + r === target) result = [num, r];
}
});
return result;
};
I'd really appreciate it, it's a messy code but it seems to work XD
These questions are so easy for me..
Ответить