1. 题目 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by the character '.'. You may assume that there will be only one unique solution. A sudoku puzzle... ...and its solution numbers marked in red. [链接] 2. 思路 每次找到最合适填入点进行试探。每次...
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters.
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exactly one solution.
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
1. 题目 Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 2. 思路 按序累加即可。考虑{4、9}*10^i的场景,做好减法和多跳一步。 3. 代码 耗时:29ms {代码...}
1. 题目 Given an integer, convert it to a roman numeral. Input is guaranteed to be within the range from 1 to 3999. 2. 思路 罗马数字的规则: 字符:M=1000, D=500, C=100, L=50, X=10, V=5, I=1. 按序累加即可。 {1,5} * 10^i, 在千这个范围的规则字符数 考虑字符的下一位的最小值,比如{4,9}*10^i, 是通...
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most wa...