@@ -580,7 +580,26 @@ public bool ClassPhotos(List<int> redShirtHeights, List<int> blueShirtHeights)
580580
581581 #region TandemBicycle
582582 /// <summary>
583- ///
583+ /// A tandem bicycle is a bicycle that's operated by two people: Person A and Person B. Both
584+ /// people pedal bicycle, but the person that pedals faster dictates the speed of the bicycle.
585+ /// So if person A pedals at speed of 5, and person B pedal at a sped of 4, the tandem bicycle
586+ /// moved st a speed of 5(i.e tandemSped = Max(speedA,speedB).
587+ ///
588+ /// You're give tow list of positive integer: one that contains the speed of riders is wearing
589+ /// red shirts, and another is wearing blue shirts. Each rider is represented by a single positive
590+ /// integer, which is the speed that the pedal a tandem bicyle at. Both lists have the same length
591+ /// meaning that there are as many red shirt riders as there are blue shirt riders. Your goal os
592+ /// to pair every rider wearing a red shirt with a rider wearing a blue shirt to operate a tandem
593+ /// blue shirt.
594+ ///
595+ /// Write a function that returns the maximum possible total speed or the minimum possible total speed
596+ /// of all the tandem bicycle being ridden based on the input parameter, fastest. if fastest = tru.
597+ /// your function should return the maximum possible total speed; otherwise it should return
598+ /// the minimum total speed.
599+ ///
600+ /// Total speed is defined as the sum of the speeds of the tandem bicycle being ridden. For example
601+ /// if there are 4 riders who have speeds 1 3 4 5 and if they're paired to tandem bicycle as follows
602+ /// [1,4],[5,3] then the total speed of these tandem bicycle is 4 + 5 = 9
584603 /// </summary>
585604 public class TandemBicycleClass
586605 {
@@ -604,15 +623,16 @@ public int TandemBicycle(int[] redShirtSpeeds, int[] blueShirtSpeeds, bool faste
604623 return totalSpeed ;
605624 }
606625
607- private void ReverseArrayInPlace ( int [ ] redShirtSpeeds )
626+ private void ReverseArrayInPlace ( int [ ] array )
608627 {
609628 var start = 0 ;
610- var end = redShirtSpeeds . Length - 1 ;
629+ var end = array . Length - 1 ;
611630 while ( start < end )
612631 {
613- var temp = redShirtSpeeds [ start ] ;
614- redShirtSpeeds [ start ] = redShirtSpeeds [ end ] ;
615- redShirtSpeeds [ end ] = temp ;
632+ var temp = array [ start ] ;
633+ array [ start ] = array [ end ] ;
634+ array [ end ] = temp ;
635+
616636 start += 1 ;
617637 end -= 1 ;
618638 }
@@ -622,7 +642,29 @@ private void ReverseArrayInPlace(int[] redShirtSpeeds)
622642
623643 #region OptimalFreelancing
624644 /// <summary>
645+ /// You're recently started freelancing software development and have been offered a variety of job
646+ /// oppotunities. Each job has a deadline ,meaning there is no value in completing the work after the
647+ /// deadline.Additionally, each job has an associate payment representing the profit for completing
648+ /// that job. Givem this information, write a function that returns the maximum profit that can be obtained in
649+ /// a 7-day period.
650+ ///
651+ /// Each job will take one full day to complete, and the deadline will be given as the number of days left
652+ /// to complete the job. For example, if a job has deadline of 1, then it can only be completed if it is
653+ /// the first job worked on. if a job has a deadline of 2, then it could be started on the first or second
654+ /// day.
655+ ///
656+ ///
657+ /// Note: There is no requirement complete all of the jobs. Only one job can be worked on at a time, meaning
658+ /// that in some screnarios it will be impossible to complete them all.
625659 ///
660+ /// Samle Input:
661+ /// Jobs =[
662+ /// {"deadline":1,"payment":1},
663+ /// {"deadline":2,"payment":1},
664+ /// {"deadline":2,"payment":2}
665+ /// ]
666+ ///
667+ /// Output= 3
626668 /// </summary>
627669 public class OptimalFreelancingClass
628670 {
@@ -631,9 +673,7 @@ public int OptimalFreelancing(Dictionary<string, int>[] jobs)
631673 const int LENGTH_OF_WEEK = 7 ;
632674 int profit = 0 ;
633675 Array . Sort ( jobs , Comparer < Dictionary < string , int > > . Create ( ( jobOne , JobTwo ) => JobTwo [ "payment" ]
634- . CompareTo ( jobOne [ "payment" ] )
635- )
636- ) ;
676+ . CompareTo ( jobOne [ "payment" ] ) ) ) ;
637677
638678 bool [ ] timeline = new bool [ LENGTH_OF_WEEK ] ;
639679
@@ -658,7 +698,14 @@ public int OptimalFreelancing(Dictionary<string, int>[] jobs)
658698
659699 #region RemoveDuplicatesFromLinkedList
660700 /// <summary>
661- ///
701+ /// You're given the head of a Singly Linked list whose nodes are in sorted order with respect
702+ /// to their values. Write a function that returns a modified version of the linked List that doesn't
703+ /// contain any nodes with duplicated values. The Linked List should be modified in place (i:e, you
704+ /// shouldn't create a brand new list), and the modified Linked List should still its modified Linked
705+ /// List should still have its nodes sorted with respect to their values.
706+ ///
707+ /// Each Linked List node has integer has an integer value as well as a next node pointing to the next
708+ /// node in the list or to Node/null if it's the tail of the list.
662709 /// </summary>
663710 public class RemoveDuplicatesFromLinkedListClass
664711 {
@@ -716,8 +763,8 @@ public LinkedList MiddleNode(LinkedList linkedList)
716763 LinkedList fastnode = linkedList ;
717764 while ( fastnode != null && fastnode . next != null )
718765 {
719- slowNode = fastnode . next ;
720- fastnode = fastnode . next ;
766+ slowNode = slowNode . next ;
767+ fastnode = fastnode . next . next ;
721768 }
722769
723770 return slowNode ;
@@ -1218,12 +1265,11 @@ public int FirstNonRepeatingCharacter(string str)
12181265 /// </summary>
12191266 public class SemordnilapClass
12201267 {
1221- public List < List < string > > Semordnilap ( string [ ] words )
1222- {
1223- HashSet < string > wordsSet = new HashSet < string > ( ) ;
1268+ public List < List < string > > Semordnilap ( string [ ] input ) {
1269+ HashSet < string > wordsSet = new HashSet < string > ( input ) ;
12241270 List < List < string > > semordnilapPairs = new List < List < string > > ( ) ;
12251271
1226- foreach ( var word in words )
1272+ foreach ( string word in input )
12271273 {
12281274 char [ ] chars = word . ToCharArray ( ) ;
12291275 Array . Reverse ( chars ) ;
@@ -1236,9 +1282,9 @@ public List<List<string>> Semordnilap(string[] words)
12361282 wordsSet . Remove ( reverse ) ;
12371283 }
12381284 }
1239-
12401285 return semordnilapPairs ;
12411286 }
1287+
12421288 }
12431289 #endregion
12441290
0 commit comments