Hello Everyone!
The first topic in Week 10 was Arrays and Strings, two of the most basic yet versatile datatypes that exist in programming. Performing today’s problems are problems that can be solved within a relative short amount of time but for which the correct approach needed some thinking and strategizing which makes them ideal to revisit basics. It seemed to be a rather counterintuitive idea that simple ideas bring a perfect solution to practical problems.
How the Day Went
-
**Including those children who can count the largest number of candies: **Kids with Greatest Number of Candies (Easy mode)
- Task: Find out whether adding more candies to each child would help them to have the most candies in that group?
- Approach: First, tried to find out the maximum number of candies that any of the children currently possessed. Then it looped through the array to see if each child after the addition of the extra amount of candies had equal to more than the maximum.
- What Made It Fun: To me, the problem came to life by regarding each of the comparisons as a short story in which kids vie for the first place.
-
Flower Placing (Ease Level)
- Task: Determine if `n’ flowers can be placed in a flower bed such that there are no two flowers one the other.
- Approach: Looped through flowerbed array to look for a spot (0) and all its neighboring places are also free. They planted a flower whenever a good position was there and reduced their name by one until no more flowers were required or planting became difficult.
- What Made It Fun: It was fun to plant flowers methodically, so it seemed like it was solving a mini gardening riddle.
What made today interesting
Relatable Scenarios:
To me, both problems had a practical sense to them – one resembled distributing rewards, the other was closer to designing a garden layout.Straightforward but Thoughtful:
Neither of these problems was complicated, but both necessitated developing an awareness of the constraints and how to traverse them for a proper approach.Visualization:
The aspect of depicting distribution of the candies and placing the flowers made those problems easier to solve in terms of visualization.
Key Learnings
Simplicity Can Be Powerful:
Such problems demonstrate the simple fact that even elementary array traversals and comparison could amount to effective solutions when used properly, or at all.Constraints Are Key:
Also both the tasks focused on the aspect of maintaining the constraints of the problem in mind; there were adjacency constraints in can_place_flowers; and comparing totals in case of kids_with_the_greatest_number_of_candies.Greedy Approaches Work Well:
A greedy algorithm such as planting flowers at any opportunity made a lot of sense and was easy to implement.
Reflections
The Kids With the Greatest Number of Candies problem was straight forward comparison problem followed by a relatively simple yet engaging Can Place Flowers with additional restriction of flower placement to adjacent positions. Each problem put me in mind again of the utility of arrays and also the need to make the solution as straightforward as possible. That was rather a good beginning of Week 10 and the tone was supposed to become progressively more interesting.
What’s Next?
The next one is String Manipulation of the next tasks, where I will solve Reverse Vowels of a String and Reverse Words in a String. These problems will put a strong pressure on the strings handling and at the same time struggling to make the logic transparent.
I really appreciate you being there for me and following my through this journey! Here is to new heights, new ways to solve problems and new advancement for the team.
Top comments (0)