100 Days to Amazon — Day 85 — Partition List
Out of Free Stories? Here is my Friend Link.
Introduction🛹
Hey Guys, Today is day 85 of the challenge that I took. Wherein I will be solving every day for 100 days the programming questions that have been asked in previous interviews.
You have a bonus at the end if you keep reading. You can find out the companies that have asked these questions in real interviews.
All these problems are taken from the following e-book. 🎓
This is completely free 🆓 if you have an amazon kindle subscription.
This e-book contains 100 coding problems that have been asked in top tech interview questions. It also has a guide to solving all the problems in 200+ ways. These problems I assure you has been asked in previous interviews.
You have to decide whether you want to go unprepared for a tech interview or go ahead and quickly search for this guide to solve the 100 problems.
Begin Your ascent to greatness🚀
Note: this e-book only contains the links to the solutions. Code for 40 have been added.
Day 85 — Partition List🏁
AIM🏹
Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.
You should preserve the original relative order of the nodes in each of the two partitions.
Example🕶
Input: head = 1->4->3->2->5->2, x = 3
Output: 1->2->2->4->3->5Code👇
Algorithm👨🎓
- Create 2 New Lists less than and greater than.
- Store the Start pointers for both the lists.
- Pass through the List.
- Elements that are less than store it in the lesser than the list.
- Elements that are greater than store it in the greater than the list.
- Connect the lesser end and greater start.
- Return the Connected list🔚
Conclusion🐱🏍
Have you come across this question in your interview before? Share it in the comment section below. 🤝
Don't forget to hit the follow button✅to receive updates when we post new coding challenges. Tell us how you solved this problem. 🔥 We would be thrilled to read them. ❤ We can feature your method in one of the blog posts.
Want to become outstanding in java programming?
Click HERE 🧨🎊🎃
I have published an ebook. A compilation of 100 Java(Interview) Programming problems which have been solved. (HackerRank) 🐱💻
This is completely free 🆓 if you have an amazon kindle subscription.
Companies
- Google 2) Pocket Gems 3) Capital One 4) Amazon
Previous Blog Posts
