Subrat Kumar Pattanaikblog-by-subrat.hashnode.dev·Mar 27, 2024What if, I was greedy?What if, you were given an access to a particular stock? What if, you could know the price of that stock prior to a day through that access? What if, the stock price only changed everyday and not every second? What if, you could hold a single stoc...Discussalgorithms
Aqiraqirlone.hashnode.dev·Mar 27, 2024Common Array Methods in Ruby: A Comprehensive OverviewAn extensive list of array methods in Ruby along with code examples for each: 1. Adding and Removing Elements: - << or push: Adds an element to the end of the array. array = [1, 2, 3] array << 4 array.push(5) unshift: Adds an element to the beginning...Discuss·30 readsRuby
Obidur Rahmanashfin.hashnode.dev·Mar 24, 2024Let's Count the Smiley Faces From an arrayWe will be solving a 6kyu problem from CodeWars. This one ->Count the smiley faces! | Codewars The Question Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces. Rules for a smili...Discusssmiley
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Crawler Log FolderThe Leetcode file system keeps a log each time some user performs a change folder operation. The operations are described below: "../" : Move to the parent folder of the current folder. (If you are already in the main folder, remain in the same fold...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Insert IntervalYou are given an array of non-overlapping intervals intervals where intervals[i] = [start<sub>i</sub>, end<sub>i</sub>] represent the start and the end of the i<sup>th</sup> interval and intervals is sorted in ascending order by start<sub>i</sub>. Yo...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Contiguous ArrayGiven a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1. LeetCode Problem - 252 import java.util.HashMap; import java.util.Map; class Solution { // Method to find the maximum length of a cont...DiscussJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Find the Middle Index in ArrayGiven a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones). A middleIndex is an index where nums[0] + nums[1] + ... + nums[middleIndex-1] == nums[middleIndex+1] + nums[middleIndex+2] + ... +...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Find Pivot IndexGiven an array of integers nums, calculate the pivot index of this array. The pivot index is the index where the sum of all the numbers strictly to the left of the index is equal to the sum of all the numbers strictly to the index's right. If the ind...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Product of Array Except SelfGiven an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algori...DiscussJava SolutionJava
Gulshan Kumarperfinsights.hashnode.dev·Mar 23, 2024Subarray Sum Equals KGiven an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k. A subarray is a contiguous non-empty sequence of elements within an array. LeetCode Problem - 560 import java.util.HashMap; import java.util...DiscussJava SolutionJava