C++
LeetCode: 2352-Design a Food Rating System Solution
Problem
Design a food rating system that can do the following:
- Modify the rating of a food item listed in the system.
- Return the highest-rated food item for a type of cuisine in the system.
LeetCode: 242-Valid Anagram Solution
Problem
Given two strings s
and t
, return true
if t
is an anagram of s
, and false
otherwise.
LeetCode: 1436-Destination City Solution
Problem
You are given the array paths
, where paths[i] = [cityAi, cityBi]
means there exists a direct path going from cityAi
to cityBi
. Return the destination city, that is, the city without any path outgoing to another city.
LeetCode: 606-Construct String from Binary Tree Solution
Problem
Given the root
of a binary tree, construct a string consisting of parenthesis and integers from a binary tree with the preorder traversal way, and return it.
LeetCode: 1903-Largest Odd Number in String Solution
題目
You are given a string num
, representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of num
, or an empty string ""
if no odd integer exists.
LeetCode: 2-Add Two Numbers Solution
Problem
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, 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 do not contain any leading zero, except the number 0 itself.
Read More »LeetCode: 2-Add Two Numbers SolutionLeetCode: 1-Two Sum Solution
Problem
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order.Read More »LeetCode: 1-Two Sum Solution
[C++] Note of priority_queue of STL
priority_queue is a queue container provided in the C++ Standard Template Library (STL), which returns the element with the highest priority first.
Read More »[C++] Note of priority_queue of STL