letCode-1】的更多相关文章

letcode里面刷题,坑还是链表不熟,(1)头结点还是有必要设置,否则返回的时候找不到位置:(2)先设置next到新节点再next到下一个节点:都是基础知识 /* * * You are given two linked lists representing two non-negative numbers. * The digits are stored in reverse order and each of their nodes contain a single digit. * Ad…
letcode第一题, tm的不好弄. 想了很久想到了一个粗蠢的解决办法. Given 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 may not use the same element twice…
Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible input cases. Notes: It is intended for this problem to be spe…
Given an array of integers, return indices of the two numbers such that they add up to a specific target. 给定一个integer类型的数组,让你返回数组中两个元素相加起来等于给定的值得元素的索引数组 You may assume that each input would have exactly one solution. 你可以假设每个给定值只有一个解决方案,那这里我们就不必考虑多个解决…
p { margin-bottom: 0.25cm; line-height: 120% } 一.理论证明 p { margin-bottom: 0.25cm; line-height: 120% } 由以上推导易得公式为:Xk+1 = (Xk +a/Xk)/2 代码实现: class Solution { public: int mySqrt(int x) { double last_pre = 3.000; ;i < ;i++){ double cur_num = (pre_num + do…
回文串 回文串(palindromic string)是指这个字符串无论从左读还是从右读,所读的顺序是一样的:简而言之,回文串是左右对称的.一般求解一个字符串的最长回文子串问题. problem:Longest Palindromic Substring 参考 1.LongestPalindromicSubstring: 完…
1 题目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−1,2,1] has the largest sum = 6. click to show more practic…
问题描述: You're given strings J representing the types of stones that are jewels, and S representing the stones you have.  Each character in S is a type of stone you have.  You want to know how many of the stones you have are also jewels. The letters in…
题目 罗马转整数 题目描述 罗马数字包含以下七种字符: I, V, X, L,C,D 和 M. 字符 数值 I 1 V 5 X 10 L 50 C 100 D 500 M 1000 例如, 罗马数字 2 写做 II ,即为两个并列的 1 .12 写做 XII ,即为 X + II . 27 写做  XXVII, 即为 XX + V + II . 通常情况下,罗马数字中小的数字在大的数字的右边.但也存在特例,例如 4 不写做 IIII,而是 IV.数字 1 在数字 5 的左边,所表示的数等于大数…
回文数 题目描述 给定一个整数数组 nums 和一个整数目标值 target,请你在该数组中找出 和为目标值 target  的那 两个 整数,并返回它们的数组下标. 你可以假设每种输入只会对应一个答案.但是,数组中同一个元素在答案里不能重复出现. 你可以按任意顺序返回答案. 示例 1: 输入:nums = [2,7,11,15], target = 9 输出:[0,1] 解释:因为 nums[0] + nums[1] == 9 ,返回 [0, 1] . 示例 2: 输入:nums = [3,2…