523. Continuous Subarray Sum Leetcode Solution

Leetcode Solutions

Continuous Subarray Sum Difficulty: Medium Topics: Array, Hash Table, Math, Prefix Sum Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise. A good subarray is a subarray where: its length is at least two, and the sum of the elements of the subarray is […]

514. Freedom Trail Leetcode Solution

Leetcode Solutions

Difficulty: Hard Topics: Array, Dynamic Programming, Depth-First Search, Breadth-First Search In the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial called the “Freedom Trail Ring” and use the dial to spell a specific keyword to open the door. Given a string ring that represents the code engraved […]

506. Relative Ranks Leetcode Solution

Leetcode Solutions

Relative Ranks Leetcode Solution Difficulty: Easy Topics: Array, Sorting, Heap (Priority Queue) You are given an integer array score of size n, where score[i] is the score of the <code>ith athlete in a competition. All the scores are guaranteed to be unique. The athletes are placed based on their scores, where the <code>1st place athlete […]

502. IPO Leetcode Solution

Leetcode Solutions

502. IPO Leetcode Solution Difficulty: Hard Topics: Array, Greedy, Sorting, Heap (Priority Queue) Suppose LeetCode will start its IPO soon. In order to sell a good price of its shares to Venture Capital, LeetCode would like to work on some projects to increase its capital before the IPO. Since it has limited resources, it can […]

476. Number Complement Leetcode Solution

Leetcode Solutions

Number Complement Leetcode Solution Difficulty: Easy Topics: Bit Manipulation The complement of an integer is the integer you get when you flip all the 0‘s to 1‘s and all the 1‘s to 0‘s in its binary representation. For example, The integer 5 is "101" in binary and its complement is "010" which is the integer […]

463. Island Perimeter Leetcode Solution

Leetcode Solutions

 Island Perimeter Leetcode Solution Difficulty: Easy Topics: Array, Depth-First Search, Breadth-First Search, Matrix You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly one island […]

445. Add Two Numbers II Leetcode Solution

Leetcode Solutions

Add Two Numbers II Difficulty: Medium Topics: Linked List, Math, Stack You are given two non-empty linked lists representing two non-negative integers. The most significant digit comes first and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked list. You may assume the two numbers […]

440. K-th Smallest in Lexicographical Order Leetcode Solution

Leetcode Solutions

402. Remove K Digits Leetcode SolutionK-th Smallest in Lexicographical Order Difficulty: Hard Topics: Trie Given two integers n and k, return the <code>kth lexicographically smallest integer in the range [1, n]. Example 1: Input: n = 13, k = 2 Output: 10 Explanation: The lexicographical order is [1, 10, 11, 12, 13, 2, 3, 4, […]

432. All O`one Data Structure Leetcode Solution

Leetcode Solutions

All O`one Data Structure Leetcode Solution Difficulty: Hard Topics: Hash Table, Linked List, Design, Doubly-Linked List Design a data structure to store the strings’ count with the ability to return the strings with minimum and maximum counts. Implement the AllOne class: AllOne() Initializes the object of the data structure. inc(String key) Increments the count of […]

409. Longest Palindrome Leetcode Solution

Leetcode Solutions

Longest Palindrome Leetcode Solution Difficulty: Easy Topics: Hash Table, String, Greedy Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome[^1] that can be built with those letters. Letters are case sensitive, for example, "Aa" is not considered a palindrome. Example 1: Input: s = “abccccdd” Output: […]