Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,152,482 members, 7,816,141 topics. Date: Friday, 03 May 2024 at 06:25 AM |
Nairaland Forum / Science/Technology / Programming / Can You Solve This Google Coding Interview Problem? (pics) (3182 Views)
Please How Did You Solve Your Power Need Without Use Of Generator / I Have A Google Coding Interview Coming Up. I’m Panicking!!! / Turing.com Live Coding Interview Preparation (2) (3) (4)
(1) (2) (3) (4) (5) (Reply) (Go Down)
Re: Can You Solve This Google Coding Interview Problem? (pics) by truthCoder: 11:34am On Dec 21, 2022 |
TastyFriedPussy: To solve this problem, you can iterate over the nodes and use the node colors and values to reconstruct the tree. Here's a rough outline of a possible solution: Start with an empty list of edges. Iterate over the nodes, starting from the first one. For each node, do the following: If the current node is white, find the next black node in the list and create an edge between the two nodes with a value equal to the difference between their sv values. If the current node is black, find the next white node in the list and create an edge between the two nodes with a value equal to the difference between their sv values. Repeat this process until you have processed all the nodes. function restoreTree(n: number, nodes: Array< [number, number] > ) : Array < [number, number, number] > { const edges: Array<[number, number, number]> = []; for (let i = 0; i < n; i++) { const [ci, si] = nodes[i]; let j = i + 1; while (j < n && nodes[j][0] === ci) { j++; } if (j < n) { const [cj, sj] = nodes[j]; edges.push([i + 1, j + 1, Math.abs(si - sj)]); } } return edges; } Courtesy, ChatGPT. 2 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 11:43am On Dec 21, 2022 |
sqlPAIN: If not for frontend and backend u won't be here on Nairaland typing trash and posting copied solution's 5 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by truthCoder: 11:46am On Dec 21, 2022 |
is coding all about data structures and algorithms Coding involves many different aspects, and data structures and algorithms are just one part of it. In general, coding involves designing, writing, testing, and debugging code to solve problems or accomplish specific goals. Data structures and algorithms are important tools that are used to solve problems and perform tasks in an efficient and effective way. They allow you to organize and manipulate data in a way that is optimized for a particular purpose, such as searching, sorting, or storing data. However, there is much more to coding than just data structures and algorithms. Other important aspects of coding include: Designing and planning: This involves understanding the problem or goal, determining the requirements and constraints, and designing a solution that meets those requirements. Writing code: This involves writing the actual code that implements the solution, using a programming language and following best practices for code organization, readability, and maintainability. Testing and debugging: This involves testing the code to ensure that it works correctly, and debugging any issues that arise. Collaborating and communicating: This involves working with other developers and stakeholders, such as project managers and users, to ensure that the solution meets their needs and meets project goals. Overall, coding involves a wide range of skills and activities, and data structures and algorithms are just one part of the picture. 4 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 11:51am On Dec 21, 2022 |
sqlPAIN: It will weed u out first. You're the worst of the worst. U didn't even attempt the question in order to learn from your mistake assuming u got it wrong so you'd try again. U didn't even rename some variables or change some patterns so your cheat will be difficult to spot. U pasted everything verbatim. In your attempt to prove to everyone that your C++ or whatever Grandpa language you're learning is superior u went ahead to copy everything word for word.... Copying, the worst form of cheating is what u indulge in. You're the quackest of all the quack programmers.... worst of all u still have a loud mouth. ChatGPT will even spit on u b4 weeding u out. 8 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by truthCoder: 12:04pm On Dec 21, 2022 |
Wow, it's really impressive how there are all these self-proclaimed geniuses out there who think they're the best because they can answer some trivia questions about data structures and algorithms. Newsflash: that doesn't mean you're actually a good coder. In fact, most of these DSA-obsessed babies don't have a single practical project to their name. They've never solved a real-life dev problem, let alone achieved 100 MAU on anything. And yet, they have the audacity to beg for hand-me-down laptops and criticize others who can afford brand new desk set-ups. But hey, it's not like being a good coder is about being able to think on your feet and adapt your current knowledge to solve real problems. Oh wait, that's exactly what it's about. That's why teams are made up of different people with different skills, not just the CTO. But I'm sure these yapping puppies know better than that. Carry on, guys 4 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by airsaylongcome: 12:07pm On Dec 21, 2022 |
Lol! Nice one @GreatIgboman. Something was so damn off with a younging rushing out with a solution. And doing so in C++. Valid points though about the need to have more posts and engagements about DSA. Not just talking about it , but more hardcore stuff. Anyway for me TastyFriedWhatever is the same person as sqlPAIN. 9 Likes 1 Share |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 12:08pm On Dec 21, 2022 |
airsaylongcome: I swear 100%. 2 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 12:12pm On Dec 21, 2022 |
airsaylongcome: There's no single Algo question that have been posted on Nl without a valid unique solution lol. trust me... I believe I've searched for them all (the majority of them)... even during the time when dhtml was active here... far back as 10+ years ago. This question this person is calling ordinary isn't ordinary but difficult. To solve it u need to leave wateva youre doing and focus on itt.... even if uv been solving algo questions consistently. People don't just engage with algo post, that's the reality... if u wan to learn algorithms... they're many websites and forum for that. |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 12:22pm On Dec 21, 2022 |
sqlPAIN I dare u to explain your solution line by line. chances are, u don't even understand what you've pasted. 5 Likes 1 Share |
Re: Can You Solve This Google Coding Interview Problem? (pics) by truthCoder: 12:26pm On Dec 21, 2022 |
GREATIGBOMAN: 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by sqlPAIN: 12:33pm On Dec 21, 2022 |
GREATIGBOMAN:Even if I did, you'd not be smart enough to understand....so stick to react JS and co |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 12:50pm On Dec 21, 2022 |
sqlPAIN: U can't, because there's no place online to copy the explanation. I'm very sure you're not older than 20years of age |
Re: Can You Solve This Google Coding Interview Problem? (pics) by qtguru(m): 12:57pm On Dec 21, 2022 |
GREATIGBOMAN: That will explain alot 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by OlawaleBammie: 1:09pm On Dec 21, 2022 |
sqlPAIN:and u tink u re making sense?? Funny you. 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by OlawaleBammie: 1:14pm On Dec 21, 2022 |
Kaycee54321:it's in their DNA When dey know small thing, they start to dey misbehave People like them hate it when u know as much as they know, the always want to be regarded as bozz, they don't want competition, the moment the realize u re on the right way they start exhibiting hatred. 1 Like 1 Share |
Re: Can You Solve This Google Coding Interview Problem? (pics) by OlawaleBammie: 1:15pm On Dec 21, 2022 |
sqlPAIN:are u done?? |
Re: Can You Solve This Google Coding Interview Problem? (pics) by SavageBoy: 1:46pm On Dec 21, 2022 |
Fact: Nobody get mouth like Greatigboman for here. The guy just dey give me joy When I saw the rubbish post, I just knew it was that tasty-fried-idiot. Like what someone once told him here, na yahoo you go later use your Laptop do. 4 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by spartan117(m): 2:26pm On Dec 21, 2022 |
Lol this thread is pure comedy GREATIGBOMAN be calming down small sqlpain aka tastyfried hope you have learnt your lesson? Go and sin no more |
Re: Can You Solve This Google Coding Interview Problem? (pics) by airsaylongcome: 2:30pm On Dec 21, 2022 |
SavageBoy: Na still GIM tell am say na yahoo hin go use that laptop do las las 2 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Maxxim: 3:22pm On Dec 21, 2022 |
spartan117: |
Re: Can You Solve This Google Coding Interview Problem? (pics) by SavageBoy: 4:11pm On Dec 21, 2022 |
airsaylongcome: Lol. With this his toxic and negative attitude, even if he abandons programming for yahoo, he wont still succeed. He's busy calling out people that are doing better than him. None of the persons he called out has ever blamed or cursed their father. Do you even expect someone that can call out his father in a public forum like this to be sensible and successful in life? He claim he is not doing programming for the money, yet he's creating a thread on how demotivating learning programming can be without money. Tastyfried idiot or whatever they call you. Programming is not for you. Better sell that your laptop and use the money to search for a solution to your problem. 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by niel63(m): 4:13pm On Dec 21, 2022 |
I am a Web Dev who likes React, Vue, Svelte and those small small UI toolkits that makes web dev look like telling a story. And you know what, I like am die. I am in agreement that I know nothing but I hope you know its just a matter of me deciding to pick pick up another language if I feel the need to... as I am currently trying to choose between golang and rust right now And I promise to drop all these in a heartbeat the moment I find something even more lucrative and enriching than this... you know why? Na money I dey find. If you like wipe head for wall like 55 times, e no go still change the fact say everything dey for us to learn. I am no pro programmer doing some tricky DSA stuffs like that small 12years old boy wey like to talk about IBM Watson and AI like say na him papa do am. Being happy is a gift and you choose your path. Some people do not know basic html structure and they are in tech making big money. So, tech isn't about being bitter about others... rather, it's about solving problems in real life even if it's just creating a shopping cart. You're so good, yet you let someone else create ChatGPT. You're a mumu boy!!! 4 Likes |
Re: Can You Solve This Google Coding Interview Problem? (pics) by namikaze: 4:18pm On Dec 21, 2022 |
@sqlPAIN I haven't been online for the past few days and I usually don't even check the programming section because it's usually dry. I'll try solving this today 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by airsaylongcome: 4:21pm On Dec 21, 2022 |
SavageBoy: I just see him as a troll that enjoys getting a lot of mentions for “going against the grain”. Never take him or his alt seriously. Empty barrels they say….(you know the rest) 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 4:38pm On Dec 21, 2022 |
niel63: |
Re: Can You Solve This Google Coding Interview Problem? (pics) by jbreezy: 8:41pm On Dec 21, 2022 |
Lol…this section ehn |
Re: Can You Solve This Google Coding Interview Problem? (pics) by chiedozie198100: 11:57pm On Dec 21, 2022 |
Help me rate this app. Thanks. https://play.google.com/store/apps/details?id=com.countriesinafrica.africancountriesquizgame |
Re: Can You Solve This Google Coding Interview Problem? (pics) by namikaze: 9:19am On Dec 22, 2022 |
much harder than I imagined, I've been able to come up with a solution though, let me clean it up. hopefully it passes all test cases 1 Like 1 Share |
Re: Can You Solve This Google Coding Interview Problem? (pics) by namikaze: 10:16am On Dec 22, 2022 |
1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by namikaze: 10:22am On Dec 22, 2022 |
replace nodes with either nodes_test or nodes_test2 in res = solve(nodes)to test with the sample data. |
Re: Can You Solve This Google Coding Interview Problem? (pics) by namikaze: 10:29am On Dec 22, 2022 |
The approach is; pick the node with the max sv value, either white or black, and then distribute value (by substracting from the sv) to the smallest nodes of the opposite color untill sv becomes zero or the smallest opposite color node is bigger, then repeat with the next max sv node, nodes visited are not reused. this should work for valid inputs 1 Like |
Re: Can You Solve This Google Coding Interview Problem? (pics) by Nobody: 5:01pm On Dec 22, 2022 |
namikaze: Add screenshots with your code and let's see it running and working pls Not everyone have Jupiter installed to run your python code to check if it's correct. |
Anybody Here Know How One Can Password/encrypt Sqlite Database in C++? / Paid Job: A Magento 2.0 Plugin Developer Is Required For A Quick Job [Closed] / Why Will The Fg Allow Sidmach Tech Take 100% Control Of Jamb Website?
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 79 |