Problem The cost of a stock on each day is given in an array. Each day, you can either buy one share, sell any number of shares that you own, or not make any transaction at all. Find is the maximum profit that you can make? Input The first line contains […]
Problem Statement Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. Definition of LCA (according to Wikipedia) The lowest common ancestor is defined between two nodes p and q as the lowest node in T that has both p and q as descendants. For the given Binary tree, if info[key1] = 15 and […]
Problem Statement [LeetCode]You are given an array prices where prices[i] is the price of a given stock on the ith day. You need to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve […]
Problem Statement: Alansh has to travel through a road having hills of different heights. Also each hill has a cave to pass through it, to avoid travelling extra distance of a hill. Alansh wants to travel through this road by taking at most K caves, so that he has to travel […]
Problem statement: Given two strings word1 and word2 (in lowercase alphabets), return the minimum number of operations required to convert word1 to word2. You could only perform three following operations on a word: Insert a character Delete a character Replace a character Example 1: Input: word1 = “horse”, word2 = “ros” Output: 3 Explanation: horse -> rorse (replace […]
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order. The order of the alphabet is some permutation of lowercase letters. Given a sequence of words written in the alien language, find the order of the alphabet. Problem statement: GeeksforGeeks Problem Link Example 1: Input: words = [“hello”,”leetcode”], order = “hlabcdefgijkmnopqrstuvwxyz”Explanation: […]