Richest Customer Wealth Problem

Problem You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank. Return the wealth that the richest customer has. A customer’s wealth is the amount of money they have in all their bank accounts. The richest customer is the customer that has the maximum wealth. Examples Example 1: Input: accounts = [ [1,2,3],[3,2,1] ] Output: 6 Explanation: `1st customer has wealth = 1 + 2 + 3 = 6` `2nd customer has wealth = 3 + 2 + 1 = 6` Both customers are considered the richest with a wealth of 6 each, so return 6. ...

Check if Intervals Overlap

Problem Given a set of intervals, find out if any two intervals overlap. Example: Intervals: [ [1,4], [2,5], [7,9] ] Output: true Explanation: Intervals [1,4] and [2,5] overlap Solution Method 1 - Sorting Let’s take the example of two intervals (‘a’ and ‘b’) such that a.start <= b.start. There are three possible scenarios: ...

Run-length Encoding

Problem Run-length Encoded is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. Examples Example 1: Input: str = AAAABBBCCDAA Output: 4A3B2C1D2A Input Format public class RLECodec { public String encode(String str) { } public String decode(String data) { } } ...

Find if Path Exists in Directed Graph Problem

Problem There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. You want to determine if there is a valid path that exists from vertex source to vertex destination. ...

Find if Path Exists in Graph Problem

Problem There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive). The edges in the graph are represented as a 2D integer array edges, where each edges[i] = [ui, vi] denotes a bi-directional edge between vertex ui and vertex vi. Every vertex pair is connected by at most one edge, and no vertex has an edge to itself. You want to determine if there is a valid path that exists from vertex source to vertex destination. ...

Count number of bits to be flipped to convert A to B

Problem You are given two numbers A and B. Write a function to determine the number of bits need to be flipped to convert integer A to integer B. OR A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0. For example, for x = 7, the binary representation is 111 and we may choose any bit (including any leading zeros not shown) and flip it. We can flip the first bit from the right to get 110, flip the second bit from the right to get 101, flip the fifth bit from the right (a leading zero) to get 10111, etc. Given two integers start and goal, return the minimum number of bit flips to convert start to goal. ...

This site uses cookies to improve your experience on our website. By using and continuing to navigate this website, you accept this. Privacy Policy