Technical Interview - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Technical Interview (481 Views)
| Technical Interview by LooneyLester(op): 6:54pm On Dec 31, 2023 |
Can you pass the Rockstar Games Job Interview?
|
| Re: Technical Interview by Stephen0mozzy: 7:20pm On Dec 31, 2023 |
Thinking.... |
| Re: Technical Interview by LikeAking: 9:50am On Jan 01, 2024 |
Very cheap |
| Re: Technical Interview by Karleb(m): 12:49am On Feb 17, 2024 |
I may be wrong o but let me just tell you what I have seen so far. The second loop should run to i and not count. BitCount method is supposed to take in integer but in the usage, a boolean is being passed. It should be BitCount(intArray[i]) <= BitCount(intArray[j]). I also think in the BitCount, i should be decremented like so i-- outside the if statement in the while loop so it doesn't loop forever. I presume i>>=1 is the statement counting the bits, then it should be before the if statement and the count should be count += i. Anyway, type that to CHATGPT and see what it gives. |
| Re: Technical Interview by airsaylongcome: 3:37am On Feb 17, 2024 |
Karleb:Output from CHATGPT Here's the corrected version of the code:
Changes made: 1. Corrected the bitwise OR (`|`) to a bitwise AND (`&`) in the `BitCount` function to properly count the number of set bits. 2. Fixed the missing curly braces and return statement in the `BitCount` function. 3. Fixed the loop conditions in the `SortIntsByBitCount` function to avoid going out of bounds and to properly compare elements. 4. Added missing parameter `intArray[j]` in the `BitCount` function call within the `SortIntsByBitCount` function. 5. Swapped elements correctly in the `SortIntsByBitCount` function when the number of set bits is different. |
| Re: Technical Interview by Karleb(m): 8:01am On Feb 17, 2024 |
airsaylongcome:Thank you. See as I embarrass myself up there. ![]() It's important to run it and be sure it's giving the right result. CHATGPT solutions are sometimes wrong. |
I Just Bombed A Technical Interview • Apparently Technical Interviews Arent Your Only Stumbling Block • Python for Non-Technical people • 2 • 3 • 4
Do You Need Help With Your School Programming Assignment • I Want To Start Programming • Accept Payment With Airtime Like Betpawa
