AtCoder Beginner Contest 358 Question A : Check if string contains AtCoder and Land if present output Yes else No. Question B : Given the person comes ticket counter at ith time just iterate and if the previous customer time is greater than next customer arriving time we will add the time required in the max of completion time of previous customer and next customer arriving time. Question C : Dp problem to visit minimum stand to collect all the type of popcorn states are the popcorn picked and the index use mask to store the types of popcorn picked. Question D : Sort the both arrays.While iterating just check which candy box can be picked greedily and add it to the min heap.Lastly if possible pick the M boxes with minimum cost and output cost if not possible then -1. Question E : Used dp to maintain the states such that number of possible ways of constructing string of length l and character type j.We will start from string length of 1 to k and next we have option to create the string of length k using the character from a to z and the frequency of character is given we can use it upto the maximum frequency such that the length condition is maintained and the position of arranging the character can be calculated effectively using Fermat little theorem. #code #coding #atcoder #cp #cpp #Contest #maths #leetcode #python #codechef #codeforces
Giriraj Bidwai’s Post
More Relevant Posts
-
AtCoder Beginner Contest 356 Question A : Given n,l and r output the numbers from 1 to n and reverse the number in sequence of l and r. Question B : For each A[i] we need sum of X[i][0] to X[i][m] greater or equal to A[i] if this violates the condition output No else Yes. Question C : We will be taking each and every combination of real and dummy key and iterate over all the m test for each combination and check for the condition is the key is in tests combination or not and maintain the count of real keys and for each test of the door is opened but the count of real key is less than key it contradicts the result and if the real keys count is greater than or equal to k but the door does not open then also it contradict the decision and when the above condition are not violated the combination is possible we will increment the count of valid combination. Question D : We need the sum of popcount of k&m such that k is from 0 to N.If the 2^i th bit of m is set then we need to find out how many numbers from 0 to N are such that the bit is set.If the 2^i th bit is set then in 2*(2^i) numbers we will have 2^i numbers such that this bit is set we will divide n by 2*(2*i) to find how many such numbers are there and for the remaining numbers if(2^i - remainder) is greater than 0 we will take that many numbers +1.Count can be too large we take mod of 998244353. #atcoder #codeforces #codechef #leetcode #cpp #python #coding #contest #cp
To view or add a comment, sign in
-
AtCoder Beginner Contest 363 1. How much must be added to round it off to nearest hundred.For example : 137 -> 200. 2. Check greedily is number of person hair length is greater than T.If its greater than P then print 0 else check how many people hair length is greater than T and for remaining P check the person with smallest hair and return T - smallest person hair length. 3. Generate all the permutation of string and check if its substring contain a palindrome of length K then it is not a valid permutation.I used (next_permutation) function to generate possible strings. 4. Tried generating some kind of series but was not able to formulate it much briefly.Need to upsolve. 5.Maintain a priority queue such that it store the boundary cells elevation and coordinates. When the queue's top elevation is less than equal to ith elevation then we will remove and it move in 4 direction to check if adjacent cells can be sink and maintain a counter for submerged cells and marked the cell visited.Got wrong answer as was calculating the submerged cell in wrong order. #atcoder #coding #code #cpp #cp #codeforces #python #maths
To view or add a comment, sign in
-
Let's dive into the world of Ruby and unravel its magic ✨ From its beginner-friendly syntax to its powerful features, Ruby is a gem in the world of coding 💻 Get ready to fall in love with this versatile language! 💬 . To get more information read our blog: https://bit.ly/3TLNdlV . . . #TheIoTAcademy #edtech #education #blog #RubyProgramming #CodingMagic #ruby #coding #learntocode #LearningRuby #ProgrammingWithRuby #RubyTutorial #UnderstandingRuby
To view or add a comment, sign in
-
Leetcode Challenge Problem 347:Top K Frequent Elements (https://lnkd.in/g_3piXcG) ✨Today while reviewing other submissions at the end, I learned instead of write your own method from scratch like the second loop in this code is unnesscary instead i could use slice method to limit the number of values i could get. 🔧 From line number 14 to 21 could be replaced by the builtin functions and optimized solution, i have attached in second screenshot, do give it a look. Give your reviews. #100daysofcodechallenge #coding #programmer #problems #leetcode #neetcode #dsa #algorithm #typescript #maps #leetcode347 #leetcodeproblems
To view or add a comment, sign in
-
Day 25 of leetcode 75 interview questions 2352. Equal Row and Column Pairs Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal. A row and column pair is considered equal if they contain the same elements in the same order (i.e., an equal array). #leetcode #LeetCode2024 #2352EqualRowandColumnPairs #equalrowandcolumnpairs #EqualRowandColumnPairs #Contest #Challenge #problemsolving #datastructure #algorithms #competitivecoding #codingforbeginners #leetcoder #leetcodemedium #computersciencestudent #codewars #codinginterviewcoach #codingbootcamps #codingdojo #codingmemes #codeforces #algorithm #programminglanguage #codingforkids #datastructuresandalgorithm #datastructures #programmers #computersciencemajor #topcoder
To view or add a comment, sign in
-
Back To Practice !! Excited to continue my daily streak on LeetCode! Achieved the best runtime for today's challenge: Magnetic Force Between Two Balls. https://lnkd.in/dm6fm_Uu #leetcode #dailystreak #coding #programming #problemsolving #algorithm #datastructures #developer #codechallenge #codingchallenge #programming #problemsolving #codeeveryday #developerlife #pythoncommunity #softwaredeveloper #datastructuresandalgorithms #codingchallenges #codekaro #dsa #python3 #competitiveprogramming #leetcodesolution #codinginterview #codingpractices #solvingproblems #dsacoding #interviewpractice #dsacommunity #hardchallange #codingadventures #advancedpractice #connections
To view or add a comment, sign in
-
🌟 100 Days of Code: A Journey with Replit! 🌟 Can you "Guess the Number" I have in mind 🤔? Day 18 of #Replit100DaysOfCode #100DaysOfCode. 🚀 Excited to share my latest project on Replit: Guess the Number! 🎉 This interactive game challenges players to guess a number between 1 and 1,000,000 complete with hints and a scoring system. It was a fun way to sharpen my coding skills while working on logic and user interaction.Check it out, give it a try, and let me know what you think! Happy coding! 💻✨ Join me on @Replit https://lnkd.in/enDN8Zt6 #Replit100DaysOfCode #100DaysOfCode #Python #coding #challenge
To view or add a comment, sign in
-
🎉 Excited to share that I just solved the "Reverse a Prefix" problem on LeetCode! 🚀 💡 This problem challenged me to reverse the first k characters of a string. It was a great exercise in string manipulation and problem-solving. 🔍 If you're also on the LeetCode journey or interested in algorithmic problem-solving, feel free to check it out and let me know your thoughts! #LeetCode #ProblemSolving #Algorithms #Programming #Coding 💻✨#day36
To view or add a comment, sign in
-
Another day, another problem solved! 🚀 Tackled the 'Maximum Number of Points with Cost' challenge on LeetCode today. https://lnkd.in/dvKx6zqH #leetcode #dailystreak #codingchallenge #programming #problemsolving #codeeveryday #developerlife #pythoncommunity #softwaredeveloper #datastructuresandalgorithms #codingchallenges #codekaro #dsa #python3 #competitiveprogramming #leetcodesolution #codinginterview #codingpractices #solvingproblems #dsacoding #interviewpractice #dsacommunity #hardchallange #codingadventures #advancedpractice #softwareengineering #coding #connections
To view or add a comment, sign in
-
#66 days of my#100 days of leetcode challenge🚀, 🚀Approach Overview: Use a Max-Heap (Priority Queue): A max-heap (or priority queue) is used to always pick the character with the highest remaining count. The heap stores pairs of the form (count, character), where count is the remaining number of times that character can still be used. Initial Population of the Heap: 🚀The priority queue is initialized with up to three elements: one for each character ('a', 'b', and 'c') that has a count greater than zero. For example, if a = 5, b = 3, and c = 1, we will push these values into the heap as {5, 'a'}, {3, 'b'}, and {1, 'c'}. 🚀Building the Result String: The string is built one character at a time by repeatedly taking the character with the highest count from the priority queue. 🚀Condition to Avoid Three Consecutive Characters: Before appending a character, the code checks the last two characters in the result string. If both of them are the same as the current character (i.e., two consecutive occurrences), the code avoids appending the current character. Using the Next Character: If adding the current character would result in three consecutive characters, the code checks the second most frequent character in the heap and appends it instead. This ensures that the "diverse" condition is maintained. 🚀After appending a character, its count is decremented. If it still has remaining occurrences, it is pushed back into the heap. Termination Condition: 🚀The process continues until the priority queue becomes empty, meaning there are no more characters left to add to the result string, or it becomes impossible to add characters without violating the consecutive character rule. #CodeChallenge #Day66 #LeetCode #ProblemSolving #PythonProgramming #MaxHeap #StringManipulation #LongestHappyString #CodingJourney #DailyChallenge #TechLearning #DataStructuresAndAlgorithms #HeapqInPython #DeveloperLife #DailyCoding #AlgorithmMastery #CodingCommunity #HappyCoding #ProblemSolvers #PythonDevs #TechSkills
To view or add a comment, sign in
Intern @Streebo | CSE'24🧑💻 | C, C++, Java & DSA | Leetcode (1833+), GFG (3150+ Points & 600+ current POTD streak) & Codechef (1628+, 3⭐) | Android App Developer (Java) | Chatbot Developer
6moLove this, Thanks for sharing ❤️