The Travels of Marco Cai

  • Home

  • About

  • Tags

  • Archives

  • Search

[LeetCode] Challenge log 401

Posted on 2018-04-05 |
401. Binary Watch

https://leetcode.com/problems/binary-watch/description/

Read more »

Python String Format

Posted on 2018-04-05 |

Number Formatting

The following table shows various ways to format numbers using python’s str.format(), includes examples for both float formatting and integer formatting.

To run examples use print("FORMAT".format(NUMBER));
So to get the output of the first example, you would run: print("{:.2f}".format(3.1415926));

Number Format Output Description
3.1415926 {:.2f} 3.14 2 decimal places
3.1415926 {:+.2f} +3.14 2 decimal places with sign
-1 {:+.2f} -1.00 2 decimal places with sign
2.71828 {:.0f} 3 No decimal places
5 {:0>2d} 05 Pad number with zeros (left padding, width 2)
5 {:x<4d} 5xxx Pad number with x’s (right padding, width 4)
10 {:x<4d} 10xx Pad number with x’s (right padding, width 4)
1000000 {:,} 1,000,000 Number format with comma separator
0.25 {:.2%} 25.00% Format percentage
1000000000 {:.2e} 1.00e+09 Exponent notation
13 {:10d} 13 Right aligned (default, width 10)
13 {:<10d} 13 Left aligned (width 10)
13 {:^10d} 13 Center aligned (width 10)

[SQL] [LeetCode] Challenge log 182

Posted on 2018-04-04 | Edited on 2018-04-12 |
182. Duplicate Emails

https://leetcode.com/problems/duplicate-emails/description/

Read more »

[LeetCode] Challenge log 756

Posted on 2018-04-04 | Edited on 2018-04-05 |
756. Pyramid Transition Matrix

https://leetcode.com/problems/pyramid-transition-matrix/

Read more »

[LeetCode] Challenge log 398

Posted on 2018-04-03 | Edited on 2018-04-04 |
398. Random Pick Index

https://leetcode.com/problems/random-pick-index/description/

Read more »

[LeetCode] Challenge log 191

Posted on 2018-04-03 |
191. Number of 1 Bits

https://leetcode.com/problems/number-of-1-bits/description/

Read more »

[Java Review] 9: Polymophism

Posted on 2018-03-29 | Edited on 2018-05-01 |

[LeetCode] Challenge log 101

Posted on 2018-03-29 |
101. Symmetric Tree

https://leetcode.com/problems/symmetric-tree/description/

Read more »

[LeetCode] Challenge log 807

Posted on 2018-03-29 |
807. Max Increase to Keep City Skyline

https://leetcode.com/problems/max-increase-to-keep-city-skyline/description/

Read more »

[Java Review] 8: Object class

Posted on 2018-03-28 |

The following notes are based on video series: 手把手教你用Java基础教程 - 北京尚学堂 - 马士兵

Java API specfication: http://www.oracle.com/technetwork/java/api-141528.html

Read more »
1…10111213
Mingxiang Cai

Mingxiang Cai

A learner, a hobbyist.

128 posts
56 tags
© 2019 Mingxiang Cai
0%