great

java Double Map HashMap Integer Null

余生长醉 提交于 2020-02-05 05:24:24
Complete the function, which calculates how much you need to tip based on the total amount of the bill and the service. 完成一个函数,基于总金额和服务水平评级,计算出你需要付出多少小费 You need to consider the following ratings: 你需要参照以下关于评级的比例: Terrible: tip 0% Poor: tip 5% Good: tip 10% Great: tip 15% Excellent: tip 20% The rating is case insensitive (so “great” = “GREAT”). If an unrecognised rating is received, then you need to return: 评级不区分大小写,如果接收到无法识别的评分,则需要返回: “Rating not recognised” in Javascript, Python and Ruby… …or null in Java 或 java里的 null …or -1 in C# Because you’re a nice person, you always round up the tip,

lintcode856. 句子相似性

坚强是说给别人听的谎言 提交于 2020-01-15 23:17:15
给出两个句子words1和words2(每个用一个字符串数组表示),和一个相似词对数组pairs,你需要判断两个句子是否相似。 例如,如果相似词对是pairs = [[“great”, “fine”], [“acting”,“drama”], [“skills”,“talent”]],那么words1 = great acting skills和words2 = fine drama talent是相似的。 需要注意,相似关系是不可传递的。例如,如果"great"和"fine"相似,"fine"和"good"相似,"great"和"good"不是一定相似的。 然而,相似性是对称的。例如,"great"和"fine"相似,则"fine"和"great"也是相似的,这两者是等价的。 另外,一个单词永远与它本身相似。例如,句子words1 = [“great”], words2 = [“great”], pairs = []是相似的,尽管没有相似词对。 最后,两个句子只有在单词数相等的情况下才可能相似。所以,句子words1 = [“great”]永远不可能与句子words2 = [“doubleplus”,“good”]相似。 样例 样例 1 输入 : words1 = [ "great" , "acting" , "skills" ] , words2 = [ "fine" ,

LeetCode开心刷题三十三天——87. Scramble String

只愿长相守 提交于 2019-11-27 02:24:26
87. Scramble String Hard 318 521 Favorite Share Given a string s1 , we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great" : great / \ gr eat / \ / \ g r e at / \ a t To scramble the string, we may choose any non-leaf node and swap its two children. For example, if we choose the node "gr" and swap its two children, it produces a scrambled string "rgeat" . rgeat / \ rg eat / \ / \ r g e at / \ a t We say that "rgeat" is a scrambled string of "great" . Similarly, if we continue to swap the children of