Decrypt String from Alphabet to Integer Mapping Leetcode Solution

Problem Statement In this problem, we are given a string containing digits (0-9) and ‘#’. We have to convert this string to a string of lowercase english letters by using the following mapping. Example s = “10#11#12” “jkab” Explanation: “10#” -> “j” , “11#” -> “k” , “1” -> “a” …

Read more

Word Search Leetcode Solution

Problem Statement Given an m x n board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where “adjacent” cells are horizontally or vertically neighbouring. The same letter cell may not be used more than once. Example …

Read more

Min Stack Leetcode Solution

Problem Statement Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) — Push element x onto stack. pop() — Removes the element on top of the stack. top() — Get the top element. getMin() — Retrieve the minimum element in the stack. …

Read more

Maximum Subarray Leetcode Solution

Problem Statement Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example nums = [-2,1,-3,4,-1,2,1,-5,4] 6 Explanation: [4,-1,2,1] has the largest sum = 6. nums = [-1] -1 Approach 1 (Divide and Conquer) In this approach …

Read more

Sort Array by Increasing Frequency Leetcode Solution

Problem Statement Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order. Example nums = [1,1,2,2,2,3] [3,1,1,2,2,2] Explanation: ‘3’ has a frequency of 1, ‘1’ has a frequency of …

Read more

Translate »