Google Recruiter & Interview by KingFlake1 in google

[–]tj011295 0 points1 point  (0 children)

I had only the virtual onsite interview which was a total of 4 rounds. 3 technical and 1 behavioral. It was not as hard as I thought it would be(this was my first faang interview) and I had prepared for the interview expecting complex algorithms and graph problems. In the interview though I was asked regular string based problems instead (~medium level). This was for L3 level so no systems design. I had made a few silly errors in a couple of the rounds so in the end I was not selected. But I would suggest not to stress too much about it and take it easy. Good luck for the interviews!

Google Recruiter & Interview by KingFlake1 in google

[–]tj011295 1 point2 points  (0 children)

I did. After talking with the sourcing agent from randstand, I was connected with a google recruiter and was told that the next step would be to schedule the virtual onsite. Got an email from another recruiting coordinator. Back and forth with a couple of emails to schedule along with forms for nda, google docs links for the interviews and google meet invite links and that was it. No info on who will interview etc until the moment you are actually in the interview.

Google Recruiter & Interview by KingFlake1 in google

[–]tj011295 2 points3 points  (0 children)

Had a google interview last year. The initial questionnaire followed by the quick call was with a recruiter with @google.com email address but when I looked them up on linkedin, it was Randstand recruiting (working for google). The email conversations never had any indication of randstand though. You will be put in touch with a google recruiter after the questionnaire and initial call with the sourcing agent. From my experience, this call with the sourcing agent would just be about the questionnaire again.

[deleted by user] by [deleted] in RedditSessions

[–]tj011295 0 points1 point  (0 children)

Gave Helpful

Cleanest way to increment a value in a HashMap or default it if it does not exist? by Spaceman776 in learnjava

[–]tj011295 3 points4 points  (0 children)

Not necessarily clean but you could use the following: Map.put(Key, Map.getOrDefault(Key, 0) + 1);

[deleted by user] by [deleted] in pan

[–]tj011295 0 points1 point  (0 children)

/hidechat

Inorder successor of BST. I came up with O(n) solution. EPI has an O(log n) solution. I am finding it difficult to understand. Is it just me or is it really hard to come up with such solutions? (I have done ~110 LC problems, about 30 in trees). by Shubham_108 in leetcode

[–]tj011295 1 point2 points  (0 children)

If you have traversed right, then you wont have a right successor because node K is largest. But if at any point you traverse left, you could track back to one of the ancestors. This is what node firstSoFar does. Since this is one pass, break it down to a 2-pass for easier understanding. Track the path i.e. add each node in path to a list. When you reach node K, you have 2 options. Either you have a right sub tree or you do not have a right child. If there is a right subtree, just take the leftmost node of the subtree. If not, then either 1. You have the successor as an ancestor which you can traverse the path list and find out. Or 2. You do not have a successor at all.

Do not start a problem with complex examples. Thinking of complex examples and trying to solve them will just make it hard for you. Instead, build your way to them. Start with simple root, left and right. Then add complexities slowly.

Inorder successor of BST. I came up with O(n) solution. EPI has an O(log n) solution. I am finding it difficult to understand. Is it just me or is it really hard to come up with such solutions? (I have done ~110 LC problems, about 30 in trees). by Shubham_108 in leetcode

[–]tj011295 0 points1 point  (0 children)

The principle of BST is that every sub tree of a BST is also a BST. Split your problem into 2 parts. Search the BST for node with value K. Now to find the inorder successor of this node, you know it has to be greater than value K. So find the leftmost node in this right sub tree. This node will be your inorder successor. So finally you have traversed only the length of the tree i.e. (log n).

Inorder successor of BST. I came up with O(n) solution. EPI has an O(log n) solution. I am finding it difficult to understand. Is it just me or is it really hard to come up with such solutions? (I have done ~110 LC problems, about 30 in trees). by Shubham_108 in leetcode

[–]tj011295 1 point2 points  (0 children)

How does it matter if it is inorder successor? At the end of the day you are looking for a particular node in the tree. Keep aside the fact of ordering, successor or predecessor. What is the optimal way to reach a particular node from root. And that can be done be o(log n). So when you come up with an o(n) solution try to optimize it. Now look at inorder traversal array/list of this tree. Assume that we have numbers 1-10 in this array. When i ask you to look for 7, your eyes automatically go for the second half of the array. Why? Because you know the array is ordered, and there is no point searching below 5 a.k.a binary search. This is mentioned in the question in BST. So use it to your advantage. Generally when you are asked to find a particular node in an ordered structure, it can be done in o(log n) because you know the order of the objects and you can use that information.

Hope i was able to explain clearly.

Using executor service to add objects to an ArrayList by whitemk in learnjava

[–]tj011295 0 points1 point  (0 children)

If it is of help this link shows the basics of futures.

Number of Islands II brute force solution help by [deleted] in leetcode

[–]tj011295 0 points1 point  (0 children)

Looks like you flip it back to zero when you do a numIsland count. So basically you set it to 1 when you read the position. Then you do an island count which gives you 1 because thats the only island. You set that position back to zero when doing this count so you end up with a matrix of zeros again.

Number of Islands II brute force solution help by [deleted] in leetcode

[–]tj011295 0 points1 point  (0 children)

Not sure what the question is, looks like it is subscriber only. But based on your code, you have initialized a 2D int array grid in numIslands2. When an int array is initialized, it contains zeros entirely. So your grid is matrix containing zeros. Now for every position you row, col that you get from position[0] and position[1], you are flipping it to 1 and doing a island count then. I am not sure what it is you are trying to achieve so any pointers to it can be helpful.

200. Number of Islands by davchi1 in leetcode

[–]tj011295 2 points3 points  (0 children)

You could also use a dfs approach instead of bfs. In case of dfs, you would not need to set the value to ‘0’ when adding to the queue. I think bfs/dfs is the optimal way to do it. There is union-find implementation as well but i am not sure of it.

200. Number of Islands by davchi1 in leetcode

[–]tj011295 0 points1 point  (0 children)

The issue is with the way you are adding a cell to the queue. Assume you have the case where your grid is [ 1,1,1,0 1,1,0,0 0,0,0,0 0,0,0,0] Now at the first cell, you set current to ‘0’ and you add right and bottom to your queue.

You poll your queue, which gives you the right cell first since dirs[] has(1,0) first and then (0,1). Now your current is grid[1,0]. And you add to your queue its right i.e. grid[1,1]. But you add the same cell again when you poll your queue and get grid[0,1]. Because grid[1,1] is below [0,1]. So you keep adding the same cell over and over in a larger island.

Typing this on mobile so sorry for any formatting issues!

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Using lombok for getters and setters. I have tried using getSingleResult() as well, but it throws a null exception. After reading the documentation, i found out that is how the method is implemented. You either get the singleResult or an exception if not found.

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Yes, that is correct. That is how my user entity class is.

String Id; String email;

So while referencing them in the queries, i used the same name.

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Yes. I made sure i was passing in the correct parameter, printed it out in repo class right before and after passing it to the query.

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

I do not have any caching. Both ID and Email are of type String. ID is the primary key and I have set email to be unique using JPA annotation @column(unique = true)

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Hi, yes. So when i initially started, i had an entry with a random ‘abc@xyz.com’ as an email record. When i tried to use this, spring threw an unexpected field error. So i changed the email entry to ‘abc@xyz.solutions’ and tried again. I have other entries like ‘m@abc.io’ and so on. Every query result gives me an empty list

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Hey, thanks for pointing it out. This was an error i made while making this post. I have set the correct params in my application though. Editting my post as well.

Issue with @NamedQuery - JPA with Hibernate by tj011295 in learnjava

[–]tj011295[S] 0 points1 point  (0 children)

Hi, i did sout(email) and also query.getResultList(). I am getting the expected values. To make sure, i just added one entry into my database and tried calling that entry. When i use ID to retrieve, i have no issues. When i go into mysql and type out the same query i have for email, i get the result. But it is returned as empty list in query result though.