G

@gcl888

check number is Armstrong cs sum of cubes of number is the number.

C#
2 years ago
using System; class Program { static void Main() { int number = 153; int original = number; int result = 0;

reverse number cs

C#
2 years ago
using System; class Program { static void Main() { int number = 12345; int reversed = 0; while (number > 0)

fibonacci series cs

C#
2 years ago
using System; class Program { static void Main() { int n = 10; int first = 0; int second = 1;

find the first non-repeating character in the list cs

C#
2 years ago
using System; using System.Collections.Generic; class Program { static void Main() { string str = "aabbcdd"; Dictionary<char, int> frequencyMap = new Dictionary<char, int>();

implement bubble sort cs

C#
2 years ago
using System; class Program { static void Main() { int[] array = { 5, 3, 9, 2, 7 }; for (int i = 0; i < array.Length - 1; i++) {

check for palindrome cs

C#
2 years ago
using System; class Program { static void Main() { string str = "maddam"; bool isPalindrome = true; for (int i = 0; i < str.Length / 2; i++)

Count the frequency of each element in an array cs

C#
2 years ago
using System; using System.Collections.Generic; class Program { static void Main() { int[] array = { 2, 3, 4, 2, 1, 3, 4 }; Dictionary<int, int> frequencyMap = new Dictionary<int,

Find the second largest element in an array cs

C#
2 years ago
using System; class Program { static void Main() { int[] array = { 5, 3, 9, 2, 7 }; int max = int.MinValue; int secondMax = int.MinValue;

remove duplicates from array cs

C#
2 years ago
using System; using System.Linq; class Program { static void Main() { int[] array = { 2, 3, 4, 2, 1, 3, 4 }; int[] uniqueArray = array.Distinct().ToArray(); Console.WriteLine("Unique Array: " + string.Join(", ", uniqueArray));

Find the maximum element in an array cs

C#
2 years ago
using System; class Program { static void Main() { int[] array = { 5, 3, 9, 2, 7 }; int max = int.MinValue; foreach (int num in array)

check if number is prime cs

C#
2 years ago
using System; class Program { static void Main() { string str = "Hello World"; char[] charArray = str.ToCharArray(); Array.Reverse(charArray); string reversedStr = new string(charArray);

check if number is prime cs

C#
2 years ago
using System; class Program { static void Main() { //int number = 17; int number=0; Console.WriteLine("Accept number:");

calculate factorial cs

C#
2 years ago
using System; class Program { static void Main() { int number = 10; int factorial = 1; for (int i = 1; i <= number; i++)

calculate factorial cs

C#
2 years ago
using System; class Program { static void Main() { int number = 10; int factorial = 1; for (int i = 1; i <= number; i++)

add two numbers cs

C#
2 years ago
using System; class Program { static void Main() { int num1 = 5; int num2 = 3; int sum = num1 + num2; Console.WriteLine("Sum: " + sum);

add two numbers cs

C#
2 years ago
using System; class Program { static void Main() { int num1 = 5; int num2 = 3; int sum = num1 + num2; Console.WriteLine("Sum: " + sum);

Write a program to count the number of distinct islands in a given grid py

Python
2 years ago
def num_distinct_islands(grid): if not grid: return 0 distinct_islands = set() def dfs(row, col, path, direction): if row < 0 or row >= len(grid) or col < 0 or col >= len(grid[0]) or grid[row][col] != 1: return

Write a program to count the number of distinct islands in a given grid py

Python
2 years ago
def num_distinct_islands(grid): if not grid: return 0 distinct_islands = set() def dfs(row, col, path, direction): if row < 0 or row >= len(grid) or col < 0 or col >= len(grid[0]) or grid[row][col] != 1: return

Write a program to reverse a linked list py

Python
2 years ago
class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def reverse_linked_list(head): prev = None current = head while current:

Write a program to find the maximum sum of a subarray within a given list, where the subarray len py

Python
2 years ago
#Write a program to find the maximum sum of a subarray within a given list, #where the subarray length is at most k. def max_subarray_sum(nums, k): if k <= 0 or len(nums) == 0: return 0 max_sum = float('-inf') current_sum = 0 start = 0