Adarsh singh
@ad_ars_h
Adarsh Singh | Frontend Developer Problem solving | React.js Developer UI/UX Backend systems
Q 15 of 100: Longest Consecutive Sequence Aim: To find out the longest consecutive Sequence in a given array. Used a set to store the elements, which kept them in a sorted order, later transferred them to a vector and found out the longest sequence Can be optimised without array
Q 14 of 100: Best time to Buy and Sell Stock Aim: To find out the best time to buy a stock and then sell in the future. Initially, used 2 arrays for prefix and suffix sum, but later on seeing solutions, realised we just need 2 variables to store the values. #leetcode #problems
Q 13 of 100: Next Permutation Aim: To find out the next permutation, provided an already existing permutation. Prior to problem, we must know the algorithm of finding the next permutation. Time complexity : O(nlogn) Space complexity : O(1) #leetcode #coding #problems
Q 12 of 100: Find most frequent vowel and consonant Aim: to find the sum of the most frequent vowel's frequency and same for the consonants and return that sum. #leetcode #potd #coding #practice
Q 11 of 100: Rearrange Array Elements By Sign Aim: To arrange the elements of an array in alternate positions - Positive and negative. TC: O(n) SC: O(n) Approach: Create another array of the same size, then maintain the indices of the positive and negative numbers. Update them.
Follow up of the Maximum subarray sum : Just store the indices everytime you update the maximum subarray sum. Maintain those indices and then just print the whole array, you're good to go 🚀🚀
Q 10 of 200: Maximum Subarray Sum Aim: To find out the subarray with the maximum sum and then return the maximum subarray sum. Iterate the array and whenever an element greater than the sum of the subarray and element itself is found, shift subarray. #leetcode #gfg #CodingLife
Q 9 of 100: Majority Element Aim: To find out the element which occurs more than 50% of the times in the array. Approach: Maintain the count of the most freq element, increase every time it occurs and decrease every time it doesn't occur. #leetcode #arrays #gfg #problemsolving
Q 8 of 100 : Sort Colours We had to sort the colors 0,1,2 in the array, used their count to solve the problem. #leetcode #problemsolving #coding #gfg #cp
Q 7 of 100: Two Sum Aim: Find out the 2 indices which sum up to the provided sum. Maintained a map for finding out the complementary element existence and its index. #leetcode #problemsolving
Q 6 of 200: Rotate Array This is a question which requires good observation, we had to rotate an array by provided k places. Used the reverse functions smartly for doing the problem, had to take help of tutorials #leetcode #dsa #grinding
Q5 of 200: Move Zeroes In this question we were supposed to move all the zeroes of an array to the end of the array while maintaining the relative order of the non zero elements. Keep an index of nonzero and at the end put the zeroes.
Q4 of 200: Check if the array is Sorted and Rotated The aim was to find and return whether the array was sorted and rotated. 2 cases: if sorted not rotated -> no peak will be there, simple if sorted and rotated -> one peak, if multiple return false else true.
Q3 of 200: Max Consecutive Ones Aim: to find the maximum consecutive number of times 1 appears in the array. Used a variable to store the frequency and updated it everytime 1 was encountered, and updated the maxConsecutiveOnes accordingly. #LeetCode #WIN
Q2 of 200: Missing number An array was given, in which there were numbers from 0 to n, but a certain number was missing. Aim was to find the missing number. Used the expected sum and actual sum difference for solving.
Q1 of 200: Single number The aim was to find the number that was occurring only once in the array and all the rest of the numbers were occurring twice. I used the XOR product of all the numbers, since the XOR of a number onto itself will be zero. This finds the single number. 😁
Day -1 of 90 day challenge Gym in the morning , treadmill 10 min mixed pace 1 km , Inclined crunches 30, Lat pull down 25 , 20+ 15 kg Side dumbell pull - 20 , 5 kg each Inclined dumbell press - 36, 5 kg + 7.5 kg reps Biceps curls - 5 kg, 20
United States Trends
- 1. Steelers 53.4K posts
- 2. #ITZY_TUNNELVISION 30.9K posts
- 3. Mr. 4 4,705 posts
- 4. Rudy Giuliani 13.1K posts
- 5. Chargers 38.6K posts
- 6. Resign 114K posts
- 7. #MondayMotivation 28.7K posts
- 8. Schumer 234K posts
- 9. Tomlin 8,382 posts
- 10. #Talus_Labs N/A
- 11. Rodgers 21.5K posts
- 12. 8 Democrats 10.5K posts
- 13. Tim Kaine 22.9K posts
- 14. Sonix 1,424 posts
- 15. Happy Birthday Marines 3,188 posts
- 16. Voltaire 9,087 posts
- 17. Angus King 19K posts
- 18. #BoltUp 3,132 posts
- 19. Dick Durbin 14.9K posts
- 20. The BBC 400K posts
Something went wrong.
Something went wrong.