Competitive Programming 40??

Competitive Programming 40??

Day 40: Implement Queue using Stacks, Design Circular Queue, Counting Bits, Partition Labels and Candy

Dear Developers!

Welcome to day 40 of my coding journey.

Hello, Developers! Moving ahead into the fortieth day of this challenge and last day. It was yet another promising day full of adrenaline from advanced problems that stretched my coding skills to a proverbial new level. Here is what the sack contained and some comments on each problem:

Highlight of day:

1. Queue Implemented using Stacks:

I wrote a queue using two stacks! I learned how to shift the elements of one stack into another in order to replicate the behavior of an ordinary queue, where in the one that enters comes out first; it was also a cool challenge.

2. Circular Queue Design

This was a very interesting exercise in building a circular queue where the end wraps around to the beginning. It's similar to a merry-go-round where if one finally makes it to the last, then he or she has still not missed the merry ride through returning to the front from the end.

3. Counting Bits

Finally, there was the counting, to count the number of 1's that appear in the binary representations of numbers from 0 through a given number. At this point, I found a pattern and was able to come up with a simple formula to count it for each number correctly.

4. Partition Labels

This problem was cutting up a string. Letters that appear in each should never reappear in each piece. So basically, I looked at when each letter last appeared and cut up the string with respect to that.

5. Candy

I had to distribute candies based on the goodness of kids. The ones with better marks should have more candies than any kid next to them. First, I gave one candy to each kid. Then, I checked twice—once from left to right and again from right to left—to ensure that each of them received equal candies.

"The only way to go fast is to go well." — Robert C. Martin

Today, I learned that greedy algorithms help solve problems. These problems showed me how to use this method, and I’m excited to keep going tomorrow

Hope you had the same delight from reading about it. Go out there and keep exploring and finding solutions, curious and determined. The coding adventures and discoveries are yet to come.

#CodeYourDreams #FromLinesToLife #DebuggingMyWay #CraftingWithCode #SyntaxAndSuccess #BuildingWithBits #CodeAndConquer #LinesOfLegacy #InnovateWithCode #CodeIsArt

要查看或添加评论,请登录

Meghana Manchala的更多文章

  • Competitive Programming 61??

    Competitive Programming 61??

    Day 61: Counting the Number of Islands in an Image, Top K Frequent Words, Permutations II, LRU Cache Dear Developers!…

  • Competitive Programming 60??

    Competitive Programming 60??

    Day 60: Permutations,subsets,letter combi Hi everyone! ?? Today, I dedicated time to work on some exciting coding…

  • Competitive Programming 54??

    Competitive Programming 54??

    Day 54: Binary Search,Search in Rotated Sorted Array, Kth Largest Element in an Array, First Bad Version Dear…

  • Competitive Programming 53??

    Competitive Programming 53??

    Day 53: Counting the Number of Islands in an Image, Top K Frequent Words, Permutations II, LRU Cache Dear Developers!…

  • Competitive Programming 52??

    Competitive Programming 52??

    Day 52: Cookie Handout, Lemonade Change, Maximum Units on a Truck, Two-City Scheduling and Jump Game Hello Developers!…

  • Competitive Programming 56??

    Competitive Programming 56??

    Day 56: Square of Sorted Array, Remove Element, Reverse Only Letters, Pivot Index and Check If Array Is Sorted and…

  • Competitive Programming 50??

    Competitive Programming 50??

    Day 50: Implement Queue using Stacks, Design Circular Queue, Counting Bits, Partition Labels and Candy Dear Developers!…

  • Competitive Programming 49??

    Competitive Programming 49??

    Day 49: Binary Search,Search in Rotated Sorted Array, Kth Largest Element in an Array, First Bad Version Dear…

  • Competitive Programming 48??

    Competitive Programming 48??

    Day 48: Binary Search,Search in Rotated Sorted Array, Kth Largest Element in an Array, First Bad Version Dear…

  • Competitive Programming 47??

    Competitive Programming 47??

    Day 47: Binary Search,Search in Rotated Sorted Array, Kth Largest Element in an Array, First Bad Version Dear…

社区洞察

其他会员也浏览了