LeetCode Biweekly Contest 180 Recap: Easy and Medium Problems Solved

Hello Everyone! After a long time, Sat at LeetCode Biweekly contest 180. Today's contest felt quite easy and I solved first three problems within 20 minutes and attempted the fourth problem 1) Traffic Signal Color(easy): can be solved by writing if else condition, the problem is so much straight forward. 2) Count Digit Appearance(Medium): Used digit extraction for each number in array and stored the digits in map data structure and return the frequency of the given digit Input: nums = [12,54,32,22], digit = 2 map: [1 : 1, 2 : 4, 3 : 1, 4 : 1, 5 : 1] --> Output: 4 3) Minimum Operations to Transform Array into Alternating Prime(Medium): iterated the given nums array twice ,one for even indexes and other for odd indexes. (Odd index must have non prime numbers) In odd index iteration, checked whether a number is prime , if it is prime and the number is 2 , then count will be incremented by 2 or if the number is prime and not 2 , then count will be incremented by 1. (Even index must have prime numbers) In even index iteration, for each number the count will be incremented by 1 until the prime number is reached (used looping and each iteration checks for prime number) Hoping to stay consistent and solve more different and creative problems ☺️ #cpp #competitiveprogramming #leetcode #problemsolving

Why do you need two loops for 3rd ques? Can be done in single iteration only

To view or add a comment, sign in

Explore content categories