Data Structures & Algorithms

Leetcode ZigZag Conversion Java Solution

The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display…

2 years ago

Leetcode Sum Root to Leaf Numbers Java Solution

Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which…

2 years ago

Leetcode Find the Duplicate Number Solution Java Solution

Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must…

2 years ago

Leetcode Unique Binary Search Trees Java Solution

Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n? Example: Input: 3 Output: 5 Explanation: Given n…

2 years ago

Leetcode Count Complete Tree Nodes Java Solution

Given a complete binary tree, count the number of nodes. Note: Definition of a complete binary tree from Wikipedia:In a complete binary tree…

2 years ago

Leetcode Single Number II Java Solution

Given a non-empty array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your…

2 years ago

Leetcode Dungeon Game Java Solution

The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists…

2 years ago

Leetcode 59 Spiral Matrix II Java Solution

Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: Input: 3 Output:…

2 years ago

Leetcode 54 Spiral Matrix Java Solution

Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. Example 1: Input: [ [ 1,…

2 years ago

Leetcode 53 Maximum Subarray Java Solution

Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its…

2 years ago

This website uses cookies.