publicintmaxSum(int[][] m){ if(m==null || m.length==0 || m[0].length==0) return0; int col = m[0].length; int[] sumArr = newint[col]; int res = Integer.MIN_VALUE; for(int i=0;i<m.length;i++){ Arrays.fill(sumArr, 0); for(int j=i;j<m.length;j++){ for(int k=0;k<col;k++){ sumArr[k] += m[j][k]; } res = Math.max(res, maxSum(sumArr)); } } return res; }
//求子数组累加最大和 publicintmaxSum(int[] arr){ if(arr==null || arr.length==0) return0; int sum = arr[0]; int res = sum; for(int i=1;i<arr.length;i++){ if(arr[i]+sum>arr[i]){ sum += arr[i]; }else sum = arr[i]; res = Math.max(sum, res); } return res; }
publicinterfaceEmployeeFactory{ public Employee makeEmployee(EmployeeRecord r) } public class EmployeeFactoryImpl implements EmployeeFactory{ public Employee makeEmployee(EmployeeRecord r){ switch(r.type){ case COMMISSONED: returnnew ComissionedEmployee(r); case HOURLY: returnnew HourlyEmployee(r); case SALARIED: returnnew SalariedEmployee(r); default: thrownew InvalidEmployeeType(e); } } }
publicintmaxLength(){ int[] h = newint[arr.length+1]; int sum = 0; h[0] = sum; for(int i=0;i!=arr.length;i++){ sum += arr[i]; h[i+1] = Math.max(sum, h[i]); } sum = 0; int res = 0; int pre = 0; int len = 0; for(int i=0;i!=arr.length;i++){ sum+=arr[i]; pre = getLessIndex(h, sum-k); len = pre == -1?0:i-pre+1; res = Math.max(res, len); } return res; }
publicintgetLessIndex(int[] arr, int num){ int low = 0; int high = arr.length-1; int mid = 0; int res = -1; while(low<=high){ mid = (low+high)>>1; if(arr[mid]>=num){ res = mid; high = mid -1; }else{ low = mid+1; } } return res; }
publicvoidheapInsert(int[] arr, int value, int index){ arr[index] = value; while(index!=0){ int parent = (index-1)/2; if(arr[parent] < arr[index]){ swap(arr, parent, index); index = parent; }else{ break; } } }
publicvoidheapify(int[] arr, int index, int heapSize){ int left = index * 2+1; int right = index * 2+2; int largest = index; while(left < heapSize){ if(arr[left] > arr[index]){ largest = left; } if(right < heapSize && arr[right] > arr[largest]){ largest = right; } if(largest!=index){ swap(arr, largest, index); }else{ break; } index = largest; left = index * 2+1; right = index * 2+2; } }
publicvoidswap(int[] arr, int index1, int index2){ int tmp = arr[index1]; arr[index1] = arr[index2]; arr[index2] = tmp; }
publicintmedianOfMedians(int[] arr, int begin, int end){ //把整个数组5个5个分为一组 int num = end - begin + 1; int offset = num % 5 ==0?0:1; //mArr是所有小区间中中间数组成的新数组 int[] mArr = newint[num/5+offset]; for(int i=0;i<mArr.length;i++){ int beginI = begin+i*5; int endI = beginI + 4; //mArr[i]是这个小区间内排序后的中间数 mArr[i] = getMedian(arr, beginI, Math.min(end, endI)); } //继续进行筛选,最终找出的是整个数组中最中间的数(但是却不用把整个数组进行排序) return select(mArr, 0, mArr.length-1, mArr.length / 2); }
//对数组进行划分,即找到枢轴值的位置,并且让该值左边都是小于他,右边都是大于他 publicint[] partition(int[] arr, int begin, int end, int pivotValue){ int small = begin-1; int cur = begin; int big = end +1; while(cur!=big){ if(arr[cur] < pivotValue){ swap(arr, ++small, cur++); }elseif(arr[cur] > pivotValue){ swap(arr, cur, --big); }else{ cur++; } } int[] range = newint[2]; range[0] = small + 1; range[1] = big - 1; return range; }
//对arr进行插入排序,然后找到最中间的数,返回 publicintgetMedian(int[] arr, int begin, int end){ insertionSort(arr, begin, end); int sum = end + begin; int mid = (sum/2) + (sum % 2); return arr[mid]; }
# URL ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/' url:http://yoursite.com# 你的域名,如果有 root:/ permalink::year/:month/:day/:title/ permalink_defaults:
# Writing # 博文相关 new_post_name::title.md# 博文的格式,默认markdown编辑 default_layout:post# 默认发布的为post,即默认发布的是文章 # 共有三种类型,具体见hexo文档 titlecase:false# Transform title into titlecase external_link:true# Open external links in new tab filename_case:0 render_drafts:false post_asset_folder:false relative_link:false future:true highlight: enable:true line_number:true auto_detect:false tab_replace: # Home page setting # path: Root path for your blogs index page. (default = '') # per_page: Posts displayed per page. (0 = disable pagination) # order_by: Posts order. (Order by date descending by default) index_generator: path:'' per_page:10# 首页每页展示的文章数 order_by:-date# 按日期逆序 # Category & Tag default_category:uncategorized category_map: tag_map:
# Date / Time format ## Hexo uses Moment.js to parse and display date ## You can customize the date format as defined in ## http://momentjs.com/docs/#/displaying/format/ date_format:YYYY-MM-DD time_format:HH:mm:ss
# Pagination ## Set per_page to 0 to disable pagination per_page:10 pagination_dir:page
# --------------------------------------------------------------- # Site Information Settings # ---------------------------------------------------------------
# To get or check favicons visit: https://realfavicongenerator.net # Put your favicons into `hexo-site/source/` (recommend) or `hexo-site/themes/next/source/images/` directory.
# Default NexT favicons placed in `hexo-site/themes/next/source/images/` directory. # And if you want to place your icons in `hexo-site/source/` root directory, you must remove `/images` prefix from pathes.
# For example, you put your favicons into `hexo-site/source/images` directory. # Then need to rename & redefine they on any other names, otherwise icons from Next will rewrite your custom icons in Hexo.
# Set rss to false to disable feed link. # Leave rss as empty to use site's feed link, and install hexo-generator-feed: `npm install hexo-generator-feed --save`. # Set rss to specific value if you have burned your feed already. rss:
footer: # Specify the date when the site was setup. # If not defined, current year will be used. #since: 2015
# Icon between year and copyright info. icon: # Icon name in fontawesome, see: https://fontawesome.com/v4.7.0/icons # `heart` is recommended with animation in red (#ff0000). name:user # If you want to animate the icon, set it to true. animated:false # Change the color of icon, using Hex Code. color:"#808080"
# If not defined, will be used `author` from Hexo main config. copyright: # ------------------------------------------------------------- powered: # Hexo link (Powered by Hexo). enable:true # Version info of Hexo after Hexo link (vX.X.X). version:false
theme: # Theme & scheme info link (Theme - NexT.scheme). enable:true # Version info of NexT after scheme info (vX.X.X). version:false # ------------------------------------------------------------- # Any custom text can be defined here. #custom_text: Hosted by <a target="_blank" rel="external nofollow" href="https://pages.coding.me"><b>Coding Pages</b></a>
# --------------------------------------------------------------- # SEO Settings # ---------------------------------------------------------------
# SEO 相关设置
# Canonical, set a canonical link tag in your hexo, you could use it for your SEO of blog. # See: https://support.google.com/webmasters/answer/139066 # Tips: Before you open this tag, remember set up your URL in hexo _config.yml ( ex. url: http://yourdomain.com ) canonical:true
# Change headers hierarchy on site-subtitle (will be main site description) and on all post/pages titles for better SEO-optimization. seo:true# 开启seo优化
# If true, will add site-subtitle to index page, added in main hexo config. # subtitle: Subtitle index_with_subtitle:true# 网页搜索及标签页显示副标题
# --------------------------------------------------------------- # Menu Settings # ---------------------------------------------------------------
# When running the site in a subdirectory (e.g. domain.tld/blog), remove the leading slash from link value (/archives -> archives). # Usage: `Key: /link/ || icon` # Key is the name of menu item. If translate for this menu will find in languages - this translate will be loaded; if not - Key name will be used. Key is case-senstive. # Value before `||` delimeter is the target link. # Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, question icon will be loaded.
# 以下为主菜单按键设置,不需要的在行首用#注释掉 # 启用的标签页需要创建相应的目录 # 例如: # cd *** # 进入微博根目录 # hexo new page about # 创建about页面
# Posts / Categories / Tags in sidebar. site_state:true
# Social Links. # Usage: `Key: permalink || icon` # Key is the link label showing to end users. # Value before `||` delimeter is the target permalink. # Value after `||` delimeter is the name of FontAwesome icon. If icon (with or without delimeter) is not specified, globe icon will be loaded. #social: #GitHub: https://github.com/yourname || github #E-Mail: mailto:yourname@gmail.com || envelope #Google: https://plus.google.com/yourname || google #Twitter: https://twitter.com/yourname || twitter #FB Page: https://www.facebook.com/yourname || facebook #VK Group: https://vk.com/yourname || vk #StackOverflow: https://stackoverflow.com/yourname || stack-overflow #YouTube: https://youtube.com/yourname || youtube #Instagram: https://instagram.com/yourname || instagram #Skype: skype:yourname?call|chat || skype
social_icons: enable:true icons_only:false transition:false # Dependencies: exturl: true in Tags Settings section below. # To encrypt links above use https://www.base64encode.org # Example encoded link: `GitHub: aHR0cHM6Ly9naXRodWIuY29tL3RoZW1lLW5leHQ= || github` exturl:false
# Follow me on GitHub banner in right-top corner. # Usage: `permalink || title` # Value before `||` delimeter is the target permalink. # Value after `||` delimeter is the title and aria-label name. #github_banner: https://github.com/yourname || Follow me on GitHub
avatar: # in theme directory(source/images): /images/avatar.gif # in site directory(source/uploads): /uploads/avatar.gif # You can also use other linking images. url:/images/touxiang.jpg # If true, the avatar would be dispalyed in circle. #rounded: false # The value of opacity should be choose from 0 to 1 to set the opacity of the avatar. opacity:1 # If true, the avatar would be rotated with the cursor. rotated:false
# Table Of Contents in the Sidebar toc: enable:true
# Automatically add list number to toc. number:true
# If true, all words will placed on next lines if header width longer then sidebar width. wrap:false
# Creative Commons 4.0 International License. # http://creativecommons.org/ # Available: by | by-nc | by-nc-nd | by-nc-sa | by-nd | by-sa | zero #creative_commons: by-nc-sa #creative_commons:
# 菜单栏放置于左边还是右边
sidebar: # Sidebar Position, available value: left | right (only for Pisces | Gemini). position:left #position: right
# Manual define the sidebar width. # If commented, will be default for: # Muse | Mist: 320 # Pisces | Gemini: 240 #width: 300
# Sidebar Display, available value (only for Muse | Mist): # - post expand on posts automatically. Default. # - always expand for all pages automatically # - hide expand only when click on the sidebar toggle icon. # - remove Totally remove sidebar including sidebar toggle. display:post #display: always #display: hide #display: remove
# Sidebar offset from top menubar in pixels (only for Pisces | Gemini). offset:12# 文章索引与顶部的距离
# Back to top in sidebar (only for Pisces | Gemini). b2t:false# 回到顶部是否置于菜单栏下方
# Scroll percent label in b2t button. scrollpercent:false
# Enable sidebar on narrow view (only for Muse | Mist). onmobile:false
# --------------------------------------------------------------- # Post Settings # ---------------------------------------------------------------
# Automatically scroll page to section which is under <!-- more --> mark. scroll_to_more:false# 是否自动进行“查看全文”标记
# Automatically saving scroll position on each post/page in cookies. save_scroll:false# 是否记录浏览位置
# Automatically excerpt description in homepage as preamble text. excerpt_description:true# 是否自动摘录作为前言
# Automatically Excerpt. Not recommend. # Please use <!-- more --> in the post to control excerpt accurately. auto_excerpt: enable:false length:150
# Post meta display settings post_meta: item_text:true created_at:true updated_at: enabled:true # If true, show updated date label only if `updated date` different from 'created date' (post edited in another day than was created). # And if post will edited in same day as created, edited time will show in popup title under created time label. # If false show anyway, but if post edited in same day, show only edited time. another_day:true categories:true
codeblock: # Manual define the border radius in codeblock # Leave it empty for the default 1 border_radius: # Add copy button on codeblock copy_button: enable:false # Show text copy result show_result:false
# 微信订阅相关设置
# Wechat Subscriber #wechat_subscriber: #enabled: true #qcode: /path/to/your/wechatqcode ex. /uploads/wechat-qcode.jpg #description: ex. subscribe to my blog by scanning my public wechat account
# Related popular posts # Dependencies: https://github.com/tea3/hexo-related-popular-posts related_posts: enable:false title:# custom header, leave empty to use the default one display_in_home:false params: maxCount:5 #PPMixingRate: 0.0 #isDate: false #isImage: false #isExcerpt: false
# Declare license on posts post_copyright: enable:false license:<ahref="https://creativecommons.org/licenses/by-nc-sa/4.0/"rel="externalnofollow"target="_blank">CCBY-NC-SA4.0</a>
# Post edit # Dependencies: https://github.com/hexojs/hexo-deployer-git post_edit: enable:false url:https://github.com/theme-next/theme-next.org/_posts/tree/master/# Link for view source. # url: https://github.com/theme-next/theme-next.org/_posts/edit/master/ # Link for fork & edit.
# Custom Logo. # !!Only available for Default Scheme currently. # Options: # enabled: [true/false] - Replace with specific image # image: url-of-image - Images's url custom_logo: enabled:false image:
# Code Highlight theme # Available values: normal | night | night eighties | night blue | night bright # https://github.com/chriskempson/tomorrow-theme highlight_theme:nighteighties# 代码高亮风格
# Enable "cheers" for archive page. cheers_enabled:true
# --------------------------------------------------------------- # Font Settings # - Find fonts on Google Fonts (https://www.google.com/fonts) # - All fonts set here will have the following styles: # light, light italic, normal, normal italic, bold, bold italic # - Be aware that setting too much fonts will cause site running slowly # - Introduce in 5.0.1 # --------------------------------------------------------------- # CAUTION! Safari Version 10.1.2 bug: https://github.com/iissnan/hexo-theme-next/issues/1844 # To avoid space between header and sidebar in Pisces / Gemini themes recommended to use Web Safe fonts for `global` (and `logo`): # Arial | Tahoma | Helvetica | Times New Roman | Courier New | Verdana | Georgia | Palatino | Garamond | Comic Sans MS | Trebuchet MS # ---------------------------------------------------------------
# 字体相关设置 # 因为上述的谷歌字体中没有中文支持 # 所以下列一般只改字体大小
font: enable:true
# Uri of fonts host. E.g. //fonts.googleapis.com (Default). host:
# Font options: # `external: true` will load this font family from `host` above. # `family: Times New Roman`. Without any quotes. # `size: xx`. Use `px` as unit.
# Global font settings used for all elements in <body>. global: external:true family:Lato size:18
# Font settings for Headlines (H1, H2, H3, H4, H5, H6). # Fallback to `global` font settings. headings: external:true family: size:
# Font settings for posts. # Fallback to `global` font settings. posts: external:true family:
# Font settings for Logo. # Fallback to `global` font settings. logo: external:true family: size:
# Font settings for <code> and code blocks. codes: external:true family: size:14