![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法分析与设计作业
ssj199705281
这个作者很懒,什么都没留下…
展开
-
算法分析与设计作业
算法分析与设计作业题Two SumGiven an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you ma...原创 2018-10-14 23:14:02 · 147 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same v...原创 2018-11-17 23:21:21 · 172 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) ...原创 2018-12-02 14:04:17 · 220 阅读 · 1 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) ...原创 2018-12-02 14:19:58 · 126 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源本题求一个树是否是平衡树。可以采用深度优先遍历,计算树的高度,如果左右子树高度差超过1,则返回-1 .class Solution {public: int isBalancedHelper(TreeNode* root) { if(root == NULL) return 0; int leftHeight ...原创 2018-12-08 19:29:53 · 116 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源(Medium)You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the ...原创 2018-12-29 16:08:51 · 140 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源 (hard)There are two sorted arrays nums1 and nums2 of size m and n respectively.Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).You m...原创 2018-12-29 16:29:31 · 124 阅读 · 0 评论 -
算法分析与设计期末项目
问题描述Suppose there are n facilities and m customers.We wish to choose:which of the n facilities to openthe assignment of customers to facilitiesThe objective is to minimize the sum of the opening c...原创 2018-12-29 21:35:07 · 289 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源(Medium)我们可以用一个map来实现,map保存的key-val值为string中字符的值以及它上一次出现的位置,index表示没有重复字符字符串的首字符位置,i代表没有重复字符字符串的最右位置。每次遍历到i时,如果map不包含s.charAt(i),则计算长度i-len+1,否则,更新index位置。然后再计算长度。一次遍历之后就可以得到结果。class...原创 2019-01-06 14:19:20 · 165 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively.You m...原创 2018-11-17 22:38:01 · 244 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will...原创 2018-11-13 16:08:22 · 139 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C 10...原创 2018-10-28 21:32:00 · 357 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题Palindrome NumberDetermine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.Example 1:Input: 121Output: trueExample 2:Input: -...原创 2018-10-21 19:38:07 · 86 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string “”.Example 1:Input: [“flower”,“flow”,“flig...原创 2018-11-01 18:51:16 · 81 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates ...原创 2018-11-01 19:36:05 · 113 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Example:Input: [-2,1,-3,4,-1,2,1,-5,4],Output...原创 2018-11-01 20:45:12 · 118 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given a string s consists of upper/lower-case alphabets and empty space characters ’ ', return the length of last word in the string.If the last word does not exist, return 0.Note: A...原创 2018-11-02 14:49:46 · 119 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, a...原创 2018-11-02 15:03:21 · 97 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.Example 1:Input: a = “11”, b = “1”Output:...原创 2018-11-02 15:19:23 · 128 阅读 · 0 评论 -
算法分析与设计作业
算法分析与设计作业题作业来源(hard)public class Solution { public int longestValidParentheses(String s) { if(s == null || s.length()<=1) return 0; int count = 0, max=0, depth = 0; f...原创 2019-01-06 15:54:52 · 145 阅读 · 0 评论