Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 381f2fa

Browse files
committed
updates
1 parent 1b13dc4 commit 381f2fa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

‎226_invert_binary_tree.scala‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Solution {
2+
def invertTree(root: TreeNode): TreeNode = {
3+
if (root == null) null
4+
else {
5+
val tmp = invertTree(root.left)
6+
root.left = invertTree(root.right)
7+
root.right = tmp
8+
root
9+
}
10+
}
11+
}

‎638_shopping_offers.scala‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
object Solution {
2+
def shoppingOffers(price: List[Int], special: List[List[Int]], needs: List[Int]): Int = {
3+
val special_filtered = special.filter(x => (x.init zip needs).map(y => y._1 <= y._2).reduce(_ && _))
4+
(special_filtered.map(x => x.last + shoppingOffers(price, special_filtered, (needs zip x.init).map(y => y._1 - y._2))) ++ List((price zip needs).map(x => x._1 * x._2).reduce(_ + _))).reduce(Math.min)
5+
}
6+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /