Lipsky

Lipsky

Let me try

LeetCode4. Median of Two Sorted Arrays
4. Median of Two Sorted Arrays#4. Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1:...
LeetCode628. Maximum Product of Three Numbers
628. Maximum Product of Three Numbers#628. Maximum Product of Three Numbers Given an integer array, find three numbers whose product is maximum and output the maximum product. Example 1: Input: [1,2,3]Output: 6 Example 2:#Input: [1,2,3,4]Output: 24 Note:#The length of the given array will be in r...
LeetCode637. Average of Levels in Binary Tree
637. Average of Levels in Binary Tree#637. Average of Levels in Binary Tree Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1:#Input: 3 / \ 9 20 / \ 15 7Output: [3, 14.5, 11] Explanation:#The average value of nodes...
LeetCode463. Island Perimeter
463. Island Perimeter#463. Island Perimeter Description#You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water. Grid cells are connected horizontally/vertically (not diagonally). The grid is completely surrounded by water, and there is exactly...
最小数组
题目描述#第一行输入一个数n,1 <= n <= 1000,下面输入n行数据,每一行有两个数,分别是x y。输出一组x y,该组数据是所有数据中x最小,且在x相等的情况下y最小的。 输入描述:#12输入有多组数据。每组输入n,然后输入n个整数对。 输出描述:#1输出最小的整数对。 示例1 输入#复制 12345653 32 25 52 13 6 输出#复制 12 1 1234567891011121314151617181920#include<bits/stdc++.h>using namespace std;int main(){ int num;...
比较奇偶个数
题目描述#第一行输入一个数,为n,第二行输入n个数,这n个数中,如果偶数比奇数多,输出NO,否则输出YES。 输入描述:#12输入有多组数据。每组输入n,然后输入n个整数(1<=n<=1000)。 输出描述:#1如果偶数比奇数多,输出NO,否则输出YES。 示例1 输入#复制 1251 5 2 4 3 输出#复制 1YES 12345678910111213141516171819202122#include <iostream>using namespace std;int main(){ int count;//奇数的个数(净个数) in...
LeetCode504. Base 7
504. Base 7#504. Base 7 Given an integer, return its base 7 string representation. Example 1:#Input: 100Output: “202”Example 2: Input: -7Output: “-10”Note: The input will be in range of [-1e7, 1e7]. Resolution#123456789101112131415class Solution { public String convertToBase7(int num) ...
LeetCode551. Student Attendance Record I
551. Student Attendance Record I#551. Student Attendance Record I You are given a string representing an attendance record for a student. The record only contains the following three characters:‘A’ : Absent.‘L’ : Late.‘P’ : Present.A student could be rewarded if his attendance record doesn’t cont...
LeetCode 303. Range Sum Query - Immutable
303. Range Sum Query - Immutable#303. Range Sum Query - Immutable Description#Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example:#Given nums = [-2, 0, 3, -5, 2, -1] sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange(0, 5) -> -3Note:...
LeetCode655. Print Binary Tree
655. Print Binary Tree#LeetCode. 655.Print Binary Tree Description#Print a binary tree in an m*n 2D string array following these rules: The row number m should be equal to the height of the given binary tree.The column number n should always be an odd number.The root node’s value (in string forma...
LeetCode561. Array Partition I
561. Array Partition I#LeetCode 561 Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), …, (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible. Example 1: Input: [1,4,3,2] Output: 4Explanation: n is 2,...
LeetCode566.Reshape the Matrix 重置矩阵
566. Reshape the Matrix#In MATLAB, there is a very useful function called ‘reshape’, which can reshape a matrix into a new one with different size but keep its original data. You’re given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row numbe...
LeetCode174. Dungeon Game🤴地狱救👸
174. Dungeon Game#The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially positioned in the top-left room and must fight his way through the dungeon to resc...
LeetCode 404. Sum of Left Leaves 左叶子结点值之和
404. Sum of Left Leaves 左叶子结点值之和#Find the sum of all left leaves in a given binary tree. Example:#3 / \ 9 20 / \ 15 7 There are two left leaves in the binary tree, with values 9 and 15 respectively. Return 24. Resolution#12345678910111213141516171819202122/** * C++ * Definition for a...
LeetCode 455. Assign Cookies 饼干分配
455. Assign Cookies 饼干🍪分配#Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size ...
LeetCode 461 Hamming Distance 汉明距离
461. Hamming Distance 汉明距离#The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance. Note:0 ≤ x, y < 231. Example:#Input: x = 1, y = 4 Output: 2 Explanation:1 (0 0 0 1)4 (0...
avatar
Lipsky
Let me try
FRIENDS
Mr-houzi