Challenge

Project 2

Arrays and Strings

SUBARRAY WITH GIVEN SUM

SubArray

OUTPUT:

  • Sum found between indexes 1 and 3

SubArray_1

OUTPUT:

  • Sum found between indexes 0 and 4

-----------------------------------------------------------------------------------------------------------------------------

PERMUTATIONS OF AN GIVEN STRING

Permutations

OUTPUT:

  • ABC ACB BAC BCA CAB CBA

Permutations_1

OUTPUT:

  • ABGS ABSG ABBS AGSB ASBG ASGB BAGS BASG BGAS BGSA BSAG BSGA GABS GASB GBAS GBSA GSAB GSBA SABG SAGB SBAG SBGA SGAB SGBA

-----------------------------------------------------------------------------------------------------------------------

Trees

DETERMINE IF TWO TREES ARE IDENTICAL

TwoTreesIdentical

OUTPUT:

  • True : Both trees are Identical

------------------------------------------------------------------------------------------------------------------------

COUNT LEAVES IN BINARY TREE

CountLeaves

OUTPUT:

  • OUTPUT: The leaf count of binary tree is : 2

-------------------------------------------------------------------------------------------------------------------------

LOWEST COMMON ANCESTOR IN BINARY TREE

LowestCommonAncestor

OUTPUT:

  • LCA(4, 5) = 2
    LCA(4, 6) = 1
    LCA(3, 4) = 1
    LCA(2, 4) = 2

-------------------------------------------------------------------------------------------------------------------------

Sorting

LINKED LIST OF 0S, 1S AND 2S, SORT IT

LinkedListOf1s2s

OUTPUT:

  • Linked List before sorting
    2 2 0 2 1 2 2 1
    Linked List after sorting
    0 1 1 2 2 2 2 2

-----------------------------------------------------------------------------------------------------------------------

Searching

FIND FIRST REPEATED CHARACTER

FindFirstRepeatedCharacter

OUTPUT:

  • Enter the String:
    Skilllync
    The First Repeated Character in the String is: l

FindFirstRepeatedCharacter_1

OUTPUT:

  • Enter the String:
    helloWorld
    The First Repeated Character in the String is: l

------------------------------------------------------------------------------------------------------------------------

CHECK IF TWO ARRAYS ARE EQUAL OR NOT

CheckTwoArray

OUTPUT:

  • Array a and b equal?: true
    Array a and b equal?: false

---------------------------------------------------------------------------------------------------------------------

Hashing

RELATIVE SORTING

RelativeSorting

OUTPUT:

  • Sorted array is
    2 2 1 1 8 8 3 5 6 7 9

RelativeSorting_1

OUTPUT:

  • Sorted array is
    2 2 6 6 4 5 7 8

----------------------------------------------------------------------------------------------------------------------

MINIMUM COST PATH

MinimumCostPath

OUTPUT:

  • 327

MinimumCostPath_1

OUTPUT:

  • 63

--------------------------------------------------------------------------------------------------------------------------

CIRCLE OF STRINGS

CircleOfString

OUTPUT:

  • Ordering is not possible : 0

CircleOfString_1

OUTPUT:

  • Ordering is not possible : 1

---------------------------------------------------------------------------------------------------------------------------

Stacks queues

FIRST NON-REPEATING CHARACTER IN A STREAM

FirstNonRepeatingCharacter

OUTPUT:

  • a -1 b b

FirstNonRepeatingCharacter_1

OUTPUT:

  • a -1 c

-----------------------------------------------------------------------------------------------------------------------

Heap

REARRANGE CHARACTERS

RearrangeCharacters

OUTPUT:

  • 1

RearrangeCharacters_1

OUTPUT:

  • 0

-------------------------------------------------------------------------------------------------------------------------

Dynamic Programming

LONGEST COMMON SUBSEQUENCE

LongestCommonSubsequence

OUTPUT:

  • Length of LCS is 4

-----------------------------------------------------------------------------------------------------------------------

MAXIMUM SUM OF INCREASING SUBSEQUENCES

MaximumSum

OUTPUT:

  • Sum of maximum sum increasing subsequence is 106

MaximumSum_1

OUTPUT:

  • Sum of maximum sum increasing subsequence is 10

----------------------------------------------------------------------------------------------------------------------

Your portfolio, next

Ship work like this
in your own course.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.