注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
1. BestTimetoBuyandSellStock
类似买卖股票最佳时间的一道题(Medium)
1. BirthdayCount
找基数个数的生日
/**
* In the hostel, there are birthday celebrations every month. Given N number of days which are representing the
* birthday, find the number of days where there are an odd number of birthday celebrations.
* <p>
* Input
* The first line of the input consists of an integer - days_size representing the number of birthdays celebrations(N).
* The second line of the input consists of N space-separate integers - days, representing the birthdays' celebrations
* in a month.
* <p>
* Output
* Print an integer representing the number of days where there is an odd number of birthday celebrations.
* <p>
* Constraints
* 0 ≤ days_size ≤ 10^3
* 0 < days[i] ≤ 31; Where i is representing the index of the days
* 0 ≤ i < days_size
* <p>
* Example
* Input:
* 5
* 4 8 2 8 9
* Output:
* 3
* Explanation:
* There are 5 numbers in this array. 4 has occurred once which is odd, so it meets the criteria, 8 doesn't as it has
* occurred twice, 2and 9 meet the criteria of occurring an odd number of times. So.the output is 3.
*/
2. DecodeWays
给一串全是数字的String 类似“100200300” 或者“99” 问转换成字母有多少种不同interpretation
(字母表a=0 b=1 ... z=25然后input是一串数字 需要算一共有多少种转化成字母的方法 111有三种bbb/bl/lb 99只能是jj所以只有一种)
动态规划:
/**
* Consider a coding system where letters are represented as sequential decimal numbers starting from 0,
* (i.e., a=O, b=1, c=2 .... z=25). Given a string of digits (e.g. "123") as input, print out the number of valid
* interpretations of letters.
*
* Write an algorithm to calculate the number of valid interpretations of the letters formed by the given input.
* Input
* The first line of input consists of a string - decInput, representing the decimal numbers.
* Output
* Print an integer representing the number of valid interpretations for the letters formed by the given string of digits.
*/
4. DititalAddEqualFindNumber
各个位相加等于某数
given int x & y, return the number of int less than or equal to representing the x coordinate of the queen;
* The third line of the input consists of an integer cord_x2, representing the x coordinate of the opponent piece;
* The fourth line of the input consists of an integer cord_y2, representing the y coordinate of the opponent piece.
*
* Output
* Print a sting "Yes" if the queen can attack the opponent piece. Otherwise, print "No"
*
* Examples
*
* Example1:
* Input:
* 4
* 5
* 6
* 7
* Output:
* Yes
* Explanation:
* When the queen is located at position (4 5) and the opponent piece is located at position (6 7), the queen may attack the piece in a diagonal attack.
*
* Example 2:
* Input:
* 1
* 1
* 3
* 2
* output:
* No
*/
28. Rotate matrix 90 degrees
Rotate image 默认answer[100][100], 重置m, n,行列copy;
/**
* Question
* Write an algorithm to rotate the image by 90 degrees right.
* lnput
* The first line of the input consists of two space-separated integers - matrix_rows and matrix_cols, representing the
* number of rows of the matrix(N) and number of columns of the matrix(M);
* The next N lines consist of M space-separated integers, representing the pixel of the matrix.
* Output
* Print M lines consist of N space-separated integers representing the rotated image by 90 degrees.
* Example
* Input:
* 3 3
* 123
* 456
* 789
* output:
* 741
* 852
* 963
*/
30. Word Search 变种
|