Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For
Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. You need to distribute these
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.Now given an M x N matrix, return True if and only if the matrix is Toeplitz.
Example 1:Input:
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-dimensi
You're now a baseball game point recorder.Given a list of strings, each string can be one of the 4 following types:
Integer (one round's score): Directly represents the number of points you get in thi
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
You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1's elements in the corresponding places of nums2.Th
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 7
Output: [3, 14.5, 11]
Explanation:
T
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.Example 1:Input: 5
Output: True
Explanation:
The binary representation o
Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these str
Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation.(Recall that the number of set bits an integer ha
You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the
Given an array of integers, every element appears twice except for one. Find that single one. Note:
Your algorithm should have a linear runtime complexity. Could you implement it without using extra m
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.For example:
Given binary tree [3,9,20,nul
Given a binary array, find the maximum number of consecutive 1s in this array.Example 1:Input: [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s.
Invert a binary tree.4
/ \
2 7
/ \ / \
1 3 6 9to4
/ \
7 2
/ \ / \
9 6 3 1 解法1:本质是输的先序遍历# Definition for a binary tree node.
# class TreeNode(object):
# def
Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.Examples:
Input: S
Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit,
You are given a data structure of employee information, which includes the employee's unique id, his importance value and his direct subordinates' id.For example, employee 1 is the leader of employee
Given two strings s and t which consist of only lowercase letters.String t is generated by random shuffling string s and then add one more letter at a random position.Find the letter that was added in
Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling your func
Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrou
Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped consecutively.Substring
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.Find all the elements of [1, n] inclusive that do not appear in this array.Could yo
ChatGPT是一种基于GPT-3.5架构的大型语言模型,由OpenAI开发。它采用了深度学习技术,具备强大的自然语言处理和对话生成能力。本文将介绍ChatGPT的技术背景、架构和应用领域,并探讨其在改变人机交互方式、提升用户体验以及应对挑战方面的潜力。引言
随着人工智能技术的迅猛发展,智能对话系统成为了人机交互领域的热点研究方向。ChatGPT作为目前最先进的语言模型之一,具备了强大的对话生成能
Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:
Given a = 1 and b = 2, return 3.
只能位运算:0x01101011 ^0x00111001----------0x01010010 0x0110101
X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Each digit must be rotated - we cannot choose to leave it alone.A num
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target.Example 1:Input:
5
/ \
3 6
/ \ \
2