Showing posts sorted by relevance for query C# 2000 things. Sort by date Show all posts
Showing posts sorted by relevance for query C# 2000 things. Sort by date Show all posts

Wednesday, September 6, 2017

Booking reading: C# tutorial

Sept. 6, 2017

#CSharpTutorial #BookReading #AdvancedTopics 


Introduction


It is never too late to read a C# tutorial. Today I spent over one hour to read C# tutorial, and then I read the first time about C# reference types. There are four types which are class types, interface types, array types, and delegate types.

I like to spend 30 minutes a time, a few times to read the book. Meanwhile, I like to use C# tutorial to help me do some research on language itself, and find some interesting and quality material to read to enhance my C# knowledge. The material I am looking for should not focus on the theory, better practical, work on small coding examples.

C# tutorial 


A few things I like to do:
1. Plan to spend 30 minutes a time to read the tutorial.
2. Write down new concepts here.
3. Try to go over the tutorial in September.

9/11/2017

Read page 1 and look into the declaration "C# is a simple, modern, object-oriented, and type-safe programming language."

Plan to look into the keyword: type-safe programming language C# -

15 minutes read:

"Learn C# tutorials", the article link is here.

9/12/2017

Read page 1 arguments:

"The type-safe design of the language makes it impossible to read from uninitialized variables, to index arrays beyond their bounds, or to perform unchecked type casts."

Questions:

- uninitialized variables - how the design make default initialization in C#
- index arrays beyond their bounds -
- unchecked type cast - what is the unchecked type cast?

Look into type-safe design of C#, name three of them.

Each common mistake plan to read 5 minutes.
Buggy C# code: The 10 most common mistakes that C# developers make -

C5 Generic Collection Library for C# and LCI - the github link is here.
Read page 1 argument:

"C# Has a Unified Type System. All C# types, including primitive types such as int and double, inherit from a single root object type. Thus, all types share a set of common operations, and values of any type can be stored, transported, and operated upon in a consistent manner. Furthermore, C# supports both user-defined reference types and value types, allowing dynamic allocation of objects as well as in-line storage of lightweight structures.".

I did Google on this, and then surprisingly I came cross the search result: #950 – C# Has a Unified Type System, I immediately decided to learn from the series of Csharp 2000 things.

Plan to go over 2000 things 30 minutes a time. Write down my favorite learning here.

2,000 things you should know about C#, the link is here.

Follow up


May 21, 2018

What I did is to review the blog, and then I also make the blog more readable. I added a few labels for easy to access. I specially like to document how I approach my goal to advance my C# skills.

Reading a book takes time. I like to use C# tutorial book to guide me to find interesting research topic. 

Feb. 20, 2024
I decided to read C# tutorial again. I searched my blog using keyword: C# tutorial, and then I found the book to read. 

Monday, November 6, 2017

Learning Interface through C# 2000 things

Nov. 6, 2017

Introduction


I got some advice to code to interface through the code review, so I plan to spend 2 hours to go over all interface things through C# 2000 things.

Here is the snapshot:


Code to Interface


It is so interesting to know that I enjoy to go over interface learning through C# 2000 things first. In order to understand the C# array and also IEnumerable interface, I need to go over the basics of C# first.


Actionable Items


Study Abstract class Array

Nov. 7, 2017


Actionable Item

Work on C# Array abstract class study

How many interfaces are derived from?

IClonable
IList
ICollection
IEnumerable
IStructuralComparable
IStructuralEquatable


Properties


IsFixedSize
IsReadOnly
IsSynchronize
Length
LongLength
Rank
SyncRoot

Method ( 10 methods a time)

AsReadOnly<T> (T[])
BinarySearch(Array, Int32, Int32, Object)  Use IComparable interface implemented by each element of the array and by the specified value.
BinarySearch(Array, Int32, Int32, Object, IComparer) Search a range of elements in a one-dimensional sorted array for a value, using the specified IComparer interface.
BinarySearch<T> (T[], T)
BinarySearch<T>(T[], T, IComparer<T>) Searches an entire one-dimensional sorted array for a value using the specified IComparer<T> generic interface.

BinarySearch<T>(T[], Int32, Int32, T) Searches a range of elements in a one-dimensional sorted array for a value, using the IComparable<T> generic interface implemented by each element of the Array and by the specified value.

BinarySearch<T>(T[], Int32, Int32, T, IComparer<T>) Searches a range of elements in a one-dimensional sorted array for a value, using the specified IComparer<T> generic interface.

Clear(Array, Int32, Int32) Sets a range of elements in an array to the default value of each element type.

Clone()
ConstrainedCopy(Array, Int32, Array, Int32, Int32) Copies a range of elements from an Array starting at the specified source index and pastes them to another Array starting at the specified destination index. Guarantees that all changes are undone if the copy does not succeed completely.

Start to read a question:
Why array implements IList?

IEnumerable vs IList

Nov. 8, 2017

What problem does IStructuralEquatable and IStructuralComparable solve?

Nov. 9, 2017
Read C# Array source code here. I found the link in the first few paragraphs of Array document.

Read C# SorterObjectArray - mscor.lib, the link is here. 

Wednesday, September 20, 2017

Understanding C# Array class

Sept. 20, 2017

Introduction


I had a mocking interview at 10:00 pm, and I like to write Array.IndexOf but I need to search Google for the help. I asked myself why it is not array.IndexOf() instead of calling an abstract class Array.IndexOf assuming that array is an object of Array class.

Here is my C# practice. I has a few issues to use Array.IndexOf instead of using hashmap to save the index.

Understanding C# Array


I like to read a few articles to get more educated on C# Array.

Read c# Array -
Read 10 minutes - C# Arrays Tutorial
https://msdn.microsoft.com/en-us/library/aa288453(v=vs.71).aspx

20 minutes reading:
http://www.c-sharpcorner.com/article/working-with-arrays-in-C-Sharp/

Study stackoverflow posts related to C# Array -

More reading:
https://www.codeproject.com/Articles/6118/All-about-abstract-classes



Csharp 2000 things



Work on C# 2000 things, the following image is highlighted by search keyword: Array


Plan to spend 10 minutes for each item related to Array, some of them are Julia's favorites.

#136, Sorting an Array of Values Based on an Array

Julia's ranking: 10 out of 10

#135, Implementing IComparable to Allow Sorting a Custom Type

9 out 10

#137, Sorting an Array Using an Independent Comparer method

9 out 10


Actionable Items



Plan to work on medium level algorithm called "Non-overlapping intervals". The link is here.


Follow up 


June 8, 2018

I spent over 20 minutes to look into more carefully about C# Array abstract class. It is true that Array.IndexOf is a static method, so that the call of the function should look like Array.IndexOf, instead of str.IndexOf. Compared to API SetValue as public  function, it will be called differently.

My second question is why IndexOf API is static but SetValue is non-static. Maybe we can read Array C# class source and then figure out why.

Wednesday, April 4, 2018

2,000 Things You Should Know About C#

April 4, 2018

Introduction


I was asked in my mock interview as an interviewer a few days ago, what language I will use in mock interview. Python, Java, JavaScript are mainly choices. I chose to use C# language.

In order to learn C# better, I spent a few hours in the morning to go over items in basics catalog on 2,000 Things You Should Know About C#.

C# reading 


Here are the items I plan to study again. I like to learn C# even I am very busy. Just work on 2,000 things, work on a few items every day.





Tuesday, September 12, 2017

2,000 things you should know about C#

Sept. 12, 2017


2,000 things you should know about C#, the link is https://csharp.2000things.com. Plan to work on 2,000 things as quick as possible. 

I did some reading on C# tutorial, and then I came cross this blog and it should be very helpful for me to learn C# in quick pace. I like to read the code and learn  a concept in the same time.



Monday, September 10, 2018

C# base class and base keyword

Sept. 10, 2018

Introduction


It is a good drill to work on C# 2000 things 20 minutes a time. A few times a month. I did search base through C# 2000 things. I did once, and then I had chance to look into over 20 items related to base class, base keyword.

One by one 


I like to go over one by one. Here are the items.

Monday, September 25, 2017

Leetcode 76: Find smallest substring

Sept. 25, 2017

Introduction


It is the classical algorithm similar to Leetcode 76. I already practiced more than two times, and I stumbled on the algorithm again. The mock interview started from 10:00 PM, and I started first to work on the algorithm, first 12 minutes I spent the time to explain the idea to solve the problem, and then I spent 18 minutes to write the code and thought out loud.

I found a secret. When I am too busy at work, I need somehow to remind myself, what is most important thing to work on.

It is true that most important is to train myself with basics, and learn how to work with the peer in more efficient way.

By going over mock interview, I have chance to educate myself, get more advice, and then I can start to apply to my current job. One mock interview a time, I figure out my weakness every time.

Last mock interview I found the issue of my understanding C# Array, and I spent 4 hours to work on Csharp 2000 things. I wrote a blog and then found "Csharp 2000 things" website, and I really enjoy learning from the short snippet.

Algorithm Practice 


C# code is here. I did not finish code in 30 minutes. I need to work on the left pointer while loop.

After Mock practice



C# code is here, with unique array "xyz" and string "xxxyz", the maximum substring is "xyz".  But failed on several issues.

Line 75, 76, if the visit char is not in the hashmap, the code will have run-time exception.
Line 89, the while loop condition to check if left pointer should move should be changed, one case is that the char is not in the hashmap, or if it is in the hashmap and also its value is negative.

Continue to update C# code, next version is here. The fix is on line 106,
   map[str[left]] ++;  // once the substring is found, and then left pointer should be moved to right, increment the hashmap on the char's count.

Continue to update C# code, the fourth version is here. The run time exception bug is fixed.

Continue to update C# code, the fifth version is here. The feature is added to remove the char not in the array when left pointer is handled.

Last two practices


Review last two practices, the link is here.


Actionable Item


It is so interesting to learn from my experience. It takes me over 3 years to learn the string search algorithm using sliding window. I still remembered that in January 2015, I spent a week every day after the work, wrote a lot of code on papers and tried to figure out the algorithm. At the end of the week, I decide to become a blogger to write blogs every day to track my progress.

I failed in 30 minutes to solve the problem, and failed in a week, and then failed after a few months, I wrote a blog in June 2015, the link is here.

Plan to study the algorithm "Length of the longest substring without repeating characters" on geeksforgeeks.org.


Train my eye to catch common bugs


Those three bugs in my first writing are common ones. The first one is related to hashmap, the dictionary to store unique characters. We need to check if the key is existing in the dictionary first. The second one is to discuss two options for the character, either in the dictionary or not in the dictionary. The third one is to maintain the dictionary value by checking increment and decrement correctly.

Nothing is new in terms of bug type. All I have to do is to review the code while I am doing whiteboard testing, think out loud, and ask myself what possible bugs are in the code.


Saturday, June 9, 2018

Inheritance - C# 2000 things to learn

June 9, 2018

Introduction


I like to have 30 minutes workout to work on inheritance through C# 2000 things to learn. I will write down something here.

Inheritance is a very good topic to work on. But if I only have 15 minutes to work on, it may be a good choice to invest time to learn something.

Quick and easy way to learn thing.

There are 11 search results on this page: https://csharp.2000things.com/index/

Let us give it 3 minutes for one thing. 33 minutes work out.


Wednesday, March 28, 2018

2,000 Things You Should Know About C#

March 28, 2018

Introduction


It is time for me to slow down to practice data structure and algorithm, and think about how to advance myself as  a C# programmer. One thing I like to do is to learn something quickly. I spent over one hour today to study interface from 2,000 things you should know about C#.

Interface




  • #434 – Interfaces
  • #435 – Implementing an Interface
  • #436 – The Implementation of an Interface Can Be a Subset of the Class
  • #437 – Access Interface Members through an Interface Variable
  • #438 – Benefits of Using Interfaces
  • #440 – A Class Can Implement More than One Interface
  • #441 – Implementing Interface Members Explicitly
  • #442 – Explicit Interface Implementation Allows Duplicate Member Names
  • #443 – An Interface Cannot Contain Fields
  • #444 – Interfaces Can Inherit from Other Interfaces
  • #445 – Differences Between an Interface and an Abstract Class
  • #446 – Deciding Between an Abstract Class and an Interface
  • #447 – Use as Operator to Get At an Object’s Interfaces
  • #448 – Use the is Operator to See if an Object Implements an Interface
  • #449 – You Can Pass an Interface Variable to a Method
  • #450 – Interfaces Should Normally Start with the Letter ‘I’
  • #451 – Implement Interface Explicitly to Simplify How a Class Appears to Clients
  • #454 – Return an Interface as a Return Value from a Method
  • #455 – Define an Interface Based on Existing Members of a Class
  • #456 – Explicitly Implemented Interface Members Are Automatically Private
  • #536 – Using a Generic Interface
  • #537 – Implement a Generic Interface with a Generic Class
  • #612 – Members of an Interface Are Implicitly Public
  • #613 – Interfaces Cannot Contain Static Members
  • #647 – A struct Can Implement an Interface
  • #799 – Interface Members Are Implicitly Public
  • #1,067 – Covariance and Generic Interfaces
  • #1,068 – Generic IEnumerable Interface Is Covariant
  • #1,069 – Contravariance and Generic Interfaces


  • It will take me 2 hours to go over those items.

    Wednesday, October 25, 2017

    Sorting an Array of Values Based on an Array of Keys

    Oct. 25, 2017

    Introduction



    One apple a day, keep doctor away. One program a day, also keep programmer awake. Today a small program keeps me awake to look into a few things, ...

    I like to share my practice using C# 2000 things, item 136: Sorting an Array of Values Based on an Array of Keys.

    Here is the C# code.

    Read the code and enjoy the workout.


    Sorting an array using an independent Comparer method

    Oct. 25, 2017

    Introduction


    One apple a day, keep doctor away. One program a day, also keep programmer awake. Today a small program keeps me awake to look into a few things, IComparer vs IComparable. 

    I like to share my practice using C# 2000 things, item 137: Sorting an array using an independent Comparer method.

    Here is the C# code.

    Read the code and enjoy the workout.

    Implementing IComparable to Allow Sorting a Custom Type

    Oct. 25, 2017

    Introduction


    One apple a day, keep doctor away. One program a day, also keep programmer awake. Today a small program keeps me awake to look into a few things, IComparer vs IComparable, throw new ArgumentExcecption on line 44. 

    I like to share my practice using C# 2000 things, item 135: Implement IComparable to allow sorting a custom type.

    Here is the C# code.


    Saturday, February 25, 2017

    Julia's Ph.D. study

    Feb. 25, 2017


    Julia's Ph.D. study 


    First time in long time, Julia was told that she had very good education from the most important person in her career in 2017. She could not believe that she got so good education and richness of experience of industry and academic fields, even though she quit in 2011 without a Ph.D. degree.

    So many good experience through her Ph.D. study spanning whole 10 years from 2000 to 2010. She could name 10 of them in a row:

    1. Two years intern at Motorola iDen group, city of Plantation, Florida from 2000 to 2002
    2. Teaching assistant work on introduction to programming, logic design and micro process lab.
    3. Network research
    4. Freedom to choose several graduate courses: education leadership, biology statistics, introduction to cryptography
    5. Write one book chapter
    6. Intern at a startup company called Siva near 1 year and then full time work less than 10 months at Par Tech
    7. Start a Chinese living water bible club around 2004
    8. Go back to Ph.d. study in 2007
    9. Write one book chapter and one conference paper, supported by National science foundation, supervised by Professor Jie Wu.
    10. Work on research on anonymity protocol research, advised by professor Hanqi Zhuang, Mihaela Cardei.


    Graduate study 


    Julia took one graduate course in education department when she worked on computer science Ph.D. in 2005, and also she took "biology statistics" mathematics graduate course by mathematics department professor Lianfen Qian as well, Introduction to Cryptography by mathematics department professor Markus Schmidmeier. She learned so many things through the mathematics courses, the way to prove things, reasoning and hard-working spirit to work on the math problems.

    She tried to innovate her Ph.D. study on computer science, and also tried a lot of ideas, for example, she worked as a teaching assistant in information technology department to grade C# programming course a few semesters, teaching assistant of the information department professor Qing Hu. She attended so many talks provided by visitors from the world, and she had chance to learn and be a classmate of so many people in Ph.D. study, more than 5 of them are computer professors right now in United States (Bing Wu, Feng Li, Wei Lou, Quan Yuan, Shuhui Yang, Xiuqi Li).

    Education leadership


    Most of her classmates in her education leadership class were the teachers in elementary school or other similar institutions. She enjoyed the structure of class teaching, around 10 of us were sitting inside the classroom, study and communicate through the whiteboard. The course name is "education leadership". One of Julia's concerns is how she can relate education leadership to herself, help herself to locate her next move in her career, go back to China or stay in USA or immigrate to Canada.

    Innovation is hard, Julia worked on her computer science Ph.D. program, and then she tried so many things but she had a lot of success and a lot of failures.

    To be continued 


    After 10 years ph.d. study, Julia started a new career in Canada, Vancouver city. She is kind of going back to old route, lack of innovation and motivation to push forward from 2010 to 2015. But Julia learned something through the involvement of the community, tech community and other activities, she sets a goal to attend the hackerrank programming contest and continuously improve the performance starting from April 2016, and also document great things daily in her life through up-and-downs.

    Julia likes to set some goals to learn courses on pluralsight.com about C# programming courses.

    Learn from WTA association and tennis professional players


    My most favorite teaching of leadership is this one, NO FEAR, feel at home, Kristina Mladenovic. Through hundreds of hours training and matches, tennis professional shows us how good they are to be inspiration of hard work and no fear spirit.

    Linkedin public profile: http://www.linkedin.com/in/jianminchen
    Coding Blogs: http://juliachencoding.blogspot.ca/
    HackerRank: https://www.hackerrank.com/jianminchen_fl
    Code review: http://codereview.stackexchange.com/users/123986/jianmin-chen?tab=profile
    Google Scholar: https://scholar.google.com/citations?hl=en&user=RKTRNtwAAAAJ

    Coding practice is like sports - I don't feel fear when I am on court. That's where I feel at home.

    Monday, September 10, 2018

    C# keywords: virtual, new, sealed, override

    Sept. 10, 2018

    Introduction


    It is a good question when to review object oriented polymorphism in C# language. I always am super busy. But I have to find time to work on it 20 - 30 minutes a time.

    I plan to study those items related to polymorphism in 2000 things you should know about C#.

    One by one


    Here are the list of items for me to study, review, and take some notes.

    Saturday, January 14, 2017

    Hackerrank week code 28 - Suffix Rotation

    January 14, 2017

    Introduction
    Life is not easy to compete the week code on Hackerrank, now Julia's ranking is following behind around 2900 out of 9985 at 11:54am, 1/14/2016. In order to get into the top 25%, she has to continue to work on the problem solving. It will be a lot of fun, a lot of mistakes, and trial and errors.

    Have some images to show the progress first, comparison to one in the ranking of 2000:


    Comparison to one in the ranking of 1000:


    The Great XOR

    Julia just found out through the above graph, she had some issues with the algorithm The Great XOR. Spent 5 minutes to look into detail. She did not have any test case failure when she worked on the algorithm, the hackerrank has issues to run so slow, only at the end of day, all test cases will be run. She lost almost 10 points on the algorithm.

    Usually, Julia likes to focus on easy and medium level algorithms, now in order to get a bronze medal, she has to learn to work on hard, advanced and expert algorithms, and try to do some research, read the discussion, and come out a simple idea to make extra points.

    Lucky Number Eight
    Julia did remember the algorithm was scored 18 instead of 10.80, now there are over 5 test case timeout. Six more test cases are added and she failed all of test cases because of timeout.

    Comparison to rank 515



    Instead, Julia can choose to walk around the outdoor, and get some physical exercise done first.


    Study, research, code 

    Suffix Rotation - problem statement

    1. Work on a test case:
    string abc, there are 6 variations:
    abc-> no rotation, answer is 0
    acb-> abc,  1 rotation
    bac->acb->abc,   2 rotations, second rotation starting from c
    bca->cab->abc,  1 rotation, but circular rotation 2 times
    cab->abc, 1 rotation
    cba->bac->acb->abc, 2 rotations

    2. Work on a test case with multiple instances of char:
    string abcbb, what is difference?
    abbbc,
    if we use counting sort, we can determine the char by counting the number, and then calculate difference.
    abbbc
    c should be in position of 2, starting from index = 0, but actually it is in position of 4
    rotation twice move 4 to 2, and also one of b is in position of 4, it should be in 2, also moved forward.

    3. Work on a test case, abcdb,
    so c should be in position 4, but it is in 2; 4 - 2 = 2, 1 rotation,

    Try to use recursion solution to gain a few points first. And get some ideas about the issues.

    Test Case: "cababc"

    After more than 3 hours coding, at 10:13pm, Julia studied the discussion related to the test case, Julia found out that there are more than one solution, but need to find minimum move.

    string cababc, using her naive solution, it will take 3 moves:
    cababc ->
    ababcc ->
    aabccb ->
    aabbcc

    but the minimum move only needs 2 moves:
    first 'a' is to use the second 'a' in the string "cababc", after first rotation, the string will be "abccab", and the second move is to use second b in the string "abccab", then final string "aabbcc".

    How to get the minimum move? Use brute force, then calculate each option for any char from a to z.

    Try to find something to think about:
    cababc->   ababcc
                      abccab

    From two strings to choose a small one, how to choose?
    abccab  -> aabbcc
    ababcc  -> aabccb

    Google Search: suffix rotation minimum

    ACM ICPC 2003 - the algorithm discussion is here.

    One more reading is here.

    Review Suffix Array and Longest Common Prefix

    Study code review

    Ashton and String Hackerrank


    my favorite algorithm teacher - JS1

    Actionable Items:

    Work on the minimum value by simply comparison. Try to get at least 1 point first.

    1. check into to document latest progress:
    1/15/2017 11:05am
    Using my code in C# to test the cases seen in the discussion - link is here.

    test case 1: hackerrank - 6
    test case 2: suffixrotation - 9

    Using queue, and calculate all the possible selections. 

    But my C# submission still scores 0, pass test case 0, and time out 1 and 2, and runtime error test case 3 on 1.97s. 

    Rotation definition - misunderstanding 

    2. Need to look into the rotation definition, see if it is making sense or not. 

    Choose index bigger than prior move. 
    but, at the index, perform circular rotation in either direction. 
    So, work on the example, abcdefjghi, at index 6, with char j, can rotate clock wise or anti-clockwise. 

    jghi -> anti-clockwise -> ijgh -> hijg ->..
    jghi -> clockwise ->  ghij -> hijg ->..

    So, work on the example: cababc
    first work on index 0, work on second a, 
                                                          clockwise, abccab
                                                          anti-clockwise, abaccb
                                       work on first a, 
                                                          clockwise, ababca
                                                          anti-clockwise, accbab

    and then, work on second char - index = 1, there are 4 choices. 

    Because Julia's C# code has wrong answer, probably it is because of her rotation misunderstanding, missing two cases. 

    Good workout and great learning 

    Suffix Rotation C# practice - score 0, but perfect learning experience. Julia learns the importance to challenge herself to work on hard algorithm, come out the solution to work ok with sample test cases. She spent more than 5 hours to work on the problem on Saturday January 14, 2016 and two more hours on January 15, 2016. 

    Have a very excellent experience to work on string manipulation, queue, and also read all discussions to get basic test cases with expected results. 

    Make some points on hard algorithm in future week code contest. It seems that week of code is most popular contest on HackerRank, and the difficulty level is up-to-most-top-standard. 

    After contest 

    code study - link is here. 
    Code review - rewrite the C# code, study and debug, code is here. 

    More study on the code, and 2nd version before code review, code is here.
    3rd version, code is here.

    Status report

    Julia finds out that there are so many solutions to study, and she does not have a lot of time to catch up so many things. Just go one by one.

    She will work hard on the algorithm, through the contest, she understood that it is most important to stay humble, and she is thankfulness to enjoy the practice. Just learn one thing a time.