Skip to content
the poor coder

Home / Topics / #leetcode

#leetcode

131 posts · page 6 of 7
2021

Leetcode - Triangle Solution

Given a triangle array, return the minimum path sum from top to bottom. For each step, you may move to an adjacent number of the row below. More formally, if you are on index i on the current row, you may move to either…

2021

Leetcode - Pascal's Triangle II Solution

Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Example 2: Example 3…

leetcodearray1 min read
2021

Leetcode - Pascal's Triangle Solution

Given an integer numRows, return the first numRows of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown: Example 1: Example 2: Constraints: 1 <= numRows <= 30…

leetcodearray1 min read
2021

Leetcode - Word Search Solution

Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or…

2021

Leetcode - Subsets Solution

Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Example 1: Example 2: Constraints: 1 <=…

2021

Leetcode - Sort Colors Solution

Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue. We will use the integers 0, 1, and 2…

2021

Leetcode - Sqrt(x) Solution

Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Example 1: Example 2…

2021

Leetcode - Plus One Solution

Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the…

leetcodearray1 min read
2021

Leetcode - Group Anagrams Solution

Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all…

2021

Leetcode - Multiply Strings Solution

Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: You must not use any built-in BigInteger library or convert the inputs to…

2021

Leetcode - Valid Sudoku Solution

Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must contain the digits 1-9…

2021

Leetcode - Remove Element Solution

Given an array nums and a value val, remove all instances of that value in-place and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1)…

2021

Leetcode - Valid Parentheses Solution

Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open…

2021

Leetcode - Longest Common Prefix Solution

Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an empty string "". Example 1: Example 2: Constraints: 0 <= strs.length <= 200 0 <=…

leetcodestring1 min read
2021

Leetcode - ZigZag Conversion Solution

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) And then read line by line: "PAHNAPLSIIGYIR"…

leetcodestring1 min read
2021

Leetcode - Reformat The String Solution

Given alphanumeric string s. (Alphanumeric string is a string consisting of lowercase English letters and digits). You have to find a permutation of the string where no letter is followed by another letter and no digit…

leetcode2 min read
ESC