Leetcode-easy problems 334 Reverse String - C++ STL String 字符串创建:string s; 字符串添加:s+=”c”; 字符串反转:s.reverse(); 412 Fizz Buzz - C++ STL Vector vector vec; vec.push_back(3); int转string: to_string(i) 直线装水: class Solution { public: int maxArea(vector<...
https://leetcode-cn.com/problems/valid-parentheses 方法分析: 该题使用的堆栈(stack)的知识。栈具有先进后出(FILO)的特点。堆栈具有栈顶和栈底之分。所谓入栈,就是将元素压入(push)堆栈;所谓出栈,就是将栈顶元素弹出(pop)堆栈。先入栈的一定后出栈,所以可以利用堆栈来检测符号是否正确配对。 解题思路: 有效...
I randomly picked several problems fromLeetcodebased on two independent parameters:difficulty level (easy/hard)andpublication date (before/after September 2021). I selected 13 problems from each of the 4 categories, totaling 52 problems. Each problem description was inputted intoChatGPT-4with a prom...
刷题链接:https://leetcode-cn.com/problems/merge-sorted-array/ 在这里提供两套解题思路: 直接将nums1后续的值填满,调用Arrays...不断++,则可不断获得n-1,n-2,n-3的值。即可成功解题。 public voidmerge(int[]nums1, intm, int[]nums2, intn) { for(int ...
—Easyhttps://leetcode.com/problems/squares-of-a-sorted-array/Code: JEECG - 基于代码生成器的J2EE智能开发框架 杂记:【演示视频和源码】 前言:随着WEB UI框架(EasyUi/Jquery UI/Ext)等的逐渐成熟,系统界面逐渐实现统一化,代码生成器也可以生成统一规范的界面!代码生成+手工MERGE半智能开发将是新的趋势,单表...
Find that single on ... LeetCode 136. Single Number (落单的数) Given an array of integers, every element appears twice except for one. Find that single one. Note:Y ... Leetcode 136 Single Number 仅出现一次的数字 原题地址https://leetcode.com/problems/single-number/ 题目描述Given an...
https://leetcode.com/problems/reverse-integer/description/ Descirption:Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 ...
题目地址:https://leetcode.com/problems/remove-duplicates-from-sorted-array/description/ 题意:给定一个已经排序好的数组,用O(1)的空间在原数组去掉重复的数,返回新的长度 思路:利用双指针,一个指向当前不重复的长度len,一个指向遍历看不重复的写到len ...
publicstaticint[]sortByBitsMe(int[]arr){Map<Integer,ArrayList<Integer>>map=newHashMap<>(16,1);Arrays.sort(arr);int count=0;for(int i:arr){count=binaryHaveOneNum(i);if(map.get(count)==null){map.put(count,newArrayList<>());}map.get(count).add(i);}int end=-1;for(int i=0;i...
原题链接 :https://leetcode.com/problems/l 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"". 编写一个可以找到一个字符串数组中最长公共前缀的函数,如果不存在的最长公共前缀返回空字符串""。