Welcome to the Daily Coding Problems repository! In this repository, you will find a collection of daily coding problems to challenge and improve your programming skills.
-
Problem 1- Two Sum Problem - Given an array of integers and a target, find two numbers in the array that add up to the target.
-
Problem 2- Remove Duplicates from Sorted Array - Given an integer array
numssorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements innums. -
Problem 3- Remove Element - Given an integer array
numsand an integerval, remove all occurrences ofvalinnumsin-place. The order of the elements may be changed. Then return the number of elements innumswhich are not equal toval. -
Problem 4- Search Insert Position - Given a sorted array of distinct integers 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 must write an algorithm with
O(log n)runtime complexity. -
Problem 5- Plus One - Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer. The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit. You must write an algorithm with
O(n)runtime complexity. -
Problem 6- Pascal's Triangle - Given an integer
numRows, return the firstnumRowsof Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it as shown. -
Problem 7- Merge Two Sorted Arrays - Given two sorted integer arrays
nums1andnums2, mergenums2intonums1as one sorted array. The number of elements initialized innums1andnums2aremandnrespectively. You must write an algorithm withO(m + n)runtime complexity. -
Problem 8- Single Number - Given a non-empty array of integers
nums, every element appears twice except for one. Find that single one. You must write an algorithm withO(n)runtime complexity andO(1)extra space complexity. -
Problem 9- Majority Element - Given an array
numsof size n, return the majority element. The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array. You must write an algorithm withO(n)runtime complexity andO(1)extra space complexity. -
Problem 10- Pascal's Triangle II - Given an integer
rowIndex, return therowIndex-th (0-indexed) row of Pascal's triangle. In Pascal's triangle, each number is the sum of the two numbers directly above it . -
Problem 11- Summary Ranges - You are given a sorted unique integer array
nums. Return the smallest sorted list of ranges that cover all the numbers in the array exactly. That is, each element ofnumsis covered by exactly one of the ranges, and there is no integerxsuch thatxis in one of the ranges but not innums. -
Problem 12- Missing Number in Array - Given an array
numscontaining n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. -
Problem 13- Move Zeros - Given an integer array
nums, move all0's to the end of it while maintaining the relative order of the non-zero elements. You must do this in-place without making a copy of the array. -
Problem 14- Range Sum Query - Immutable - Given an integer array
nums, handle multiple queries of the following type: Calculate the sum of the elements ofnumsbetween indicesleftandright.