Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
Question Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with constant memory. For example, Given input array nums = [1,1,2], Your function ...
Related to questionExcel Sheet Column Title Given a column title as appear in an Excel sheet, return its corresponding column number. For example: A -> 1 B -> 2 C -> 3 ... Z -> 26 AA -> 27 AB -> 28 题目分析:处理26进制,逐个读入字符串的每一个字符进行处理转换,逐个移位; java代...
*/publicclassSolution{publicintsubarraySum(int[]nums,int k){int count=0,pre=0;HashMap<Integer,Integer>mp=newHashMap<>();mp.put(0,1);for(int i=0;i<nums.length;i++){pre+=nums[i];if(mp.containsKey(pre-k)){count+=mp.get(pre-k);}mp.put(pre,mp.getOrDefault(pre,0)+1);}ret...
Question : Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, Given [100, 4, 200, 1, 3, 2], The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity...
class Solution { /* O(n) */ public boolean isAnagram(String s, String t) { if (s.length() != t.length()) { return false; } int[] nums = new int[26]; // 每个位置记录字符出现次数 for (int i = 0; i < s.length(); i++) { nums[s.charAt(i)-'a']++; } // 字符抵...
com/explore/interview/card/top-interview-questions-easy/?utm_campaign=lcsocial&utm_medium=question&...
public class P${question.frontendQuestionId}_$!velocityTool.camelCaseName(${question.titleSlug}){ public static void main(String[] args) { //测试代码 Solution solution = new P$!{question.frontendQuestionId}_$!velocityTool.camelCaseName(${question.titleSlug})().new Solution(); ...
Note:This question is the same as 1038:https://leetcode.com/problems/binary-search-tree-to-greater-sum-tree/ 1. Please don't postany solutionsin this discussion. 2. The problem discussion is for asking questions about the problem or for sharing tips - anything except for solutions. ...
Question : The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) 代码语言:javascript 代码运行次数:0 运行 AI代码解释 P A H N A P L S I I G Y I R And then...