r/CS_Questions • u/vgraupera • Jun 13 '23
r/CS_Questions • u/ifelsestatement007 • Feb 25 '21
Unique Path. The question which has been asked by Amazon during the interviews
r/CS_Questions • u/drugsbowed • Aug 06 '19
How to build on the second question I had during this interview?
Just came off an interview and it bothers me that I couldn't get this question in time. The fact that I didn't complete the question and was only halfway through a brute force solution means I know I failed.
The question started with:
Given two strings, one input and one target string, give the indices that you would have to remove from the input string to match the target string.
My approach was to use two headers on both strings in a while loop, iterating thru and adding unmatched character indices to a list. The solution seemed to work, wasn't sure if it was optimal. Seeing as you'd have to iterate through the entire target string I was thinking it was a linear solution.
The second question went on to be:
If there are duplicates in the input string, change the function so that you can return the number of possibilities. So..
aaab ab
You can remove [0,1], [0,2], [1,2] to match the target string. Was kinda stumped here... my brute force solution was to take my returning list and work off it, I know the solution it would give would be [2], so check it's predecessors for the same value and see if they matched, adding to a total.
What's the better way or how would you guys approach it?
r/CS_Questions • u/Sroy20 • Jul 09 '18
Tried to make a comprehensive list of questions asked in Machine Learning interviews
r/CS_Questions • u/kpthunder • Nov 13 '11
Spellcheck
Given a list of words, write an algorithm that performs fast spell check for a given word. Your algorithm should be faster than O(n) (where n is the size of the dictionary).
You can choose the data structure you wish to use, the words are just supplied in a file so you can load them into memory.
Your spellchecker should be able to handle three cases:
Incorrect capitalization (e.g., bill => Bill, Reddit => reddit)
Repeated letters (e.g., ccccaaatttttt => cat)
Incorrect vowels (e.g., opun => open)
Your spellchecker should also be able to handle any combination of the above cases (e.g., pREsidaNt => president).
If the user has supplied a word that is royally screwed up and you can't find a suggestion, feel free to print a message saying so.
Extra Credit:
Also handle the case of missing letters (and combine this case with those above, e.g., calculat => calculate or calculator, FrUd => Fred or Fridge).
r/CS_Questions • u/Hardy_Nguyen • Jul 13 '22
Share the biggest achievements/contributions at work that you have made over the last 6 months But you have no impressive contributions
Hello everyone, I just joined this company five months ago ( Fresher )
I have a survey about performance review and I stuck with one question: " Share the biggest achievements/contributions at work that you have made over the last 6 months "
The problem is I just joined and spent most of the time dealing with simple or intermediate issues (I still need support from other members with difficult ones) therefore I don't think I have any significant achievements or contributions that are impressive enough to put in the survey.
Any advice or tips would be helpful
Thank you so much.
r/CS_Questions • u/Add1ctedToGames • Mar 15 '22
Are hash maps really as common of an interview question solution as satire/comedy channels make them out to be?
r/CS_Questions • u/pahalie • Mar 15 '22
Support Ukrainian Developers
Hey, redditors of the world!
Right now due to war in Ukraine thousands of developers have lost their jobs. I with my fellow coworkers from Ukraine have created a community of mid to senior level developers (web-dev, ML, cyber security, etc.) of more than 1200 people. The main asset of our community is speed - we have a great team of PMs, so any task can be distributed between many people and can be done faster than you could imagine - motivation it is x)
Now we are looking for outsourcing opportunities for them.
If you have any suggestions of how to approach this problem or maybe even have some opportunities for them we, Ukrainians, will deeply appreciate it! Thanks everyone in advance!
r/CS_Questions • u/how_you_feel • Mar 30 '21
At what scale or in what cases would you lean towards a denormalized and sharded cassandra data storage instead of the traditional B-tree indices of an RDBMS?
Going by my previous question, I got a good answer for why data in cassandra (or any NoSQL DB) lends itself better to sharding than an RDBMS. Tl;dr because relations in RDBMS prohibit them from being partitioned out efficiently, and NoSQL DBs circumvent this by denormalizing (i.e. duplicating) data storage.
Now the question arises, when do we want to absorb the cost of the added storage/expense and store data in cassandra as opposed to indexing the columns in something like MySQL? E.g. in a book-author-publisher-reader data model, you can either model it:
RDBMS
Books
| ID | Book (indexed) | Author (indexed) | Publisher (indexed) | other columns |
|---|---|---|---|---|
| 041 | HP | JKR | Bloomsbury | text |
| 134 | Artemis Fowl | Eoin Colfer | Apple | text |
| 643 | LoTR | JRR Tolkien | Orange | text |
| 124 | Goosebumps | RL Stine | Scholastic | text |
| 462 | Dune | Frank Herbert | Chilton | text |
Readers
| ID | BookID (indexed) | ReaderID (indexed) |
|---|---|---|
| 524 | HP | John14 |
| 123 | LoTR | John14 |
| 126 | Dune | John14 |
| 647 | Dune | Wayne56 |
| 647 | Goosebumps | Wayne56 |
| 647 | Dune | Alex89 |
| 647 | HP | Alex89 |
| 954 | Dune | Alice30 |
Quick queries using the index:
select * from Books where Author =..
select * from Books where Publisher =..
select * from Books where Publisher =..
select BookID from Readers where ReaderID=..
Cassandra
Denormalize data into 3 tables:
1) partition key - (Publisher, Book)
Allows you to get all books by a publisher. The second part of the key is the clustering key, which decides the ordering/sorting on file by cassandra. The first part is the primary key and gets hashed (consistent hashing) to pick out the cassandra node to go to.
2) partition key - (Author, Book)
Allows you to get all books by an author.
3) partition key - (Reader, Book)
What would be other pros/cons of each approach? I can think of:
Duplicate storage - more space needed for cassandra
Cassandra would be more expensive?
Can't do complex joins/aggregates in Cassandra (get all books written by this author read by these many readers) and would need to do them in the application.
Cassandra will be faster, or will it? We have the B-tree indices in RDBMS.
r/CS_Questions • u/RocketScienceGamer • Nov 02 '20
Elevator System Design | Object-Oriented System Design Interview Question
r/CS_Questions • u/latest_ali • Jul 27 '20
Can you explain race conditions in the context of inserting some values into the MySQL database?
So this was a technical question. Imagine you can update a least of devices in a devices table. You need to fetch the data and then update the information of the devices. What can go wrong with this?
My answer was that usually MySQL can handle atomic transactions but apparently I have had to talk about race conditions in this context. I have never dealt with this in my career and I would like to know about race conditions in the backend.
Thank you.
r/CS_Questions • u/how_you_feel • Jul 04 '20
What's the use of a wide-column NoSQL db such as Cassandra over a K-V store or a document based db?
Say we're making a simple photo app. This link says that we can store the image in S3 and now have a URL. Great. Next, we need a mapping of a UserID to the many images they've created. For this, it recommends Cassandra where the key would be UserID and the value would be the list of PhotoIDs stored in different columns.
However, why can't we use a document DB like mongo instead? It can have something like:
{
“UserID” : abc
“PhotoIDs” : {
url1,
url2,
url3,
..
}
}Or a persistent K-V store like DynamoDB?
What is Cassandra's column-based storage giving us here that these don't?
On a related note, I read that wide-column stores are commonly used for storing Internet of Things data and user profile data. What makes them suitable for these use cases?
r/CS_Questions • u/Throwawaybalahbalah • Aug 16 '19
Super awkward, wondering what I can do
Hi everyone, throwaway for obvious reasons. I'm putting it in a less popular subreddit because I'm sure someone would see it and know who I am if it was in CSCareerQuestions. God knows what nightmare that would create.
The title basically says it: I'm super awkward. I'm on my fourth day of training and somehow I've managed to alienate myself from almost everyone I've met. It's gotten so bad that I can literally see people turn around and walk the other way when I walk by, actively ignore me when I say hi, today someone even muttered under their breath "Oh this fucking guy" when he saw me sitting down in a training session. I don't know how I can win at this point. I'd honestly be ecstatic if I could get to anonymous corporate drone #31293.
I really don't think I'm mean to people, nor do I treat them badly. At least I hope that's the case. Maybe I'm a huge asshole and don't realize it. I also have really bad anxiety and can't think of what I want to say... unsurprisingly this gets worse when I see someone visibly recoil at my presence. I have been so anxious about this training... and somehow I've managed to make it even worse than I could have possibly imagined. I'm actually a pretty good programmer, so I'm hoping that I can make up for my awkwardness by being helpful once we start actually coding. At this point I guess I'm just really looking for advice on damage control. I'd really like to be able to just have someone that I can ask "Hey, I know I'm coming off really poorly, any advice?", but I feel that would really only exacerbate things, to say nothing of the fact that it would be unreasonable to burden someone I just met with something like that.
Thanks!
Also, on the off chance that you are reading this and have an idea of who I am... please don't mention this, I think I'm already doing bad enough, right?
r/CS_Questions • u/BlackFreud • Aug 14 '19
Google Software Dev Internship Interview. How to prepare?!
So, I am trying to start preparing for the google internship interviews. The recruiter said to brush up on my algorithms, but the thing is I am going to be taking algorithms this fall, so by the time the interview process comes around, I may not be adequately prepared. I wanted to know what sort of algorithms I should be looking at or going over in preparation for the interview? Also do you have any resources you would recommend?
r/CS_Questions • u/danielmichaelni • Jan 22 '18
Find the median of two sorted arrays in logarithmic time
r/CS_Questions • u/Rob_Blob • Nov 04 '17
What C++ concepts should I absolutely memorize for my upcoming Big 4 interview?
Hi everyone! I have an upcoming interview to work with a team that primarily uses C++. This being said, it is for an entry level position where I can use any OOL for the interview. I want to impress with my C++ experience. I use C++ as a hobbyist, so I want to make sure I have all my bases covered, as I have not really interfaced with C++ veterans.
What I have been studying so far: Data Structures; Algorithms; The Standard Template Library (STL); IO; Abstraction and Inheritance; Pointers, References, Memory, ect.; C++ Hacker Rank Problems
What else is fundamental for an entry level C++ programmer? What language specific questions might come up while I whiteboard a solution (e.g. using pointers vs. shared pointers)? Should I memorize as much of the STL as possible, and as many of the functions within?
Thanks!
r/CS_Questions • u/SlumsToMills • Sep 19 '16
Software Engineer interview. After correctly writing the code on the whiteboard, I was asked "How do you absolutely know the answer is 100% correct and will work for all valid inputs"?
I was told to code a solution to "return how many digits in an int input are above 0?" I correctly coded this using modulus (%).
After that I asked him, do you agree my solution is correct? He says, "Sure".
Then he says what if this program was in an eye surgery device, how do you determine that this program will work for all acceptable inputs? How do I know for 100% that this program works as it is intended and would I trust this to be used myself if it was in an eye surgery device? The list of things I tried answering were:
Write a test for it
Write a test that will test edge cases of an int number that will include tests 0, 10, 13, 100, 1000000, 352315231, and then 232.
He then says, what if the program is unlimited in input, or what if the computer was defected and the circuit board will feed an incorrect input, then what?
I think he was hinting at a mathematical solution using a proof. I told him that I have not taken any proof classes so I would not be able to provide him with a mathematical proof.
He then tells me to "go ask some friends and discuss! :)". Well, problem is he doesn't realize not all people have computer science friends who can solve mathematical proofs... So here i am...
Does anyone have any idea what this guy was trying to get at?
r/CS_Questions • u/Sbhavnani • Jul 06 '16
What are some interesting programming questions that you have come across that become easy with mathematical thinking?
r/CS_Questions • u/throwcscq • Mar 18 '16
A compilation of programming interview questions
r/CS_Questions • u/kpthunder • Dec 27 '11
Sum of Digits
Consider the following example:
210 = 1024 -> 1 + 0 + 2 + 4 = 7
Write a program which calculates the sum of the individual digits of 250 .
r/CS_Questions • u/CallMeRex • Dec 01 '11
Write a function that returns the mth to last element in a singly linked-list.
Bonus: Do it in O(n) time.
Extra Bonus: Use only O(1) space.
r/CS_Questions • u/CallMeRex • Nov 22 '11
Write a function that determines whether two integers are equal without using any comparative operators.
Taken from: "Programming Interviews Exposed: Secrets to Landing Your Next Job"
r/CS_Questions • u/kpthunder • Nov 13 '11
Classic Interview Question: Anagrams
Given two strings, return true if they are anagrams and false otherwise. You can assume that capitalization and punctuation do not matter and your algorithm must run in O(n) time. Subroutines are okay if you need them.
Example 1:
Given two strings:
Boston
osbont
Return true.
Example 2:
Given two strings:
Robble
Bobble
Return false.
r/CS_Questions • u/sunny6549 • Oct 23 '22
Does Meta allows another chance later if you fail live coding interview?
Basically what the title says. I was contacted by Meta recruiter and decided to take a test. However, I didn't have enough time to prepare and I'm feeling extreme anxiety. I'm wondering what are my options in case of failing? Am I on blacklist, when I would be able to apply again? Anyone having some similar experiences or some pieces of advice? Thank you.