AspBucket offers ASP.NET, C#, VB, Jquery, CSS, Ajax, SQL tutorials. It is the best place for programmers to learn

Showing posts with label DSA. Show all posts
Showing posts with label DSA. Show all posts

Sunday, 22 January 2023

Friday, 13 January 2023

DSA Problem solution: Find Kth Largest Element in an Array using Heap in C#



Given an integer array nums and an integer k, return the kth largest element in the array.

Note that it is the kth largest element in the sorted order, not the kth distinct element.


Example 1:

Input: nums = [3,2,1,5,6,4], k = 2

Output: 5

Saturday, 7 January 2023

DSA Problem Solution: Binary Search





Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

Example 1:

Input: nums = [-6,1,3,5,9,11], target = 9

Output: 4

Explanation: 9 exists in nums and its index is 4

Monday, 26 December 2022

DSA Problem Solution: Product of Array Except Self



Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].

The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.

Example 1:

Input: nums = [1,2,3,4]

Output: [24,12,8,6]

  • Popular Posts
  • Comments